From patchwork Wed Jan 21 04:16:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 5674591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 24F6EC058D for ; Wed, 21 Jan 2015 04:20:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56163204D6 for ; Wed, 21 Jan 2015 04:20:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86386204D2 for ; Wed, 21 Jan 2015 04:20:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YDmk4-00088X-CP; Wed, 21 Jan 2015 04:18:08 +0000 Received: from mail-pa0-f41.google.com ([209.85.220.41]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YDmjm-0007vh-PM for linux-arm-kernel@lists.infradead.org; Wed, 21 Jan 2015 04:17:52 +0000 Received: by mail-pa0-f41.google.com with SMTP id rd3so50223690pab.0 for ; Tue, 20 Jan 2015 20:17:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9Qrto0rMMol223HrGx/UIXvb5utCGfrAU8XfyOiO9A4=; b=Bi0Ul7V0GaoRI7wrTMzUpBbjh0LxfxxdWepJS1JkHfOLnQd/AjlkI1g89xbMbSeVig 4EMqlAwvVxFSjhvA+UJw4VdhlBzrLDT+nwaINxKZarjgBru72LXF9xMFTBjzzs5h0tUb WDisNzo2cbxECCd4Dkn/or0XrUPtZPFqVpH1Buhfrhm6Q3K7dTC3I6FRHb/zofFMKWi2 agf2JF7KZ5iHNEsWbw/JEVx3ymD5U3sAlfgId2NzFo7zbECyeGrBMUcHqQWvJqxWA5aI o+sV/GuKnn0Brc6R1BOmNq4aPJq05s/oTyW7IcBHvUkDe2dQ53KsrEqFCLVnIV+ftiO/ O6og== X-Gm-Message-State: ALoCoQmADV4n1bs1pZjmOH+cLpWWLHvbzmN3rSSiXppch4tzhWQkPb/0k2xT0C/7NQXb8JwfG1VQ X-Received: by 10.70.128.15 with SMTP id nk15mr57810923pdb.121.1421813849452; Tue, 20 Jan 2015 20:17:29 -0800 (PST) Received: from ss-ubuntu.lan ([106.51.225.38]) by mx.google.com with ESMTPSA id hx9sm4684773pad.38.2015.01.20.20.17.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jan 2015 20:17:28 -0800 (PST) From: Sumit Semwal To: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: [RFCv2 1/2] device: add dma_params->max_segment_count Date: Wed, 21 Jan 2015 09:46:46 +0530 Message-Id: <1421813807-9178-2-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421813807-9178-1-git-send-email-sumit.semwal@linaro.org> References: <1421813807-9178-1-git-send-email-sumit.semwal@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150120_201750_902010_2E214473 X-CRM114-Status: GOOD ( 11.24 ) X-Spam-Score: -0.7 (/) Cc: t.stanislaws@samsung.com, linaro-kernel@lists.linaro.org, robdclark@gmail.com, daniel@ffwll.ch, Sumit Semwal , m.szyprowski@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 [sumits: Minor updates wrt comments on the first version] Signed-off-by: Sumit Semwal --- include/linux/device.h | 1 + include/linux/dma-mapping.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index fb50673..a32f9b6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -647,6 +647,7 @@ struct device_dma_parameters { * sg limitations. */ unsigned int max_segment_size; + unsigned int max_segment_count; /* INT_MAX for unlimited */ unsigned long segment_boundary_mask; }; diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index c3007cb..38e2835 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -154,6 +154,25 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev, return -EIO; } +#define DMA_SEGMENTS_MAX_SEG_COUNT ((unsigned int) INT_MAX) + +static inline unsigned int dma_get_max_seg_count(struct device *dev) +{ + return dev->dma_parms ? + dev->dma_parms->max_segment_count : + DMA_SEGMENTS_MAX_SEG_COUNT; +} + +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 ?