From patchwork Thu Jul 12 17:44:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 9965 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 A589323E56 for ; Thu, 12 Jul 2012 17:44:25 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 739DBA18308 for ; Thu, 12 Jul 2012 17:44:25 +0000 (UTC) Received: by yhpp61 with SMTP id p61so3060124yhp.11 for ; Thu, 12 Jul 2012 10:44:24 -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 :x-gm-message-state; bh=c7EN89/W/rACGpbZxX+JHBuamdo4iNBrGkb3ZzN6E/A=; b=hNqyv5/jKeiSacDFMd4ceeF/noqyLx1zkgwgcWmz3BRqPbiUaiFuxxG3j1bfOqrNZl 65g9fqEMBDU/0vYplLNBi6jj07P255AaFJ6yCnZz4g5/ivyHy4dewp/lTuVCKEBQWKIy 7AlxnAkRdxNsCGymFzaK95/2VhE/V8nBsKWsK1qnQDeqD0XgINloGvf806JbUh7fpr1x 4cKpS7H//pzhdsN5DOM2mIsbbJxMAAXN1PAySSPuQ2LdC+9A5S2RIytaHd97JU2eHnZY J5wA6weFXWusYCPqODwcrMWA5yvqe/8e9uW2z/N25VEyDWBaOlX5jae5xvx/A5BjmsDK oHyg== Received: by 10.50.40.193 with SMTP id z1mr18647330igk.0.1342115064424; Thu, 12 Jul 2012 10:44:24 -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.241.2 with SMTP id lc2csp6849ibb; Thu, 12 Jul 2012 10:44:23 -0700 (PDT) Received: by 10.182.17.36 with SMTP id l4mr13344199obd.59.1342115063627; Thu, 12 Jul 2012 10:44:23 -0700 (PDT) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id im8si5328528obb.154.2012.07.12.10.44.23 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Jul 2012 10:44:23 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.214.178 as permitted sender) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.214.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by obbwd20 with SMTP id wd20so4585828obb.37 for ; Thu, 12 Jul 2012 10:44:23 -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; bh=c7EN89/W/rACGpbZxX+JHBuamdo4iNBrGkb3ZzN6E/A=; b=a5AUKc0PyODA77mdAuxDcMJnvyDuCqW1Yaf6khb567YjoLGcVxi/LU3a3YAeQ7su9P krkV1O/9kNZr1uE/0uRkt+OpB0qbV3FVw7cK1cAmLDs6gWwz9hSWZ+/yNqioxdEKd8wT lL9X/lE5WGzdHMIu1FDErlIgV2IE1qBGtErcsQj7BJYvbhQfUtNLHQWTRvSct6vdMkVw S10Sdv+1TaFlNOol1g6mk+9qQl3iTPpn6BiklkTDYMULdkHoKGLaFqnNNBYLkI6fZY/2 qlfubg2tMDMBkG/gN4htnJuSZISAwCJE+0rZteiL1fctCNzdG9IOhvbCWbPNwMlywCCQ b+Zg== Received: by 10.60.29.72 with SMTP id i8mr56045529oeh.26.1342115063359; Thu, 12 Jul 2012 10:44:23 -0700 (PDT) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id 6sm848827oef.6.2012.07.12.10.44.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Jul 2012 10:44:22 -0700 (PDT) Sender: Rob Clark From: Rob Clark To: linux-kernel@vger.kernel.org Cc: patches@linaro.org, linaro-mm-sig@lists.linaro.org, Rob Clark Subject: [PATCH] device: add dma_params->max_segment_count Date: Thu, 12 Jul 2012 12:44:16 -0500 Message-Id: <1342115056-27419-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmK5ULep6mWuPVlKIXXNy3MqDo+kJemOsAYCWOgdEkzA+FgaoahO+4u41QvXE2L2zA2yyzy 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 --- 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 ?