Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-30 Thread Lee Jones
On Tue, 30 Apr 2013, Linus Walleij wrote:

> On Wed, Apr 24, 2013 at 12:58 PM, Lee Jones  wrote:
> 
> > Currently, if DMA information isn't passed from platform data, then DMA
> > will not be used. This patch allows DMA information obtained though Device
> > Tree to be used as well.
> >
> > Cc: Russell King 
> > Cc: Chris Ball 
> > Cc: linux-...@vger.kernel.org
> > Signed-off-by: Lee Jones 
> (...)
> 
> I tried to test this patch, but:
>   CC  drivers/mmc/host/mmci.o
> /drivers/mmc/host/mmci.c: In function 'mmci_dma_setup':
> /drivers/mmc/host/mmci.c:307:51: error: 'dev' undeclared (first use in
> this function)
> /drivers/mmc/host/mmci.c:307:51: note: each undeclared identifier is
> reported only once for each function it appears in
> make[5]: *** [drivers/mmc/host/mmci.o] Error 1
> make[4]: *** [drivers/mmc/host] Error 2
> make[3]: *** [drivers/mmc] Error 2
> 
> Due to:
> 
> > @@ -304,10 +304,8 @@ static void mmci_dma_setup(struct mmci_host *host)
> > const char *rxname, *txname;
> > dma_cap_mask_t mask;
> >
> > -   if (!plat || !plat->dma_filter) {
> > -   dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
> > -   return;
> > -   }
> > +   host->dma_rx_channel = dma_request_slave_channel(dev, "rx");
> > +   host->dma_tx_channel = dma_request_slave_channel(dev, "tx");
> 
> There is no "dev" here.

You've missed v2 again dude.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-30 Thread Linus Walleij
On Wed, Apr 24, 2013 at 12:58 PM, Lee Jones  wrote:

> Currently, if DMA information isn't passed from platform data, then DMA
> will not be used. This patch allows DMA information obtained though Device
> Tree to be used as well.
>
> Cc: Russell King 
> Cc: Chris Ball 
> Cc: linux-...@vger.kernel.org
> Signed-off-by: Lee Jones 
(...)

I tried to test this patch, but:
  CC  drivers/mmc/host/mmci.o
/drivers/mmc/host/mmci.c: In function 'mmci_dma_setup':
/drivers/mmc/host/mmci.c:307:51: error: 'dev' undeclared (first use in
this function)
/drivers/mmc/host/mmci.c:307:51: note: each undeclared identifier is
reported only once for each function it appears in
make[5]: *** [drivers/mmc/host/mmci.o] Error 1
make[4]: *** [drivers/mmc/host] Error 2
make[3]: *** [drivers/mmc] Error 2

Due to:

> @@ -304,10 +304,8 @@ static void mmci_dma_setup(struct mmci_host *host)
> const char *rxname, *txname;
> dma_cap_mask_t mask;
>
> -   if (!plat || !plat->dma_filter) {
> -   dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
> -   return;
> -   }
> +   host->dma_rx_channel = dma_request_slave_channel(dev, "rx");
> +   host->dma_tx_channel = dma_request_slave_channel(dev, "tx");

There is no "dev" here.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-30 Thread Linus Walleij
On Wed, Apr 24, 2013 at 12:58 PM, Lee Jones lee.jo...@linaro.org wrote:

 Currently, if DMA information isn't passed from platform data, then DMA
 will not be used. This patch allows DMA information obtained though Device
 Tree to be used as well.

 Cc: Russell King li...@arm.linux.org.uk
 Cc: Chris Ball c...@laptop.org
 Cc: linux-...@vger.kernel.org
 Signed-off-by: Lee Jones lee.jo...@linaro.org
(...)

I tried to test this patch, but:
  CC  drivers/mmc/host/mmci.o
/drivers/mmc/host/mmci.c: In function 'mmci_dma_setup':
/drivers/mmc/host/mmci.c:307:51: error: 'dev' undeclared (first use in
this function)
/drivers/mmc/host/mmci.c:307:51: note: each undeclared identifier is
reported only once for each function it appears in
make[5]: *** [drivers/mmc/host/mmci.o] Error 1
make[4]: *** [drivers/mmc/host] Error 2
make[3]: *** [drivers/mmc] Error 2

Due to:

 @@ -304,10 +304,8 @@ static void mmci_dma_setup(struct mmci_host *host)
 const char *rxname, *txname;
 dma_cap_mask_t mask;

 -   if (!plat || !plat-dma_filter) {
 -   dev_info(mmc_dev(host-mmc), no DMA platform data\n);
 -   return;
 -   }
 +   host-dma_rx_channel = dma_request_slave_channel(dev, rx);
 +   host-dma_tx_channel = dma_request_slave_channel(dev, tx);

There is no dev here.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-30 Thread Lee Jones
On Tue, 30 Apr 2013, Linus Walleij wrote:

 On Wed, Apr 24, 2013 at 12:58 PM, Lee Jones lee.jo...@linaro.org wrote:
 
  Currently, if DMA information isn't passed from platform data, then DMA
  will not be used. This patch allows DMA information obtained though Device
  Tree to be used as well.
 
  Cc: Russell King li...@arm.linux.org.uk
  Cc: Chris Ball c...@laptop.org
  Cc: linux-...@vger.kernel.org
  Signed-off-by: Lee Jones lee.jo...@linaro.org
 (...)
 
 I tried to test this patch, but:
   CC  drivers/mmc/host/mmci.o
 /drivers/mmc/host/mmci.c: In function 'mmci_dma_setup':
 /drivers/mmc/host/mmci.c:307:51: error: 'dev' undeclared (first use in
 this function)
 /drivers/mmc/host/mmci.c:307:51: note: each undeclared identifier is
 reported only once for each function it appears in
 make[5]: *** [drivers/mmc/host/mmci.o] Error 1
 make[4]: *** [drivers/mmc/host] Error 2
 make[3]: *** [drivers/mmc] Error 2
 
 Due to:
 
  @@ -304,10 +304,8 @@ static void mmci_dma_setup(struct mmci_host *host)
  const char *rxname, *txname;
  dma_cap_mask_t mask;
 
  -   if (!plat || !plat-dma_filter) {
  -   dev_info(mmc_dev(host-mmc), no DMA platform data\n);
  -   return;
  -   }
  +   host-dma_rx_channel = dma_request_slave_channel(dev, rx);
  +   host-dma_tx_channel = dma_request_slave_channel(dev, tx);
 
 There is no dev here.

You've missed v2 again dude.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Russell King - ARM Linux
On Thu, Apr 18, 2013 at 11:25:44AM +0200, Arnd Bergmann wrote:
> +static void mmci_dma_setup(struct device *dev, struct mmci_host *host)
> +{
> + const char *rxname, *txname;
> +
> + host->dma_rx_channel = dma_request_slave_channel(dev, "rx");
> + host->dma_tx_channel = dma_request_slave_channel(dev, "tx");
> +
> + if (!host->dma_rx_channel && !host->dma_tx_channel) {
> + if (host->plat && host->plat->dma_filter)
> + mmci_dma_plat_setup(host);
> + else
> + dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
> + return;

You may like to fix the sillies in this patch... but yes, the above
would be better.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Arnd Bergmann
On Thursday 18 April 2013, Russell King - ARM Linux wrote:
> On Thu, Apr 18, 2013 at 09:02:38AM +0100, Lee Jones wrote:
> > @@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
> >* attempt to use it bidirectionally, however if it is
> >* is specified but cannot be located, DMA will be disabled.
> >*/
> > - if (plat->dma_rx_param) {
> > - host->dma_rx_channel = dma_request_channel(mask,
> > -plat->dma_filter,
> > -
> > plat->dma_rx_param);
> > + if (plat->dma_rx_param || np) {
> > + host->dma_rx_channel = dma_request_slave_channel_compat(mask,
> > + 
> > plat->dma_filter,
> > + 
> > plat->dma_rx_param,
> > + >dev, 
> > "rx");
> >   /* E.g if no DMA hardware is present */
> >   if (!host->dma_rx_channel)
> >   dev_err(mmc_dev(host->mmc), "no RX DMA channel\n");
> 
> I don't think this is right - I think Arnd has been leading you up the
> garden path saying that this can be simplified.  Why?
> 
> If you look at what this code does, the DMA channels are optional.  If
> they're not provided, then you don't get an error or a warning printk from
> the code.  However, after your conversion, if you use DT and avoid giving
> the DMA information (which you have to avoid on the majority of ARM
> platforms) then "np" will be non-NULL, and
> dma_request_slave_channel_compat() will return NULL, causing the error
> and/or warning to be printed.

Right, so I guess we should print the warning only if plat->dma_filter
is non-NULL, or we don't use dma_request_slave_channel_compat, which
does not actually simplify the code here.

Arnd

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 375c109..c97bc92 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -298,20 +298,11 @@ static void mmci_init_sg(struct mmci_host *host, struct 
mmc_data *data)
  * no custom DMA interfaces are supported.
  */
 #ifdef CONFIG_DMA_ENGINE
-static void mmci_dma_setup(struct mmci_host *host)
+static int mmci_dma_plat_setup(struct mmci_host *host)
 {
struct mmci_platform_data *plat = host->plat;
-   const char *rxname, *txname;
dma_cap_mask_t mask;
 
-   if (!plat || !plat->dma_filter) {
-   dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
-   return;
-   }
-
-   /* initialize pre request cookie */
-   host->next_data.cookie = 1;
-
/* Try to acquire a generic DMA engine slave channel */
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
@@ -339,6 +330,25 @@ static void mmci_dma_setup(struct mmci_host *host)
} else {
host->dma_tx_channel = host->dma_rx_channel;
}
+}
+
+static void mmci_dma_setup(struct device *dev, struct mmci_host *host)
+{
+   const char *rxname, *txname;
+
+   host->dma_rx_channel = dma_request_slave_channel(dev, "rx");
+   host->dma_tx_channel = dma_request_slave_channel(dev, "tx");
+
+   if (!host->dma_rx_channel && !host->dma_tx_channel) {
+   if (host->plat && host->plat->dma_filter)
+   mmci_dma_plat_setup(host);
+   else
+   dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
+   return;
+   }
+
+   /* initialize pre request cookie */
+   host->next_data.cookie = 1;
 
if (host->dma_rx_channel)
rxname = dma_chan_name(host->dma_rx_channel);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Ulf Hansson
On 18 April 2013 10:02, Lee Jones  wrote:
>> I think you can further simplify this, given that in the DT case we always
>> allocate a zeroed mmci_platform_data for host->plat, so !plat cannot happen
>> when we get here.
>
> Okay, third time lucky. :)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 372e921..3260ab4 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -298,14 +298,16 @@ static void mmci_init_sg(struct mmci_host *host, struct 
> mmc_data *data)
>   * no custom DMA interfaces are supported.
>   */
>  #ifdef CONFIG_DMA_ENGINE
> -static void mmci_dma_setup(struct mmci_host *host)
> +static void mmci_dma_setup(struct amba_device *dev,
> +  struct mmci_host *host)

Hi Lee,

You don't need to pass the amba_device, this can be fetched from the
mmci_host. Check how other functions converts the mmci host it in this
driver.

Kind regards
Ulf Hansson

>  {
> +   struct device_node *np = dev->dev.of_node;
> struct mmci_platform_data *plat = host->plat;
> const char *rxname, *txname;
> dma_cap_mask_t mask;
>
> -   if (!plat || !plat->dma_filter) {
> -   dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
> +   if (!(plat->dma_filter || np)) {
> +   dev_info(mmc_dev(host->mmc), "no DMA platform data or DT\n");
> return;
> }
>
> @@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
>  * attempt to use it bidirectionally, however if it is
>  * is specified but cannot be located, DMA will be disabled.
>  */
> -   if (plat->dma_rx_param) {
> -   host->dma_rx_channel = dma_request_channel(mask,
> -  plat->dma_filter,
> -  
> plat->dma_rx_param);
> +   if (plat->dma_rx_param || np) {
> +   host->dma_rx_channel = dma_request_slave_channel_compat(mask,
> +   
> plat->dma_filter,
> +   
> plat->dma_rx_param,
> +   >dev, 
> "rx");
> /* E.g if no DMA hardware is present */
> if (!host->dma_rx_channel)
> dev_err(mmc_dev(host->mmc), "no RX DMA channel\n");
> }
>
> -   if (plat->dma_tx_param) {
> -   host->dma_tx_channel = dma_request_channel(mask,
> -  plat->dma_filter,
> -  
> plat->dma_tx_param);
> +   if (plat->dma_tx_param || np) {
> +   host->dma_tx_channel = dma_request_slave_channel_compat(mask,
> +   
> plat->dma_filter,
> +   
> plat->dma_tx_param,
> +   >dev, 
> "tx");
> if (!host->dma_tx_channel)
> dev_warn(mmc_dev(host->mmc), "no TX DMA channel\n");
> } else {
> @@ -1538,7 +1542,7 @@ static int mmci_probe(struct amba_device *dev,
>  amba_rev(dev), (unsigned long long)dev->res.start,
>  dev->irq[0], dev->irq[1]);
>
> -   mmci_dma_setup(host);
> +   mmci_dma_setup(dev, host);
>
> pm_runtime_set_autosuspend_delay(>dev, 50);
> pm_runtime_use_autosuspend(>dev);
>
> --
> Lee Jones
> Linaro ST-Ericsson Landing Team Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Russell King - ARM Linux
On Thu, Apr 18, 2013 at 09:02:38AM +0100, Lee Jones wrote:
> @@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
>* attempt to use it bidirectionally, however if it is
>* is specified but cannot be located, DMA will be disabled.
>*/
> - if (plat->dma_rx_param) {
> - host->dma_rx_channel = dma_request_channel(mask,
> -plat->dma_filter,
> -plat->dma_rx_param);
> + if (plat->dma_rx_param || np) {
> + host->dma_rx_channel = dma_request_slave_channel_compat(mask,
> + 
> plat->dma_filter,
> + 
> plat->dma_rx_param,
> + >dev, 
> "rx");
>   /* E.g if no DMA hardware is present */
>   if (!host->dma_rx_channel)
>   dev_err(mmc_dev(host->mmc), "no RX DMA channel\n");

I don't think this is right - I think Arnd has been leading you up the
garden path saying that this can be simplified.  Why?

If you look at what this code does, the DMA channels are optional.  If
they're not provided, then you don't get an error or a warning printk from
the code.  However, after your conversion, if you use DT and avoid giving
the DMA information (which you have to avoid on the majority of ARM
platforms) then "np" will be non-NULL, and
dma_request_slave_channel_compat() will return NULL, causing the error
and/or warning to be printed.

So, we really need to know whether the DMA channel information has been
provided in DT in the upper level "if" statement, and _not_ use
dma_request_slave_channel_compat().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Lee Jones
> I think you can further simplify this, given that in the DT case we always
> allocate a zeroed mmci_platform_data for host->plat, so !plat cannot happen
> when we get here.

Okay, third time lucky. :)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 372e921..3260ab4 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -298,14 +298,16 @@ static void mmci_init_sg(struct mmci_host *host, struct 
mmc_data *data)
  * no custom DMA interfaces are supported.
  */
 #ifdef CONFIG_DMA_ENGINE
-static void mmci_dma_setup(struct mmci_host *host)
+static void mmci_dma_setup(struct amba_device *dev,
+  struct mmci_host *host)
 {
+   struct device_node *np = dev->dev.of_node;
struct mmci_platform_data *plat = host->plat;
const char *rxname, *txname;
dma_cap_mask_t mask;
 
-   if (!plat || !plat->dma_filter) {
-   dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
+   if (!(plat->dma_filter || np)) {
+   dev_info(mmc_dev(host->mmc), "no DMA platform data or DT\n");
return;
}
 
@@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
 * attempt to use it bidirectionally, however if it is
 * is specified but cannot be located, DMA will be disabled.
 */
-   if (plat->dma_rx_param) {
-   host->dma_rx_channel = dma_request_channel(mask,
-  plat->dma_filter,
-  plat->dma_rx_param);
+   if (plat->dma_rx_param || np) {
+   host->dma_rx_channel = dma_request_slave_channel_compat(mask,
+   
plat->dma_filter,
+   
plat->dma_rx_param,
+   >dev, 
"rx");
/* E.g if no DMA hardware is present */
if (!host->dma_rx_channel)
dev_err(mmc_dev(host->mmc), "no RX DMA channel\n");
}
 
-   if (plat->dma_tx_param) {
-   host->dma_tx_channel = dma_request_channel(mask,
-  plat->dma_filter,
-  plat->dma_tx_param);
+   if (plat->dma_tx_param || np) {
+   host->dma_tx_channel = dma_request_slave_channel_compat(mask,
+   
plat->dma_filter,
+   
plat->dma_tx_param,
+   >dev, 
"tx");
if (!host->dma_tx_channel)
dev_warn(mmc_dev(host->mmc), "no TX DMA channel\n");
} else {
@@ -1538,7 +1542,7 @@ static int mmci_probe(struct amba_device *dev,
 amba_rev(dev), (unsigned long long)dev->res.start,
 dev->irq[0], dev->irq[1]);
 
-   mmci_dma_setup(host);
+   mmci_dma_setup(dev, host);
 
pm_runtime_set_autosuspend_delay(>dev, 50);
pm_runtime_use_autosuspend(>dev);

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Lee Jones
 I think you can further simplify this, given that in the DT case we always
 allocate a zeroed mmci_platform_data for host-plat, so !plat cannot happen
 when we get here.

Okay, third time lucky. :)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 372e921..3260ab4 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -298,14 +298,16 @@ static void mmci_init_sg(struct mmci_host *host, struct 
mmc_data *data)
  * no custom DMA interfaces are supported.
  */
 #ifdef CONFIG_DMA_ENGINE
-static void mmci_dma_setup(struct mmci_host *host)
+static void mmci_dma_setup(struct amba_device *dev,
+  struct mmci_host *host)
 {
+   struct device_node *np = dev-dev.of_node;
struct mmci_platform_data *plat = host-plat;
const char *rxname, *txname;
dma_cap_mask_t mask;
 
-   if (!plat || !plat-dma_filter) {
-   dev_info(mmc_dev(host-mmc), no DMA platform data\n);
+   if (!(plat-dma_filter || np)) {
+   dev_info(mmc_dev(host-mmc), no DMA platform data or DT\n);
return;
}
 
@@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
 * attempt to use it bidirectionally, however if it is
 * is specified but cannot be located, DMA will be disabled.
 */
-   if (plat-dma_rx_param) {
-   host-dma_rx_channel = dma_request_channel(mask,
-  plat-dma_filter,
-  plat-dma_rx_param);
+   if (plat-dma_rx_param || np) {
+   host-dma_rx_channel = dma_request_slave_channel_compat(mask,
+   
plat-dma_filter,
+   
plat-dma_rx_param,
+   dev-dev, 
rx);
/* E.g if no DMA hardware is present */
if (!host-dma_rx_channel)
dev_err(mmc_dev(host-mmc), no RX DMA channel\n);
}
 
-   if (plat-dma_tx_param) {
-   host-dma_tx_channel = dma_request_channel(mask,
-  plat-dma_filter,
-  plat-dma_tx_param);
+   if (plat-dma_tx_param || np) {
+   host-dma_tx_channel = dma_request_slave_channel_compat(mask,
+   
plat-dma_filter,
+   
plat-dma_tx_param,
+   dev-dev, 
tx);
if (!host-dma_tx_channel)
dev_warn(mmc_dev(host-mmc), no TX DMA channel\n);
} else {
@@ -1538,7 +1542,7 @@ static int mmci_probe(struct amba_device *dev,
 amba_rev(dev), (unsigned long long)dev-res.start,
 dev-irq[0], dev-irq[1]);
 
-   mmci_dma_setup(host);
+   mmci_dma_setup(dev, host);
 
pm_runtime_set_autosuspend_delay(dev-dev, 50);
pm_runtime_use_autosuspend(dev-dev);

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Russell King - ARM Linux
On Thu, Apr 18, 2013 at 09:02:38AM +0100, Lee Jones wrote:
 @@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
* attempt to use it bidirectionally, however if it is
* is specified but cannot be located, DMA will be disabled.
*/
 - if (plat-dma_rx_param) {
 - host-dma_rx_channel = dma_request_channel(mask,
 -plat-dma_filter,
 -plat-dma_rx_param);
 + if (plat-dma_rx_param || np) {
 + host-dma_rx_channel = dma_request_slave_channel_compat(mask,
 + 
 plat-dma_filter,
 + 
 plat-dma_rx_param,
 + dev-dev, 
 rx);
   /* E.g if no DMA hardware is present */
   if (!host-dma_rx_channel)
   dev_err(mmc_dev(host-mmc), no RX DMA channel\n);

I don't think this is right - I think Arnd has been leading you up the
garden path saying that this can be simplified.  Why?

If you look at what this code does, the DMA channels are optional.  If
they're not provided, then you don't get an error or a warning printk from
the code.  However, after your conversion, if you use DT and avoid giving
the DMA information (which you have to avoid on the majority of ARM
platforms) then np will be non-NULL, and
dma_request_slave_channel_compat() will return NULL, causing the error
and/or warning to be printed.

So, we really need to know whether the DMA channel information has been
provided in DT in the upper level if statement, and _not_ use
dma_request_slave_channel_compat().
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Ulf Hansson
On 18 April 2013 10:02, Lee Jones lee.jo...@linaro.org wrote:
 I think you can further simplify this, given that in the DT case we always
 allocate a zeroed mmci_platform_data for host-plat, so !plat cannot happen
 when we get here.

 Okay, third time lucky. :)

 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
 index 372e921..3260ab4 100644
 --- a/drivers/mmc/host/mmci.c
 +++ b/drivers/mmc/host/mmci.c
 @@ -298,14 +298,16 @@ static void mmci_init_sg(struct mmci_host *host, struct 
 mmc_data *data)
   * no custom DMA interfaces are supported.
   */
  #ifdef CONFIG_DMA_ENGINE
 -static void mmci_dma_setup(struct mmci_host *host)
 +static void mmci_dma_setup(struct amba_device *dev,
 +  struct mmci_host *host)

Hi Lee,

You don't need to pass the amba_device, this can be fetched from the
mmci_host. Check how other functions converts the mmci host it in this
driver.

Kind regards
Ulf Hansson

  {
 +   struct device_node *np = dev-dev.of_node;
 struct mmci_platform_data *plat = host-plat;
 const char *rxname, *txname;
 dma_cap_mask_t mask;

 -   if (!plat || !plat-dma_filter) {
 -   dev_info(mmc_dev(host-mmc), no DMA platform data\n);
 +   if (!(plat-dma_filter || np)) {
 +   dev_info(mmc_dev(host-mmc), no DMA platform data or DT\n);
 return;
 }

 @@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
  * attempt to use it bidirectionally, however if it is
  * is specified but cannot be located, DMA will be disabled.
  */
 -   if (plat-dma_rx_param) {
 -   host-dma_rx_channel = dma_request_channel(mask,
 -  plat-dma_filter,
 -  
 plat-dma_rx_param);
 +   if (plat-dma_rx_param || np) {
 +   host-dma_rx_channel = dma_request_slave_channel_compat(mask,
 +   
 plat-dma_filter,
 +   
 plat-dma_rx_param,
 +   dev-dev, 
 rx);
 /* E.g if no DMA hardware is present */
 if (!host-dma_rx_channel)
 dev_err(mmc_dev(host-mmc), no RX DMA channel\n);
 }

 -   if (plat-dma_tx_param) {
 -   host-dma_tx_channel = dma_request_channel(mask,
 -  plat-dma_filter,
 -  
 plat-dma_tx_param);
 +   if (plat-dma_tx_param || np) {
 +   host-dma_tx_channel = dma_request_slave_channel_compat(mask,
 +   
 plat-dma_filter,
 +   
 plat-dma_tx_param,
 +   dev-dev, 
 tx);
 if (!host-dma_tx_channel)
 dev_warn(mmc_dev(host-mmc), no TX DMA channel\n);
 } else {
 @@ -1538,7 +1542,7 @@ static int mmci_probe(struct amba_device *dev,
  amba_rev(dev), (unsigned long long)dev-res.start,
  dev-irq[0], dev-irq[1]);

 -   mmci_dma_setup(host);
 +   mmci_dma_setup(dev, host);

 pm_runtime_set_autosuspend_delay(dev-dev, 50);
 pm_runtime_use_autosuspend(dev-dev);

 --
 Lee Jones
 Linaro ST-Ericsson Landing Team Lead
 Linaro.org │ Open source software for ARM SoCs
 Follow Linaro: Facebook | Twitter | Blog
 --
 To unsubscribe from this list: send the line unsubscribe linux-mmc in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Arnd Bergmann
On Thursday 18 April 2013, Russell King - ARM Linux wrote:
 On Thu, Apr 18, 2013 at 09:02:38AM +0100, Lee Jones wrote:
  @@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
 * attempt to use it bidirectionally, however if it is
 * is specified but cannot be located, DMA will be disabled.
 */
  - if (plat-dma_rx_param) {
  - host-dma_rx_channel = dma_request_channel(mask,
  -plat-dma_filter,
  -
  plat-dma_rx_param);
  + if (plat-dma_rx_param || np) {
  + host-dma_rx_channel = dma_request_slave_channel_compat(mask,
  + 
  plat-dma_filter,
  + 
  plat-dma_rx_param,
  + dev-dev, 
  rx);
/* E.g if no DMA hardware is present */
if (!host-dma_rx_channel)
dev_err(mmc_dev(host-mmc), no RX DMA channel\n);
 
 I don't think this is right - I think Arnd has been leading you up the
 garden path saying that this can be simplified.  Why?
 
 If you look at what this code does, the DMA channels are optional.  If
 they're not provided, then you don't get an error or a warning printk from
 the code.  However, after your conversion, if you use DT and avoid giving
 the DMA information (which you have to avoid on the majority of ARM
 platforms) then np will be non-NULL, and
 dma_request_slave_channel_compat() will return NULL, causing the error
 and/or warning to be printed.

Right, so I guess we should print the warning only if plat-dma_filter
is non-NULL, or we don't use dma_request_slave_channel_compat, which
does not actually simplify the code here.

Arnd

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 375c109..c97bc92 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -298,20 +298,11 @@ static void mmci_init_sg(struct mmci_host *host, struct 
mmc_data *data)
  * no custom DMA interfaces are supported.
  */
 #ifdef CONFIG_DMA_ENGINE
-static void mmci_dma_setup(struct mmci_host *host)
+static int mmci_dma_plat_setup(struct mmci_host *host)
 {
struct mmci_platform_data *plat = host-plat;
-   const char *rxname, *txname;
dma_cap_mask_t mask;
 
-   if (!plat || !plat-dma_filter) {
-   dev_info(mmc_dev(host-mmc), no DMA platform data\n);
-   return;
-   }
-
-   /* initialize pre request cookie */
-   host-next_data.cookie = 1;
-
/* Try to acquire a generic DMA engine slave channel */
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
@@ -339,6 +330,25 @@ static void mmci_dma_setup(struct mmci_host *host)
} else {
host-dma_tx_channel = host-dma_rx_channel;
}
+}
+
+static void mmci_dma_setup(struct device *dev, struct mmci_host *host)
+{
+   const char *rxname, *txname;
+
+   host-dma_rx_channel = dma_request_slave_channel(dev, rx);
+   host-dma_tx_channel = dma_request_slave_channel(dev, tx);
+
+   if (!host-dma_rx_channel  !host-dma_tx_channel) {
+   if (host-plat  host-plat-dma_filter)
+   mmci_dma_plat_setup(host);
+   else
+   dev_info(mmc_dev(host-mmc), no DMA platform data\n);
+   return;
+   }
+
+   /* initialize pre request cookie */
+   host-next_data.cookie = 1;
 
if (host-dma_rx_channel)
rxname = dma_chan_name(host-dma_rx_channel);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-18 Thread Russell King - ARM Linux
On Thu, Apr 18, 2013 at 11:25:44AM +0200, Arnd Bergmann wrote:
 +static void mmci_dma_setup(struct device *dev, struct mmci_host *host)
 +{
 + const char *rxname, *txname;
 +
 + host-dma_rx_channel = dma_request_slave_channel(dev, rx);
 + host-dma_tx_channel = dma_request_slave_channel(dev, tx);
 +
 + if (!host-dma_rx_channel  !host-dma_tx_channel) {
 + if (host-plat  host-plat-dma_filter)
 + mmci_dma_plat_setup(host);
 + else
 + dev_info(mmc_dev(host-mmc), no DMA platform data\n);
 + return;

You may like to fix the sillies in this patch... but yes, the above
would be better.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-17 Thread Arnd Bergmann
On Wednesday 17 April 2013, Lee Jones wrote:
> > This looks unnecessarily complex.
> 
> That thought did cross my mind.
> 
> > Why not just do dma_request_slave_channel_compat() unconditionally here?
> 
> So how about something like this instead, as it keeps the current
> semantics, and only differs in the case of DT.

Yes, looks better.

> @@ -298,14 +298,16 @@ static void mmci_init_sg(struct mmci_host *host, struct 
> mmc_data *data)
>   * no custom DMA interfaces are supported.
>   */
>  #ifdef CONFIG_DMA_ENGINE
> -static void mmci_dma_setup(struct mmci_host *host)
> +static void mmci_dma_setup(struct amba_device *dev,
> +struct mmci_host *host)
>  {
> + struct device_node *np = dev->dev.of_node;
>   struct mmci_platform_data *plat = host->plat;
>   const char *rxname, *txname;
>   dma_cap_mask_t mask;
>  
> - if (!plat || !plat->dma_filter) {
> - dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
> + if (!(plat && plat->dma_filter) && !np) {
> + dev_info(mmc_dev(host->mmc), "no DMA platform data or DT\n");
>   return;
>   }

I think you can further simplify this, given that in the DT case we always
allocate a zeroed mmci_platform_data for host->plat, so !plat cannot happen
when we get here.

> @@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
>* attempt to use it bidirectionally, however if it is
>* is specified but cannot be located, DMA will be disabled.
>*/
> - if (plat->dma_rx_param) {
> - host->dma_rx_channel = dma_request_channel(mask,
> -plat->dma_filter,
> -plat->dma_rx_param);
> + if ((plat && plat->dma_rx_param) || np) {
> + host->dma_rx_channel = dma_request_slave_channel_compat(mask,
> + (plat) ? plat->dma_filter : NULL,
> + (plat) ? plat->dma_rx_param : NULL,
> + >dev, "rx");
>   /* E.g if no DMA hardware is present */
>   if (!host->dma_rx_channel)
>   dev_err(mmc_dev(host->mmc), "no RX DMA channel\n");

And based on that, you can unconditionally pass plat->dma_filter and
plat->dma_rx_param here. In case of DT, they will be NULL, and they
will not be used either.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-17 Thread Lee Jones
> This looks unnecessarily complex.

That thought did cross my mind.

> Why not just do dma_request_slave_channel_compat() unconditionally here?

So how about something like this instead, as it keeps the current
semantics, and only differs in the case of DT.

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 372e921..1fd212a 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -298,14 +298,16 @@ static void mmci_init_sg(struct mmci_host *host, struct 
mmc_data *data)
  * no custom DMA interfaces are supported.
  */
 #ifdef CONFIG_DMA_ENGINE
-static void mmci_dma_setup(struct mmci_host *host)
+static void mmci_dma_setup(struct amba_device *dev,
+  struct mmci_host *host)
 {
+   struct device_node *np = dev->dev.of_node;
struct mmci_platform_data *plat = host->plat;
const char *rxname, *txname;
dma_cap_mask_t mask;
 
-   if (!plat || !plat->dma_filter) {
-   dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
+   if (!(plat && plat->dma_filter) && !np) {
+   dev_info(mmc_dev(host->mmc), "no DMA platform data or DT\n");
return;
}
 
@@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
 * attempt to use it bidirectionally, however if it is
 * is specified but cannot be located, DMA will be disabled.
 */
-   if (plat->dma_rx_param) {
-   host->dma_rx_channel = dma_request_channel(mask,
-  plat->dma_filter,
-  plat->dma_rx_param);
+   if ((plat && plat->dma_rx_param) || np) {
+   host->dma_rx_channel = dma_request_slave_channel_compat(mask,
+   (plat) ? plat->dma_filter : NULL,
+   (plat) ? plat->dma_rx_param : NULL,
+   >dev, "rx");
/* E.g if no DMA hardware is present */
if (!host->dma_rx_channel)
dev_err(mmc_dev(host->mmc), "no RX DMA channel\n");
}
 
-   if (plat->dma_tx_param) {
-   host->dma_tx_channel = dma_request_channel(mask,
-  plat->dma_filter,
-  plat->dma_tx_param);
+   if ((plat && plat->dma_tx_param) || np) {
+   host->dma_tx_channel = dma_request_slave_channel_compat(mask,
+   (plat) ? plat->dma_filter : NULL,
+   (plat) ? plat->dma_tx_param : NULL,
+   >dev, "tx");
if (!host->dma_tx_channel)
dev_warn(mmc_dev(host->mmc), "no TX DMA channel\n");
} else {
@@ -1538,7 +1542,7 @@ static int mmci_probe(struct amba_device *dev,
 amba_rev(dev), (unsigned long long)dev->res.start,
 dev->irq[0], dev->irq[1]);
 
-   mmci_dma_setup(host);
+   mmci_dma_setup(dev, host);
 
pm_runtime_set_autosuspend_delay(>dev, 50);
pm_runtime_use_autosuspend(>dev);

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-17 Thread Arnd Bergmann
On Wednesday 17 April 2013, Lee Jones wrote:

>  #ifdef CONFIG_DMA_ENGINE
> -static void mmci_dma_setup(struct mmci_host *host)
> +static void mmci_dma_setup(struct amba_device *dev,
> +struct mmci_host *host)
>  {
> + struct device_node *np = dev->dev.of_node;
>   struct mmci_platform_data *plat = host->plat;
>   const char *rxname, *txname;
>   dma_cap_mask_t mask;
> + const char *chan_name;
> + int count, i;
> + bool do_tx = false, do_rx = false;
>  
>   if (!plat || !plat->dma_filter) {
> - dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
> - return;
> + if (np) {
> + count = of_property_count_strings(np, "dma-names");
> + for (i = 0; i < count; i++) {
> + of_property_read_string_index(np, "dma-names",
> +   i, _name);
> + if (strcmp(chan_name, "tx"))
> + do_tx = true;
> + else if (strcmp(chan_name, "rx"))
> + do_rx = true;
> + }
> + } else {
> + dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
> + return;
> + }
>   }

This looks unnecessarily complex.

>   /* initialize pre request cookie */
> @@ -321,19 +338,21 @@ static void mmci_dma_setup(struct mmci_host *host)
>* attempt to use it bidirectionally, however if it is
>* is specified but cannot be located, DMA will be disabled.
>*/
> - if (plat->dma_rx_param) {
> - host->dma_rx_channel = dma_request_channel(mask,
> -plat->dma_filter,
> -plat->dma_rx_param);
> + if (plat->dma_rx_param || do_rx) {
> + host->dma_rx_channel = dma_request_slave_channel_compat(mask,
> + (plat) ? plat->dma_filter : NULL,
> + (plat) ? plat->dma_rx_param : NULL,
> + >dev, "rx");
>   /* E.g if no DMA hardware is present */
>   if (!host->dma_rx_channel)
>   dev_err(mmc_dev(host->mmc), "no RX DMA channel\n");
>   }

Why not just do dma_request_slave_channel_compat() unconditionally here?
It's not an error for MMCI if that fails. If you want to keep the warning
in the case dma_rx_channel is provided by not working, you can do it like

host->dma_rx_channel = dma_request_slave_channel(dev, "rx");
if (!host->dma_rx_channel && plat->dma_rx_param) {
host->dma_rx_channel = dma_request_channel(mask,
   plat->dma_filter,
   plat->dma_rx_param);
...
}

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-17 Thread Arnd Bergmann
On Wednesday 17 April 2013, Lee Jones wrote:

  #ifdef CONFIG_DMA_ENGINE
 -static void mmci_dma_setup(struct mmci_host *host)
 +static void mmci_dma_setup(struct amba_device *dev,
 +struct mmci_host *host)
  {
 + struct device_node *np = dev-dev.of_node;
   struct mmci_platform_data *plat = host-plat;
   const char *rxname, *txname;
   dma_cap_mask_t mask;
 + const char *chan_name;
 + int count, i;
 + bool do_tx = false, do_rx = false;
  
   if (!plat || !plat-dma_filter) {
 - dev_info(mmc_dev(host-mmc), no DMA platform data\n);
 - return;
 + if (np) {
 + count = of_property_count_strings(np, dma-names);
 + for (i = 0; i  count; i++) {
 + of_property_read_string_index(np, dma-names,
 +   i, chan_name);
 + if (strcmp(chan_name, tx))
 + do_tx = true;
 + else if (strcmp(chan_name, rx))
 + do_rx = true;
 + }
 + } else {
 + dev_info(mmc_dev(host-mmc), no DMA platform data\n);
 + return;
 + }
   }

This looks unnecessarily complex.

   /* initialize pre request cookie */
 @@ -321,19 +338,21 @@ static void mmci_dma_setup(struct mmci_host *host)
* attempt to use it bidirectionally, however if it is
* is specified but cannot be located, DMA will be disabled.
*/
 - if (plat-dma_rx_param) {
 - host-dma_rx_channel = dma_request_channel(mask,
 -plat-dma_filter,
 -plat-dma_rx_param);
 + if (plat-dma_rx_param || do_rx) {
 + host-dma_rx_channel = dma_request_slave_channel_compat(mask,
 + (plat) ? plat-dma_filter : NULL,
 + (plat) ? plat-dma_rx_param : NULL,
 + dev-dev, rx);
   /* E.g if no DMA hardware is present */
   if (!host-dma_rx_channel)
   dev_err(mmc_dev(host-mmc), no RX DMA channel\n);
   }

Why not just do dma_request_slave_channel_compat() unconditionally here?
It's not an error for MMCI if that fails. If you want to keep the warning
in the case dma_rx_channel is provided by not working, you can do it like

host-dma_rx_channel = dma_request_slave_channel(dev, rx);
if (!host-dma_rx_channel  plat-dma_rx_param) {
host-dma_rx_channel = dma_request_channel(mask,
   plat-dma_filter,
   plat-dma_rx_param);
...
}

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-17 Thread Lee Jones
 This looks unnecessarily complex.

That thought did cross my mind.

 Why not just do dma_request_slave_channel_compat() unconditionally here?

So how about something like this instead, as it keeps the current
semantics, and only differs in the case of DT.

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 372e921..1fd212a 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -298,14 +298,16 @@ static void mmci_init_sg(struct mmci_host *host, struct 
mmc_data *data)
  * no custom DMA interfaces are supported.
  */
 #ifdef CONFIG_DMA_ENGINE
-static void mmci_dma_setup(struct mmci_host *host)
+static void mmci_dma_setup(struct amba_device *dev,
+  struct mmci_host *host)
 {
+   struct device_node *np = dev-dev.of_node;
struct mmci_platform_data *plat = host-plat;
const char *rxname, *txname;
dma_cap_mask_t mask;
 
-   if (!plat || !plat-dma_filter) {
-   dev_info(mmc_dev(host-mmc), no DMA platform data\n);
+   if (!(plat  plat-dma_filter)  !np) {
+   dev_info(mmc_dev(host-mmc), no DMA platform data or DT\n);
return;
}
 
@@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
 * attempt to use it bidirectionally, however if it is
 * is specified but cannot be located, DMA will be disabled.
 */
-   if (plat-dma_rx_param) {
-   host-dma_rx_channel = dma_request_channel(mask,
-  plat-dma_filter,
-  plat-dma_rx_param);
+   if ((plat  plat-dma_rx_param) || np) {
+   host-dma_rx_channel = dma_request_slave_channel_compat(mask,
+   (plat) ? plat-dma_filter : NULL,
+   (plat) ? plat-dma_rx_param : NULL,
+   dev-dev, rx);
/* E.g if no DMA hardware is present */
if (!host-dma_rx_channel)
dev_err(mmc_dev(host-mmc), no RX DMA channel\n);
}
 
-   if (plat-dma_tx_param) {
-   host-dma_tx_channel = dma_request_channel(mask,
-  plat-dma_filter,
-  plat-dma_tx_param);
+   if ((plat  plat-dma_tx_param) || np) {
+   host-dma_tx_channel = dma_request_slave_channel_compat(mask,
+   (plat) ? plat-dma_filter : NULL,
+   (plat) ? plat-dma_tx_param : NULL,
+   dev-dev, tx);
if (!host-dma_tx_channel)
dev_warn(mmc_dev(host-mmc), no TX DMA channel\n);
} else {
@@ -1538,7 +1542,7 @@ static int mmci_probe(struct amba_device *dev,
 amba_rev(dev), (unsigned long long)dev-res.start,
 dev-irq[0], dev-irq[1]);
 
-   mmci_dma_setup(host);
+   mmci_dma_setup(dev, host);
 
pm_runtime_set_autosuspend_delay(dev-dev, 50);
pm_runtime_use_autosuspend(dev-dev);

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT

2013-04-17 Thread Arnd Bergmann
On Wednesday 17 April 2013, Lee Jones wrote:
  This looks unnecessarily complex.
 
 That thought did cross my mind.
 
  Why not just do dma_request_slave_channel_compat() unconditionally here?
 
 So how about something like this instead, as it keeps the current
 semantics, and only differs in the case of DT.

Yes, looks better.

 @@ -298,14 +298,16 @@ static void mmci_init_sg(struct mmci_host *host, struct 
 mmc_data *data)
   * no custom DMA interfaces are supported.
   */
  #ifdef CONFIG_DMA_ENGINE
 -static void mmci_dma_setup(struct mmci_host *host)
 +static void mmci_dma_setup(struct amba_device *dev,
 +struct mmci_host *host)
  {
 + struct device_node *np = dev-dev.of_node;
   struct mmci_platform_data *plat = host-plat;
   const char *rxname, *txname;
   dma_cap_mask_t mask;
  
 - if (!plat || !plat-dma_filter) {
 - dev_info(mmc_dev(host-mmc), no DMA platform data\n);
 + if (!(plat  plat-dma_filter)  !np) {
 + dev_info(mmc_dev(host-mmc), no DMA platform data or DT\n);
   return;
   }

I think you can further simplify this, given that in the DT case we always
allocate a zeroed mmci_platform_data for host-plat, so !plat cannot happen
when we get here.

 @@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host)
* attempt to use it bidirectionally, however if it is
* is specified but cannot be located, DMA will be disabled.
*/
 - if (plat-dma_rx_param) {
 - host-dma_rx_channel = dma_request_channel(mask,
 -plat-dma_filter,
 -plat-dma_rx_param);
 + if ((plat  plat-dma_rx_param) || np) {
 + host-dma_rx_channel = dma_request_slave_channel_compat(mask,
 + (plat) ? plat-dma_filter : NULL,
 + (plat) ? plat-dma_rx_param : NULL,
 + dev-dev, rx);
   /* E.g if no DMA hardware is present */
   if (!host-dma_rx_channel)
   dev_err(mmc_dev(host-mmc), no RX DMA channel\n);

And based on that, you can unconditionally pass plat-dma_filter and
plat-dma_rx_param here. In case of DT, they will be NULL, and they
will not be used either.

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/