From patchwork Wed Jan 21 04:16:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 43429 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AAF8F2034D for ; Wed, 21 Jan 2015 04:17:35 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gf13sf9195720lab.0 for ; Tue, 20 Jan 2015 20:17:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:subject:date :message-id:in-reply-to:references:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=cf6IUkwYSlBYxNWQFJBndHH9BLxbiXERureGJKqlbKY=; b=LgV/9U16dpQbZD6yG0NEnBb9Fx8ATTo54B3Z+RGvAit9HIDN06FRIvbeXrFOn69l6Q +qnY+vaitSqFkqxNM9efEt88wOpHyx7EVj6V/A/V22iWmkH1xqcXKL19E5x4gW550I8q CAR6XYKaU7iSKJAyWZIZAxit3E0GG8cM/Sw3r7WvhWTgPnoG8C1OnLdeWplz9zWbVrsD mnAHrSSuJ2oMKmV4CQPrerRnguVDO8+vsk4RCnTkcKSwaYUHksjedNFXb9fgQizJ3VoV dG+yib9rcHuTICc8dXJVrJF77J1WLdaFsvi5GXB37xSyft3rVSHJ9uS+T9oQ5kdcjqnJ XTjQ== X-Gm-Message-State: ALoCoQlmr2jhcLjqhsvmkQDXDzLHgN4hd/NDWYOavVWt9a7PO5xb64wqRbxM0tNZZjLn5bdV+m7A X-Received: by 10.112.171.74 with SMTP id as10mr29162lbc.8.1421813854566; Tue, 20 Jan 2015 20:17:34 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.191.140 with SMTP id gy12ls557561lac.93.gmail; Tue, 20 Jan 2015 20:17:34 -0800 (PST) X-Received: by 10.112.235.194 with SMTP id uo2mr7235465lbc.57.1421813854421; Tue, 20 Jan 2015 20:17:34 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id o5si18255729lae.100.2015.01.20.20.17.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 20:17:34 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id s18so4831189lam.3 for ; Tue, 20 Jan 2015 20:17:34 -0800 (PST) X-Received: by 10.152.7.229 with SMTP id m5mr12840259laa.80.1421813854336; Tue, 20 Jan 2015 20:17:34 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1644012lbb; Tue, 20 Jan 2015 20:17:33 -0800 (PST) X-Received: by 10.68.131.39 with SMTP id oj7mr58881619pbb.145.1421813852538; Tue, 20 Jan 2015 20:17:32 -0800 (PST) Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id by10si7262908pab.69.2015.01.20.20.17.31; Tue, 20 Jan 2015 20:17:32 -0800 (PST) Received-SPF: none (google.com: dri-devel-bounces@lists.freedesktop.org does not designate permitted sender hosts) client-ip=131.252.210.177; Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 064696E6F8; Tue, 20 Jan 2015 20:17:31 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by gabe.freedesktop.org (Postfix) with ESMTP id AF6806E6F8 for ; Tue, 20 Jan 2015 20:17:29 -0800 (PST) Received: by mail-pd0-f173.google.com with SMTP id fp1so22374029pdb.4 for ; Tue, 20 Jan 2015 20:17:29 -0800 (PST) X-Received: by 10.70.128.15 with SMTP id nk15mr57810923pdb.121.1421813849452; Tue, 20 Jan 2015 20:17:29 -0800 (PST) Received: from ss-ubuntu.lan ([106.51.225.38]) by mx.google.com with ESMTPSA id hx9sm4684773pad.38.2015.01.20.20.17.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jan 2015 20:17:28 -0800 (PST) From: Sumit Semwal To: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: [RFCv2 1/2] device: add dma_params->max_segment_count Date: Wed, 21 Jan 2015 09:46:46 +0530 Message-Id: <1421813807-9178-2-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421813807-9178-1-git-send-email-sumit.semwal@linaro.org> References: <1421813807-9178-1-git-send-email-sumit.semwal@linaro.org> Cc: t.stanislaws@samsung.com, linaro-kernel@lists.linaro.org, m.szyprowski@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sumit.semwal@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Rob Clark For devices which have constraints about maximum number of segments in an sglist. For example, a device which could only deal with contiguous buffers would set max_segment_count to 1. The initial motivation is for devices sharing buffers via dma-buf, to allow the buffer exporter to know the constraints of other devices which have attached to the buffer. The dma_mask and fields in 'struct device_dma_parameters' tell the exporter everything else that is needed, except whether the importer has constraints about maximum number of segments. Signed-off-by: Rob Clark [sumits: Minor updates wrt comments on the first version] Signed-off-by: Sumit Semwal --- include/linux/device.h | 1 + include/linux/dma-mapping.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index fb50673..a32f9b6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -647,6 +647,7 @@ struct device_dma_parameters { * sg limitations. */ unsigned int max_segment_size; + unsigned int max_segment_count; /* INT_MAX for unlimited */ unsigned long segment_boundary_mask; }; diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index c3007cb..38e2835 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -154,6 +154,25 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, return -EIO; } +#define DMA_SEGMENTS_MAX_SEG_COUNT ((unsigned int) INT_MAX) + +static inline unsigned int dma_get_max_seg_count(struct device *dev) +{ + return dev->dma_parms ? + dev->dma_parms->max_segment_count : + DMA_SEGMENTS_MAX_SEG_COUNT; +} + +static inline int dma_set_max_seg_count(struct device *dev, + unsigned int count) +{ + if (dev->dma_parms) { + dev->dma_parms->max_segment_count = count; + return 0; + } else + return -EIO; +} + static inline unsigned long dma_get_seg_boundary(struct device *dev) { return dev->dma_parms ?