diff mbox

[1/3] dmaengine: add new dma API for max_segment_number

Message ID 1306391493-29425-1-git-send-email-shawn.guo@linaro.org
State New
Headers show

Commit Message

Shawn Guo May 26, 2011, 6:31 a.m. UTC
Like dma_set(get)_max_seg_size for max_segment_size, the patch adds
max_segment_number into device_dma_parameters and creates the
corresponding dmaengine API dma_set(get)_max_seg_number for it.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 include/linux/device.h      |    1 +
 include/linux/dma-mapping.h |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

Comments

Shawn Guo June 1, 2011, 2:33 a.m. UTC | #1
Hi Vinod,

Thoughts?
Vinod Koul June 1, 2011, 7:42 a.m. UTC | #2
On Thu, 2011-05-26 at 14:31 +0800, Shawn Guo wrote:
> Like dma_set(get)_max_seg_size for max_segment_size, the patch adds
> max_segment_number into device_dma_parameters and creates the
> corresponding dmaengine API dma_set(get)_max_seg_number for it.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  include/linux/device.h      |    1 +
>  include/linux/dma-mapping.h |   15 +++++++++++++++
>  2 files changed, 16 insertions(+), 0 deletions(-)
Can you explain me why this change is required, the patch description
isn't helping for this.

If you satisfy me with above then I am okay with it, but I need ACK from
Dan before applying...

~Vinod

> 
> diff --git a/include/linux/device.h b/include/linux/device.h
> index c66111a..44cb2528 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -487,6 +487,7 @@ struct device_dma_parameters {
>  	 * sg limitations.
>  	 */
>  	unsigned int max_segment_size;
> +	unsigned int max_segment_number;
>  	unsigned long segment_boundary_mask;
>  };
>  
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index ba8319a..fd314f4 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -131,6 +131,21 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev,
>  		return -EIO;
>  }
>  
> +static inline unsigned int dma_get_max_seg_number(struct device *dev)
> +{
> +	return dev->dma_parms ? dev->dma_parms->max_segment_number : 1;
> +}
> +
> +static inline unsigned int dma_set_max_seg_number(struct device *dev,
> +						  unsigned int number)
> +{
> +	if (dev->dma_parms) {
> +		dev->dma_parms->max_segment_number = number;
> +		return 0;
> +	} else
> +		return -EIO;
> +}
> +
>  static inline unsigned long dma_get_seg_boundary(struct device *dev)
>  {
>  	return dev->dma_parms ?
Shawn Guo June 2, 2011, 5:56 a.m. UTC | #3
On Wed, Jun 01, 2011 at 01:12:24PM +0530, Koul, Vinod wrote:
> On Thu, 2011-05-26 at 14:31 +0800, Shawn Guo wrote:
> > Like dma_set(get)_max_seg_size for max_segment_size, the patch adds
> > max_segment_number into device_dma_parameters and creates the
> > corresponding dmaengine API dma_set(get)_max_seg_number for it.
> > 
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > ---
> >  include/linux/device.h      |    1 +
> >  include/linux/dma-mapping.h |   15 +++++++++++++++
> >  2 files changed, 16 insertions(+), 0 deletions(-)
> Can you explain me why this change is required, the patch description
> isn't helping for this.
> 
> If you satisfy me with above then I am okay with it, but I need ACK from
> Dan before applying...
> 
I recently saw you people are trying to sort out the slave dma api
document.  This reminds me there is small piece missing, which the
patch here is trying to add.

Here is the user story.  The mxs-mmc is the mmc host controller for
Freescale MXS architecture.  There are a pair of  mmc host specific
parameters max_seg_size and max_segs that mxs-mmc host driver needs
to tell mmc core, so that mmc core can know how big each data segment
could be and how many segments could be handled one time in a scatter
list by host driver.

The mxs-mmc driver is one user of dmaengine mxs-dma, and it will call
mxs-dma to transfer data in scatter list.  That is to say mxs-mmc has
not idea of what max_seg_size and max_segs should be, because they are
all mxs-dma capability parameters, and mxs-mmc needs to query them
from mxs-dma.

Right now, there is well defined dma api (dma_get_max_seg_size) for
mmc to query max_seg_size from dma driver, but the one for max_segs is
missing.  That's why mxs-mmc driver has to hard-code it.

The mxs-mmc is just one example to demonstrate the need of the new
api, and I'm sure there are other mmc host drivers (mxcmmc on imx-dma
is another example) and possibly even other dmaengine users need this
new api to know the maximum segments that dma driver can handle per
dma call.
FUJITA Tomonori June 5, 2011, 1:30 a.m. UTC | #4
On Wed, 1 Jun 2011 10:33:57 +0800
Shawn Guo <shawn.guo@freescale.com> wrote:

> On Thu, May 26, 2011 at 02:31:31PM +0800, Shawn Guo wrote:
> > Like dma_set(get)_max_seg_size for max_segment_size, the patch adds
> > max_segment_number into device_dma_parameters and creates the
> > corresponding dmaengine API dma_set(get)_max_seg_number for it.
> > 
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > ---
> >  include/linux/device.h      |    1 +
> >  include/linux/dma-mapping.h |   15 +++++++++++++++
> >  2 files changed, 16 insertions(+), 0 deletions(-)

include/linux/dma-mapping.h is for DMA mapping API (please see
Documentation/DMA-API*.txt).

What does dma_set(get)_max_seg_size do? And it's related with DMA
mapping API?


> > 
> > diff --git a/include/linux/device.h b/include/linux/device.h
> > index c66111a..44cb2528 100644
> > --- a/include/linux/device.h
> > +++ b/include/linux/device.h
> > @@ -487,6 +487,7 @@ struct device_dma_parameters {
> >  	 * sg limitations.
> >  	 */
> >  	unsigned int max_segment_size;
> > +	unsigned int max_segment_number;
> >  	unsigned long segment_boundary_mask;
> >  };
> >  
> > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > index ba8319a..fd314f4 100644
> > --- a/include/linux/dma-mapping.h
> > +++ b/include/linux/dma-mapping.h
> > @@ -131,6 +131,21 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev,
> >  		return -EIO;
> >  }
> >  
> > +static inline unsigned int dma_get_max_seg_number(struct device *dev)
> > +{
> > +	return dev->dma_parms ? dev->dma_parms->max_segment_number : 1;
> > +}
> > +
> > +static inline unsigned int dma_set_max_seg_number(struct device *dev,
> > +						  unsigned int number)
> > +{
> > +	if (dev->dma_parms) {
> > +		dev->dma_parms->max_segment_number = number;
> > +		return 0;
> > +	} else
> > +		return -EIO;
> > +}
> > +
> >  static inline unsigned long dma_get_seg_boundary(struct device *dev)
> >  {
> >  	return dev->dma_parms ?
> > -- 
> > 1.7.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
Vinod Koul June 6, 2011, 5:28 a.m. UTC | #5
On Sun, 2011-06-05 at 10:30 +0900, FUJITA Tomonori wrote:
> On Wed, 1 Jun 2011 10:33:57 +0800
> Shawn Guo <shawn.guo@freescale.com> wrote:
> 
> > On Thu, May 26, 2011 at 02:31:31PM +0800, Shawn Guo wrote:
> > > Like dma_set(get)_max_seg_size for max_segment_size, the patch adds
> > > max_segment_number into device_dma_parameters and creates the
> > > corresponding dmaengine API dma_set(get)_max_seg_number for it.
> > > 
> > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > > ---
> > >  include/linux/device.h      |    1 +
> > >  include/linux/dma-mapping.h |   15 +++++++++++++++
> > >  2 files changed, 16 insertions(+), 0 deletions(-)
> 
> include/linux/dma-mapping.h is for DMA mapping API (please see
> Documentation/DMA-API*.txt).
> 
> What does dma_set(get)_max_seg_size do? And it's related with DMA
> mapping API?
See the other post by author



> 
> 
> > > 
> > > diff --git a/include/linux/device.h b/include/linux/device.h
> > > index c66111a..44cb2528 100644
> > > --- a/include/linux/device.h
> > > +++ b/include/linux/device.h
> > > @@ -487,6 +487,7 @@ struct device_dma_parameters {
> > >  	 * sg limitations.
> > >  	 */
> > >  	unsigned int max_segment_size;
> > > +	unsigned int max_segment_number;
> > >  	unsigned long segment_boundary_mask;
> > >  };
> > >  
> > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > > index ba8319a..fd314f4 100644
> > > --- a/include/linux/dma-mapping.h
> > > +++ b/include/linux/dma-mapping.h
> > > @@ -131,6 +131,21 @@ static inline unsigned int dma_set_max_seg_size(struct device *dev,
> > >  		return -EIO;
> > >  }
> > >  
> > > +static inline unsigned int dma_get_max_seg_number(struct device *dev)
> > > +{
> > > +	return dev->dma_parms ? dev->dma_parms->max_segment_number : 1;
> > > +}
> > > +
> > > +static inline unsigned int dma_set_max_seg_number(struct device *dev,
> > > +						  unsigned int number)
> > > +{
> > > +	if (dev->dma_parms) {
> > > +		dev->dma_parms->max_segment_number = number;
> > > +		return 0;
> > > +	} else
> > > +		return -EIO;
> > > +}
> > > +
> > >  static inline unsigned long dma_get_seg_boundary(struct device *dev)
> > >  {
> > >  	return dev->dma_parms ?
> > > -- 
> > > 1.7.4.1
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
Vinod Koul June 6, 2011, 5:35 a.m. UTC | #6
On Thu, 2011-06-02 at 13:56 +0800, Shawn Guo wrote:
> On Wed, Jun 01, 2011 at 01:12:24PM +0530, Koul, Vinod wrote:
> > On Thu, 2011-05-26 at 14:31 +0800, Shawn Guo wrote:
> > > Like dma_set(get)_max_seg_size for max_segment_size, the patch adds
> > > max_segment_number into device_dma_parameters and creates the
> > > corresponding dmaengine API dma_set(get)_max_seg_number for it.
> > > 
> > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > > ---
> > >  include/linux/device.h      |    1 +
> > >  include/linux/dma-mapping.h |   15 +++++++++++++++
> > >  2 files changed, 16 insertions(+), 0 deletions(-)
> > Can you explain me why this change is required, the patch description
> > isn't helping for this.
> > 
> > If you satisfy me with above then I am okay with it, but I need ACK from
> > Dan before applying...
> > 
> I recently saw you people are trying to sort out the slave dma api
> document.  This reminds me there is small piece missing, which the
> patch here is trying to add.
> 
> Here is the user story.  The mxs-mmc is the mmc host controller for
> Freescale MXS architecture.  There are a pair of  mmc host specific
> parameters max_seg_size and max_segs that mxs-mmc host driver needs
> to tell mmc core, so that mmc core can know how big each data segment
> could be and how many segments could be handled one time in a scatter
> list by host driver.
> 
> The mxs-mmc driver is one user of dmaengine mxs-dma, and it will call
> mxs-dma to transfer data in scatter list.  That is to say mxs-mmc has
> not idea of what max_seg_size and max_segs should be, because they are
> all mxs-dma capability parameters, and mxs-mmc needs to query them
> from mxs-dma.
> 
> Right now, there is well defined dma api (dma_get_max_seg_size) for
> mmc to query max_seg_size from dma driver, but the one for max_segs is
> missing.  That's why mxs-mmc driver has to hard-code it.
> 
> The mxs-mmc is just one example to demonstrate the need of the new
> api, and I'm sure there are other mmc host drivers (mxcmmc on imx-dma
> is another example) and possibly even other dmaengine users need this
> new api to know the maximum segments that dma driver can handle per
> dma call.
> 
Looks fine, care to add above in your patch description.
Few years down it will be really helpful to know why this was added.
FUJITA Tomonori June 6, 2011, 6:38 a.m. UTC | #7
On Mon, 06 Jun 2011 10:58:38 +0530
"Koul, Vinod" <vinod.koul@intel.com> wrote:

> On Sun, 2011-06-05 at 10:30 +0900, FUJITA Tomonori wrote:
> > On Wed, 1 Jun 2011 10:33:57 +0800
> > Shawn Guo <shawn.guo@freescale.com> wrote:
> > 
> > > On Thu, May 26, 2011 at 02:31:31PM +0800, Shawn Guo wrote:
> > > > Like dma_set(get)_max_seg_size for max_segment_size, the patch adds
> > > > max_segment_number into device_dma_parameters and creates the
> > > > corresponding dmaengine API dma_set(get)_max_seg_number for it.
> > > > 
> > > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > > > ---
> > > >  include/linux/device.h      |    1 +
> > > >  include/linux/dma-mapping.h |   15 +++++++++++++++
> > > >  2 files changed, 16 insertions(+), 0 deletions(-)
> > 
> > include/linux/dma-mapping.h is for DMA mapping API (please see
> > Documentation/DMA-API*.txt).
> > 
> > What does dma_set(get)_max_seg_size do? And it's related with DMA
> > mapping API?
> See the other post by author

The pointer, please.
Shawn Guo June 6, 2011, 6:54 a.m. UTC | #8
On Mon, Jun 06, 2011 at 03:38:12PM +0900, FUJITA Tomonori wrote:
> On Mon, 06 Jun 2011 10:58:38 +0530
> "Koul, Vinod" <vinod.koul@intel.com> wrote:
> 
> > On Sun, 2011-06-05 at 10:30 +0900, FUJITA Tomonori wrote:
> > > On Wed, 1 Jun 2011 10:33:57 +0800
> > > Shawn Guo <shawn.guo@freescale.com> wrote:
> > > 
> > > > On Thu, May 26, 2011 at 02:31:31PM +0800, Shawn Guo wrote:
> > > > > Like dma_set(get)_max_seg_size for max_segment_size, the patch adds
> > > > > max_segment_number into device_dma_parameters and creates the
> > > > > corresponding dmaengine API dma_set(get)_max_seg_number for it.
> > > > > 
> > > > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > > > > ---
> > > > >  include/linux/device.h      |    1 +
> > > > >  include/linux/dma-mapping.h |   15 +++++++++++++++
> > > > >  2 files changed, 16 insertions(+), 0 deletions(-)
> > > 
> > > include/linux/dma-mapping.h is for DMA mapping API (please see
> > > Documentation/DMA-API*.txt).
> > > 
Hmm, I think they are all about dmaengine.

> > > What does dma_set(get)_max_seg_size do? And it's related with DMA
> > > mapping API?
> > See the other post by author
> 
> The pointer, please.
> 
http://permalink.gmane.org/gmane.linux.kernel/1149304
FUJITA Tomonori June 6, 2011, 8:06 a.m. UTC | #9
On Mon, 6 Jun 2011 14:54:21 +0800
Shawn Guo <shawn.guo@freescale.com> wrote:

> On Mon, Jun 06, 2011 at 03:38:12PM +0900, FUJITA Tomonori wrote:
> > On Mon, 06 Jun 2011 10:58:38 +0530
> > "Koul, Vinod" <vinod.koul@intel.com> wrote:
> > 
> > > On Sun, 2011-06-05 at 10:30 +0900, FUJITA Tomonori wrote:
> > > > On Wed, 1 Jun 2011 10:33:57 +0800
> > > > Shawn Guo <shawn.guo@freescale.com> wrote:
> > > > 
> > > > > On Thu, May 26, 2011 at 02:31:31PM +0800, Shawn Guo wrote:
> > > > > > Like dma_set(get)_max_seg_size for max_segment_size, the patch adds
> > > > > > max_segment_number into device_dma_parameters and creates the
> > > > > > corresponding dmaengine API dma_set(get)_max_seg_number for it.
> > > > > > 
> > > > > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> > > > > > ---
> > > > > >  include/linux/device.h      |    1 +
> > > > > >  include/linux/dma-mapping.h |   15 +++++++++++++++
> > > > > >  2 files changed, 16 insertions(+), 0 deletions(-)
> > > > 
> > > > include/linux/dma-mapping.h is for DMA mapping API (please see
> > > > Documentation/DMA-API*.txt).
> > > > 
> Hmm, I think they are all about dmaengine.

No, I added them for the DMA mapping API (mainly, IOMMUs).
diff mbox

Patch

diff --git a/include/linux/device.h b/include/linux/device.h
index c66111a..44cb2528 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -487,6 +487,7 @@  struct device_dma_parameters {
 	 * sg limitations.
 	 */
 	unsigned int max_segment_size;
+	unsigned int max_segment_number;
 	unsigned long segment_boundary_mask;
 };
 
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index ba8319a..fd314f4 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -131,6 +131,21 @@  static inline unsigned int dma_set_max_seg_size(struct device *dev,
 		return -EIO;
 }
 
+static inline unsigned int dma_get_max_seg_number(struct device *dev)
+{
+	return dev->dma_parms ? dev->dma_parms->max_segment_number : 1;
+}
+
+static inline unsigned int dma_set_max_seg_number(struct device *dev,
+						  unsigned int number)
+{
+	if (dev->dma_parms) {
+		dev->dma_parms->max_segment_number = number;
+		return 0;
+	} else
+		return -EIO;
+}
+
 static inline unsigned long dma_get_seg_boundary(struct device *dev)
 {
 	return dev->dma_parms ?