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: 1218021 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id E3822DF24C for ; Thu, 19 Jul 2012 16:26:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C7359A0FC5 for ; Thu, 19 Jul 2012 09:26:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f177.google.com (mail-qc0-f177.google.com [209.85.216.177]) by gabe.freedesktop.org (Postfix) with ESMTP id A4D56A0FCB for ; Thu, 19 Jul 2012 09:24:50 -0700 (PDT) Received: by qcsu28 with SMTP id u28so1796805qcs.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> Cc: t.stanislaws@samsung.com, linux@arm.linux.org.uk, arnd@arndb.de, patches@linaro.org, maarten.lankhorst@canonical.com, Rob Clark , m.szyprowski@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.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 ?