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: 5674531 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 19C469F358 for ; Wed, 21 Jan 2015 04:17:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E2D920303 for ; Wed, 21 Jan 2015 04:17:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A1199204D1 for ; Wed, 21 Jan 2015 04:17:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 064696E6F8; Tue, 20 Jan 2015 20:17:31 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by gabe.freedesktop.org (Postfix) with ESMTP id AF6806E6F8 for ; Tue, 20 Jan 2015 20:17:29 -0800 (PST) Received: by mail-pd0-f173.google.com with SMTP id fp1so22374029pdb.4 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=eUw1hOuqkmAlBH3n7/A70Bd7psqtZHQulnpqL2q9njc2BNoaYD3idlrcpLtaq2lr1I Fu8vdEvZ/oHm5n0NhENb+ZuK1TTe1gKjvXAJ+uvkoL93G31L1m5nfsehuOUOkKTtUHiL cdZufciMTRxK/clunPzWt7J08ThkhbeheVp1jtcNj/Na9KV/yhm8FMTQxPEcvb2gCYWe DmUoJCWWIIHbY6lXvJhJwJ/zrUP+V9Q7llb8tm/BHy8hkmvAYxrSQjKWdFvr3kmLknWN 2tSr0w8DLsXL/oiBBhg8jgpf0Hwl/51F0OQ4MaTQ4pQcqLzk9PbVavBwFsZvyqGyO1ph oClA== X-Gm-Message-State: ALoCoQkjtSmpxA3zIlpt0FJXScN1UA1AMeib+lDboiuBpGANnPjibTjLWSXOSInVt0I4ZQrdA+Lc 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> Cc: t.stanislaws@samsung.com, linaro-kernel@lists.linaro.org, m.szyprowski@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 ?