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: 1218011 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 40D2CDF24C for ; Thu, 19 Jul 2012 16:25:40 +0000 (UTC) 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 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 ?