Message ID | 1421813807-9178-2-git-send-email-sumit.semwal@linaro.org (mailing list archive) |
---|---|
State | RFC, archived |
Headers |
Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from <linux-media-owner@vger.kernel.org>) id 1YDmk3-0001Y2-Uz; Wed, 21 Jan 2015 05:18:07 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-7) with esmtp id 1YDmk2-00033a-05; Wed, 21 Jan 2015 05:18:07 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754062AbbAUERd (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Tue, 20 Jan 2015 23:17:33 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:40210 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754037AbbAUER3 (ORCPT <rfc822;linux-media@vger.kernel.org>); Tue, 20 Jan 2015 23:17:29 -0500 Received: by mail-pa0-f53.google.com with SMTP id kx10so5877467pab.12 for <linux-media@vger.kernel.org>; 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=LOqNGZCqK11dceu/ejamXsquUUIbIE3KJdS/CURpfFsb2lyfzAkK7uGdiMaBc/z/BH dTT5fKuGIfOT7gwC+9BaLzPWXPqSNgn01xIPsyBpliZ74V2N0ELb7jYA0JBTg0uCZIra vLWUIWT6ZsghhyqoRujjKIzt4MTl1Fz6pRYm6SS6Ljc3NPoALlcgrDS46bfLE9UUW8MV xwMZlvIfWBwFPSGnRrAL4MYrUbbSEbhUmCJzGxuJYktpv/Nrux3l1b6VOLVuwUReba8I NiSEkjPdbpiaFhmUK2Um890GNjFvbnLGK5mDPtQKwkTdwdwbuu7UqjuX+1R1wSfyd+Av PKnA== X-Gm-Message-State: ALoCoQkobcvZDqalv77yNhfY5EFnwPyqOG3S3cTOV7QHsyWlU8enUcBW3UsbvD3pAKFEKDRpnbdN 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 <sumit.semwal@linaro.org> 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 Cc: linaro-kernel@lists.linaro.org, robdclark@gmail.com, daniel@ffwll.ch, m.szyprowski@samsung.com, t.stanislaws@samsung.com, Sumit Semwal <sumit.semwal@linaro.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> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.1.21.40921 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __MULTIPLE_RCPTS_TO_X5 0, __REFERENCES 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' |
Commit Message
Sumit Semwal
Jan. 21, 2015, 4:16 a.m. UTC
From: Rob Clark <robdclark@gmail.com> 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 <robdclark@gmail.com> [sumits: Minor updates wrt comments on the first version] Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> --- include/linux/device.h | 1 + include/linux/dma-mapping.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
Comments
Hi Sumit, On 21/01/15 04:16, Sumit Semwal wrote: > From: Rob Clark <robdclark@gmail.com> > > 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 <robdclark@gmail.com> > [sumits: Minor updates wrt comments on the first version] > Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> > --- > 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; > +} I know this copies the style of the existing code, but unfortunately it also copies the subtle brokenness. Plenty of drivers seem to set up a dma_parms struct just for max_segment_size, thus chances are you'll come across a max_segment_count of 0 sooner or later. How badly is that going to break things? I posted a fix recently[1] having hit this problem with segment_boundary_mask in IOMMU code. > + > +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 This "else" is just as unnecessary as the other two I've taken out ;) Robin. [1]:http://article.gmane.org/gmane.linux.kernel.iommu/8175/ > + return -EIO; > +} > + > static inline unsigned long dma_get_seg_boundary(struct device *dev) > { > return dev->dma_parms ? > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Robin! On 22 January 2015 at 00:26, Robin Murphy <robin.murphy@arm.com> wrote: > Hi Sumit, > > > On 21/01/15 04:16, Sumit Semwal wrote: >> >> From: Rob Clark <robdclark@gmail.com> >> >> 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 <robdclark@gmail.com> >> [sumits: Minor updates wrt comments on the first version] >> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> >> --- >> 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; >> +} > > > I know this copies the style of the existing code, but unfortunately it also > copies the subtle brokenness. Plenty of drivers seem to set up a dma_parms > struct just for max_segment_size, thus chances are you'll come across a > max_segment_count of 0 sooner or later. How badly is that going to break > things? I posted a fix recently[1] having hit this problem with > segment_boundary_mask in IOMMU code. > Thanks very much for reviewing this code; and apologies for missing your patch that you mentioned here; sure, I will update my patch accordingly as well. >> + >> +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 > > > This "else" is just as unnecessary as the other two I've taken out ;) > > > Robin. > > [1]:http://article.gmane.org/gmane.linux.kernel.iommu/8175/ > > >> + return -EIO; >> +} >> + >> static inline unsigned long dma_get_seg_boundary(struct device *dev) >> { >> return dev->dma_parms ? >> > > BR, Sumit. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 ?