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: 13413 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SrtXp-0007SR-39 for patchwork@linuxtv.org; Thu, 19 Jul 2012 18:25:41 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-2) with esmtp for id 1SrtXo-0003Qp-HR; Thu, 19 Jul 2012 18:25:40 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751981Ab2GSQYy (ORCPT ); Thu, 19 Jul 2012 12:24:54 -0400 Received: from mail-yw0-f46.google.com ([209.85.213.46]:39798 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750894Ab2GSQYu (ORCPT ); Thu, 19 Jul 2012 12:24:50 -0400 Received: by yhmm54 with SMTP id m54so2945304yhm.19 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 Cc: patches@linaro.org, linux@arm.linux.org.uk, arnd@arndb.de, jesse.barker@linaro.org, m.szyprowski@samsung.com, daniel@ffwll.ch, t.stanislaws@samsung.com, sumit.semwal@ti.com, maarten.lankhorst@canonical.com, Rob Clark 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> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.7.19.161816 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, DATE_TZ_NEG_0500 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __MULTIPLE_RCPTS_TO_X5 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' 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 ?