From patchwork Thu Jul 19 16:23:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 1218051 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id AF9A1DF24C for ; Thu, 19 Jul 2012 16:32:44 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SrtY0-00059B-Rh; Thu, 19 Jul 2012 16:25:52 +0000 Received: from mail-qc0-f177.google.com ([209.85.216.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SrtX0-00057q-Jv for linux-arm-kernel@lists.infradead.org; Thu, 19 Jul 2012 16:24:51 +0000 Received: by qcsu28 with SMTP id u28so1796804qcs.36 for ; Thu, 19 Jul 2012 09:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=c7EN89/W/rACGpbZxX+JHBuamdo4iNBrGkb3ZzN6E/A=; b=ri1WQd5mxFCmqcvcQJzhL0rJACgcuH6Zv4TDAS+m4VKZFPxr08vF3qjW35SBZr3fsV TeEE2ZzGOaW4IUlur/i4+s22eFUiQlkhtAN0UD3alXg27sit7CuMfoB99kbAkCHFCpGd b2b0pLt577VEwMry+2wD/c/GZHBeaO6tZip2RerP6BZPUBe/sgHHbSDu+Sv6Wo9E35CK S1jC5YT29yU12Nk6Zyci2aKxTR1TVA6PJmlrKKgOKbb7SfHrosQCsFk4vhQaGQG13z7e i4uBL10UvF710cQ/mtGLIVrGL1BjH2LK95HXxQnP6Ga0hrn1ZZu3QEIFz+iQJBZVVqtb sIZQ== Received: by 10.60.3.202 with SMTP id e10mr3609308oee.52.1342715090081; Thu, 19 Jul 2012 09:24:50 -0700 (PDT) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id g3sm1539523oeb.5.2012.07.19.09.24.48 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Jul 2012 09:24:49 -0700 (PDT) From: Rob Clark To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org Subject: [PATCH 1/2] device: add dma_params->max_segment_count Date: Thu, 19 Jul 2012 11:23:33 -0500 Message-Id: <1342715014-5316-2-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1342715014-5316-1-git-send-email-rob.clark@linaro.org> References: <1342715014-5316-1-git-send-email-rob.clark@linaro.org> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.216.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robdclark[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: t.stanislaws@samsung.com, linux@arm.linux.org.uk, sumit.semwal@ti.com, arnd@arndb.de, patches@linaro.org, jesse.barker@linaro.org, daniel@ffwll.ch, maarten.lankhorst@canonical.com, Rob Clark , m.szyprowski@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 Acked-by: Marek Szyprowski --- include/linux/device.h | 1 + include/linux/dma-mapping.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index 161d962..3813735 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -568,6 +568,7 @@ struct device_dma_parameters { * sg limitations. */ unsigned int max_segment_size; + unsigned int max_segment_count; /* zero for unlimited */ unsigned long segment_boundary_mask; }; diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index dfc099e..f380f79 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -111,6 +111,22 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, return -EIO; } +static inline unsigned int dma_get_max_seg_count(struct device *dev) +{ + return dev->dma_parms ? dev->dma_parms->max_segment_count : 0; +} + +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 ?