2011-05-26 06:27:00

by Shawn Guo

[permalink] [raw]
Subject: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

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 <[email protected]>
---
include/linux/device.h | 1 +
include/linux/dma-mapping.h | 15 +++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)

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


2011-05-26 06:27:03

by Shawn Guo

[permalink] [raw]
Subject: [PATCH 2/3] dmaengine: mxs-dma: set up max_segment_number

It calls dmaengine API dma_set_max_seg_number to set
device_dma_parameters max_segment_number.

Signed-off-by: Shawn Guo <[email protected]>
---
drivers/dma/mxs-dma.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 88aad4f..875d8f6 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -670,6 +670,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
/* mxs_dma gets 65535 bytes maximum sg size */
mxs_dma->dma_device.dev->dma_parms = &mxs_dma->dma_parms;
dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
+ dma_set_max_seg_number(mxs_dma->dma_device.dev, NUM_CCW);

mxs_dma->dma_device.device_alloc_chan_resources = mxs_dma_alloc_chan_resources;
mxs_dma->dma_device.device_free_chan_resources = mxs_dma_free_chan_resources;
--
1.7.4.1

2011-05-26 06:27:07

by Shawn Guo

[permalink] [raw]
Subject: [PATCH 3/3] mmc: mxs-mmc: call dmaengine API to set mmc->max_segs

With dmaengine API dma_get_max_seg_number added, we now can call
the API to get and number and then set mmc->max_segs instead of
hard-coding it.

Signed-off-by: Shawn Guo <[email protected]>
---
drivers/mmc/host/mxs-mmc.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 99d39a6..d783af3 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -745,11 +745,15 @@ static int mxs_mmc_probe(struct platform_device *pdev)
mmc->f_max = 288000000;
mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;

- mmc->max_segs = 52;
mmc->max_blk_size = 1 << 0xf;
mmc->max_blk_count = (ssp_is_old()) ? 0xff : 0xffffff;
mmc->max_req_size = (ssp_is_old()) ? 0xffff : 0xffffffff;
mmc->max_seg_size = dma_get_max_seg_size(host->dmach->device->dev);
+ /*
+ * Reserve one segment for carrying on pio words to get dma engine
+ * program mmc controller registers
+ */
+ mmc->max_segs = dma_get_max_seg_number(host->dmach->device->dev) - 1;

platform_set_drvdata(pdev, mmc);

--
1.7.4.1

2011-06-01 02:29:04

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

Hi Vinod,

Thoughts?

--
Regards,
Shawn

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 <[email protected]>
> ---
> include/linux/device.h | 1 +
> include/linux/dma-mapping.h | 15 +++++++++++++++
> 2 files changed, 16 insertions(+), 0 deletions(-)
>
> 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

2011-06-01 09:06:13

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

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 <[email protected]>
> ---
> 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 ?


2011-06-02 05:51:17

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

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 <[email protected]>
> > ---
> > 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.

--
Regards,
Shawn

2011-06-05 01:30:50

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

On Wed, 1 Jun 2011 10:33:57 +0800
Shawn Guo <[email protected]> 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 <[email protected]>
> > ---
> > 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 [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2011-06-06 06:03:31

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

On Sun, 2011-06-05 at 10:30 +0900, FUJITA Tomonori wrote:
> On Wed, 1 Jun 2011 10:33:57 +0800
> Shawn Guo <[email protected]> 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 <[email protected]>
> > > ---
> > > 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 [email protected]
> > 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 [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/


--
~Vinod

2011-06-06 06:09:53

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

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 <[email protected]>
> > > ---
> > > 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.

--
~Vinod

2011-06-06 06:38:36

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

On Mon, 06 Jun 2011 10:58:38 +0530
"Koul, Vinod" <[email protected]> wrote:

> On Sun, 2011-06-05 at 10:30 +0900, FUJITA Tomonori wrote:
> > On Wed, 1 Jun 2011 10:33:57 +0800
> > Shawn Guo <[email protected]> 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 <[email protected]>
> > > > ---
> > > > 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.

2011-06-06 06:49:44

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

On Mon, Jun 06, 2011 at 03:38:12PM +0900, FUJITA Tomonori wrote:
> On Mon, 06 Jun 2011 10:58:38 +0530
> "Koul, Vinod" <[email protected]> wrote:
>
> > On Sun, 2011-06-05 at 10:30 +0900, FUJITA Tomonori wrote:
> > > On Wed, 1 Jun 2011 10:33:57 +0800
> > > Shawn Guo <[email protected]> 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 <[email protected]>
> > > > > ---
> > > > > 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

--
Regards,
Shawn

2011-06-06 08:06:22

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: add new dma API for max_segment_number

On Mon, 6 Jun 2011 14:54:21 +0800
Shawn Guo <[email protected]> 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" <[email protected]> wrote:
> >
> > > On Sun, 2011-06-05 at 10:30 +0900, FUJITA Tomonori wrote:
> > > > On Wed, 1 Jun 2011 10:33:57 +0800
> > > > Shawn Guo <[email protected]> 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 <[email protected]>
> > > > > > ---
> > > > > > 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).