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: 10151 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2C1DB23E56 for ; Thu, 19 Jul 2012 16:24:52 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id D66AEA182B6 for ; Thu, 19 Jul 2012 16:24:51 +0000 (UTC) Received: by ghbz12 with SMTP id z12so3183260ghb.11 for ; Thu, 19 Jul 2012 09:24:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=c7EN89/W/rACGpbZxX+JHBuamdo4iNBrGkb3ZzN6E/A=; b=CORXZIOKVHOyjBGLM5eopCs9BiG0ZhujAdWEHhKKwMukoDxHiWpoCw7zq5f+DKeAXp M4oD9dlioegWoEeh516IM/xn1RGm2V415f0iblPC26KVJuxkfBccANDctrw96pI87UFR 1L+QcYw6xqLKSC/zk8Oo4o+NJSbqhzk2cmd3JPVlWWcXWE73PwtBVc1k54zLUpETVchl QLcD9H9RwCouUJWOdr3A2ZkpUut8hZP19MDV+xxn1Ws2HI7s70QJrqKTh/fB8gsWgyLd A5cqtMg4BTZMUyDkQ1YvI/uQ72orhg8nt/6qjMCTdXTrG9KACbDYyD4XXfMQrB2DNnns g6BQ== Received: by 10.43.63.140 with SMTP id xe12mr1629937icb.57.1342715091215; Thu, 19 Jul 2012 09:24:51 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.153.7 with SMTP id i7csp13157ibw; Thu, 19 Jul 2012 09:24:50 -0700 (PDT) Received: by 10.236.175.231 with SMTP id z67mr2042631yhl.34.1342715090495; Thu, 19 Jul 2012 09:24:50 -0700 (PDT) Received: from mail-yx0-f178.google.com (mail-yx0-f178.google.com [209.85.213.178]) by mx.google.com with ESMTPS id h1si1026151anl.13.2012.07.19.09.24.50 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Jul 2012 09:24:50 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.213.178 as permitted sender) client-ip=209.85.213.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.213.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by yenl6 with SMTP id l6so3513059yen.37 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) Sender: Rob Clark 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> X-Gm-Message-State: ALoCoQkoAyxvGyClFeuSCxMSyu82WTYW/vfW5oCHJRoNWITbjvFbkAQ+Fm7pgtnGjNclMPv8OV6P 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 ?