* [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <1359395857-1235-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> @ 2013-01-28 17:57 ` Arnd Bergmann [not found] ` <1359395857-1235-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-28 17:57 ` [PATCH 3/5] serial: pl011: " Arnd Bergmann 2013-01-28 21:58 ` [PATCH v2 0/5] dmaengine: convert dw_dmac/spear13xx to generic binding Arnd Bergmann 2 siblings, 1 reply; 20+ messages in thread From: Arnd Bergmann @ 2013-01-28 17:57 UTC (permalink / raw) To: linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Vinod Koul, Arnd Bergmann, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko With the new OF DMA binding, it is possible to completely avoid the need for platform_data for configuring a DMA channel. In cases where the platform has already been converted, calling dma_request_slave_channel should get all the necessary information from the device tree. Like the patch that converts the dw_dma controller, this is completely untested and is looking for someone to try it out. Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> Cc: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Cc: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: Vinod Koul <vinod.koul-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org --- drivers/spi/spi-pl022.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index b0fe393..371cc66f 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -1139,6 +1139,35 @@ err_no_rxchan: return -ENODEV; } +static int pl022_dma_autoprobe(struct pl022 *pl022) +{ + struct device *dev = &pl022->adev->dev; + + /* automatically configure DMA channels from platform, normally using DT */ + pl022->dma_rx_channel = dma_request_slave_channel(dev, "rx"); + if (!pl022->dma_rx_channel) + goto err_no_rxchan; + + pl022->dma_tx_channel = dma_request_slave_channel(dev, "tx"); + if (!pl022->dma_tx_channel) + goto err_no_txchan; + + pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!pl022->dummypage) + goto err_no_dummypage; + + return 0; + +err_no_dummypage: + dma_release_channel(pl022->dma_tx_channel); + pl022->dma_tx_channel = NULL; +err_no_txchan: + dma_release_channel(pl022->dma_rx_channel); + pl022->dma_rx_channel = NULL; +err_no_rxchan: + return -ENODEV; +} + static void terminate_dma(struct pl022 *pl022) { struct dma_chan *rxchan = pl022->dma_rx_channel; @@ -1167,6 +1196,11 @@ static inline int configure_dma(struct pl022 *pl022) return -ENODEV; } +static inline int pl022_dma_autoprobe(struct pl022 *pl022) +{ + return 0; +} + static inline int pl022_dma_probe(struct pl022 *pl022) { return 0; @@ -2226,8 +2260,13 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) goto err_no_irq; } - /* Get DMA channels */ - if (platform_info->enable_dma) { + /* Get DMA channels, try autoconfiguration first */ + status = pl022_dma_autoprobe(pl022); + + /* If that failed, use channels from platform_info */ + if (status == 0) + platform_info->enable_dma = 1; + else if (platform_info->enable_dma) { status = pl022_dma_probe(pl022); if (status != 0) platform_info->enable_dma = 0; -- 1.8.0 ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d ^ permalink raw reply related [flat|nested] 20+ messages in thread
[parent not found: <1359395857-1235-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>]
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <1359395857-1235-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> @ 2013-02-05 14:22 ` Grant Likely 2013-02-07 18:27 ` Linus Walleij 1 sibling, 0 replies; 20+ messages in thread From: Grant Likely @ 2013-02-05 14:22 UTC (permalink / raw) To: Arnd Bergmann, linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Vinod Koul, Arnd Bergmann, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko On Mon, 28 Jan 2013 17:57:34 +0000, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote: > With the new OF DMA binding, it is possible to completely avoid the > need for platform_data for configuring a DMA channel. In cases where the > platform has already been converted, calling dma_request_slave_channel > should get all the necessary information from the device tree. > > Like the patch that converts the dw_dma controller, this is completely > untested and is looking for someone to try it out. > > Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> > Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> > Cc: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> > Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > Cc: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > Cc: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > Cc: Vinod Koul <vinod.koul-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org > Cc: linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > --- > drivers/spi/spi-pl022.c | 43 +++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 41 insertions(+), 2 deletions(-) Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> > > diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c > index b0fe393..371cc66f 100644 > --- a/drivers/spi/spi-pl022.c > +++ b/drivers/spi/spi-pl022.c > @@ -1139,6 +1139,35 @@ err_no_rxchan: > return -ENODEV; > } > > +static int pl022_dma_autoprobe(struct pl022 *pl022) > +{ > + struct device *dev = &pl022->adev->dev; > + > + /* automatically configure DMA channels from platform, normally using DT */ > + pl022->dma_rx_channel = dma_request_slave_channel(dev, "rx"); > + if (!pl022->dma_rx_channel) > + goto err_no_rxchan; > + > + pl022->dma_tx_channel = dma_request_slave_channel(dev, "tx"); > + if (!pl022->dma_tx_channel) > + goto err_no_txchan; > + > + pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); > + if (!pl022->dummypage) > + goto err_no_dummypage; > + > + return 0; > + > +err_no_dummypage: > + dma_release_channel(pl022->dma_tx_channel); > + pl022->dma_tx_channel = NULL; > +err_no_txchan: > + dma_release_channel(pl022->dma_rx_channel); > + pl022->dma_rx_channel = NULL; > +err_no_rxchan: > + return -ENODEV; > +} > + > static void terminate_dma(struct pl022 *pl022) > { > struct dma_chan *rxchan = pl022->dma_rx_channel; > @@ -1167,6 +1196,11 @@ static inline int configure_dma(struct pl022 *pl022) > return -ENODEV; > } > > +static inline int pl022_dma_autoprobe(struct pl022 *pl022) > +{ > + return 0; > +} > + > static inline int pl022_dma_probe(struct pl022 *pl022) > { > return 0; > @@ -2226,8 +2260,13 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) > goto err_no_irq; > } > > - /* Get DMA channels */ > - if (platform_info->enable_dma) { > + /* Get DMA channels, try autoconfiguration first */ > + status = pl022_dma_autoprobe(pl022); > + > + /* If that failed, use channels from platform_info */ > + if (status == 0) > + platform_info->enable_dma = 1; > + else if (platform_info->enable_dma) { > status = pl022_dma_probe(pl022); > if (status != 0) > platform_info->enable_dma = 0; > -- > 1.8.0 > -- Grant Likely, B.Sc, P.Eng. Secret Lab Technologies, Ltd. ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <1359395857-1235-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-02-05 14:22 ` Grant Likely @ 2013-02-07 18:27 ` Linus Walleij 1 sibling, 0 replies; 20+ messages in thread From: Linus Walleij @ 2013-02-07 18:27 UTC (permalink / raw) To: Arnd Bergmann Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA On Mon, Jan 28, 2013 at 6:57 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote: > With the new OF DMA binding, it is possible to completely avoid the > need for platform_data for configuring a DMA channel. In cases where the > platform has already been converted, calling dma_request_slave_channel > should get all the necessary information from the device tree. > > Like the patch that converts the dw_dma controller, this is completely > untested and is looking for someone to try it out. > > Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> This looks correct to me atleast: Acked-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Yours, Linus Walleij ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 3/5] serial: pl011: use generic DMA slave configuration if possible [not found] ` <1359395857-1235-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-28 17:57 ` [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible Arnd Bergmann @ 2013-01-28 17:57 ` Arnd Bergmann [not found] ` <1359395857-1235-4-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-28 21:58 ` [PATCH v2 0/5] dmaengine: convert dw_dmac/spear13xx to generic binding Arnd Bergmann 2 siblings, 1 reply; 20+ messages in thread From: Arnd Bergmann @ 2013-01-28 17:57 UTC (permalink / raw) To: linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Vinod Koul, Arnd Bergmann, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Greg Kroah-Hartman, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, Jiri Slaby, Linus Walleij With the new OF DMA binding, it is possible to completely avoid the need for platform_data for configuring a DMA channel. In cases where the platform has already been converted, calling dma_request_slave_channel should get all the necessary information from the device tree. Like the patch that converts the dw_dma controller, this is completely untested and is looking for someone to try it out. Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> Cc: Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org> Cc: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> Cc: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Cc: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: Vinod Koul <vinod.koul-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org --- drivers/tty/serial/amba-pl011.c | 62 ++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 3ea5408..c25b00e 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -245,7 +245,7 @@ static void pl011_sgbuf_free(struct dma_chan *chan, struct pl011_sgbuf *sg, } } -static void pl011_dma_probe_initcall(struct uart_amba_port *uap) +static void pl011_dma_probe_initcall(struct device *dev, struct uart_amba_port *uap) { /* DMA is the sole user of the platform data right now */ struct amba_pl011_data *plat = uap->port.dev->platform_data; @@ -259,20 +259,25 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) struct dma_chan *chan; dma_cap_mask_t mask; - /* We need platform data */ - if (!plat || !plat->dma_filter) { - dev_info(uap->port.dev, "no DMA platform data\n"); - return; - } + chan = dma_request_slave_channel(dev, "tx"); - /* Try to acquire a generic DMA engine slave TX channel */ - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); - - chan = dma_request_channel(mask, plat->dma_filter, plat->dma_tx_param); if (!chan) { - dev_err(uap->port.dev, "no TX DMA channel!\n"); - return; + /* We need platform data */ + if (!plat || !plat->dma_filter) { + dev_info(uap->port.dev, "no DMA platform data\n"); + return; + } + + /* Try to acquire a generic DMA engine slave TX channel */ + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); + + chan = dma_request_channel(mask, plat->dma_filter, + plat->dma_tx_param); + if (!chan) { + dev_err(uap->port.dev, "no TX DMA channel!\n"); + return; + } } dmaengine_slave_config(chan, &tx_conf); @@ -282,7 +287,18 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) dma_chan_name(uap->dmatx.chan)); /* Optionally make use of an RX channel as well */ - if (plat->dma_rx_param) { + chan = dma_request_slave_channel(dev, "rx"); + + if (!chan && plat->dma_rx_param) { + chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param); + + if (!chan) { + dev_err(uap->port.dev, "no RX DMA channel!\n"); + return; + } + } + + if (chan) { struct dma_slave_config rx_conf = { .src_addr = uap->port.mapbase + UART01x_DR, .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, @@ -291,12 +307,6 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) .device_fc = false, }; - chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param); - if (!chan) { - dev_err(uap->port.dev, "no RX DMA channel!\n"); - return; - } - dmaengine_slave_config(chan, &rx_conf); uap->dmarx.chan = chan; @@ -315,6 +325,7 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) struct dma_uap { struct list_head node; struct uart_amba_port *uap; + struct device *dev; }; static LIST_HEAD(pl011_dma_uarts); @@ -325,7 +336,7 @@ static int __init pl011_dma_initcall(void) list_for_each_safe(node, tmp, &pl011_dma_uarts) { struct dma_uap *dmau = list_entry(node, struct dma_uap, node); - pl011_dma_probe_initcall(dmau->uap); + pl011_dma_probe_initcall(dmau->dev, dmau->uap); list_del(node); kfree(dmau); } @@ -334,18 +345,19 @@ static int __init pl011_dma_initcall(void) device_initcall(pl011_dma_initcall); -static void pl011_dma_probe(struct uart_amba_port *uap) +static void pl011_dma_probe(struct device *dev, struct uart_amba_port *uap) { struct dma_uap *dmau = kzalloc(sizeof(struct dma_uap), GFP_KERNEL); if (dmau) { dmau->uap = uap; + dmau->dev = dev; list_add_tail(&dmau->node, &pl011_dma_uarts); } } #else -static void pl011_dma_probe(struct uart_amba_port *uap) +static void pl011_dma_probe(struct device *dev, struct uart_amba_port *uap) { - pl011_dma_probe_initcall(uap); + pl011_dma_probe_initcall(dev, uap); } #endif @@ -2020,7 +2032,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) uap->port.ops = &amba_pl011_pops; uap->port.flags = UPF_BOOT_AUTOCONF; uap->port.line = i; - pl011_dma_probe(uap); + pl011_dma_probe(&dev->dev, uap); /* Ensure interrupts from this UART are masked and cleared */ writew(0, uap->port.membase + UART011_IMSC); -- 1.8.0 ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d ^ permalink raw reply related [flat|nested] 20+ messages in thread
[parent not found: <1359395857-1235-4-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>]
* Re: [PATCH 3/5] serial: pl011: use generic DMA slave configuration if possible [not found] ` <1359395857-1235-4-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> @ 2013-02-05 14:22 ` Grant Likely 0 siblings, 0 replies; 20+ messages in thread From: Grant Likely @ 2013-02-05 14:22 UTC (permalink / raw) To: Arnd Bergmann, linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Greg Kroah-Hartman, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, Jiri Slaby On Mon, 28 Jan 2013 17:57:35 +0000, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote: > With the new OF DMA binding, it is possible to completely avoid the > need for platform_data for configuring a DMA channel. In cases where the > platform has already been converted, calling dma_request_slave_channel > should get all the necessary information from the device tree. > > Like the patch that converts the dw_dma controller, this is completely > untested and is looking for someone to try it out. > > Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> > Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> > Cc: Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org> > Cc: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> > Cc: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > Cc: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > Cc: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > Cc: Vinod Koul <vinod.koul-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org > Cc: linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> > --- > drivers/tty/serial/amba-pl011.c | 62 ++++++++++++++++++++++++----------------- > 1 file changed, 37 insertions(+), 25 deletions(-) > > diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c > index 3ea5408..c25b00e 100644 > --- a/drivers/tty/serial/amba-pl011.c > +++ b/drivers/tty/serial/amba-pl011.c > @@ -245,7 +245,7 @@ static void pl011_sgbuf_free(struct dma_chan *chan, struct pl011_sgbuf *sg, > } > } > > -static void pl011_dma_probe_initcall(struct uart_amba_port *uap) > +static void pl011_dma_probe_initcall(struct device *dev, struct uart_amba_port *uap) > { > /* DMA is the sole user of the platform data right now */ > struct amba_pl011_data *plat = uap->port.dev->platform_data; > @@ -259,20 +259,25 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) > struct dma_chan *chan; > dma_cap_mask_t mask; > > - /* We need platform data */ > - if (!plat || !plat->dma_filter) { > - dev_info(uap->port.dev, "no DMA platform data\n"); > - return; > - } > + chan = dma_request_slave_channel(dev, "tx"); > > - /* Try to acquire a generic DMA engine slave TX channel */ > - dma_cap_zero(mask); > - dma_cap_set(DMA_SLAVE, mask); > - > - chan = dma_request_channel(mask, plat->dma_filter, plat->dma_tx_param); > if (!chan) { > - dev_err(uap->port.dev, "no TX DMA channel!\n"); > - return; > + /* We need platform data */ > + if (!plat || !plat->dma_filter) { > + dev_info(uap->port.dev, "no DMA platform data\n"); > + return; > + } > + > + /* Try to acquire a generic DMA engine slave TX channel */ > + dma_cap_zero(mask); > + dma_cap_set(DMA_SLAVE, mask); > + > + chan = dma_request_channel(mask, plat->dma_filter, > + plat->dma_tx_param); > + if (!chan) { > + dev_err(uap->port.dev, "no TX DMA channel!\n"); > + return; > + } > } > > dmaengine_slave_config(chan, &tx_conf); > @@ -282,7 +287,18 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) > dma_chan_name(uap->dmatx.chan)); > > /* Optionally make use of an RX channel as well */ > - if (plat->dma_rx_param) { > + chan = dma_request_slave_channel(dev, "rx"); > + > + if (!chan && plat->dma_rx_param) { > + chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param); > + > + if (!chan) { > + dev_err(uap->port.dev, "no RX DMA channel!\n"); > + return; > + } > + } > + > + if (chan) { > struct dma_slave_config rx_conf = { > .src_addr = uap->port.mapbase + UART01x_DR, > .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, > @@ -291,12 +307,6 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) > .device_fc = false, > }; > > - chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param); > - if (!chan) { > - dev_err(uap->port.dev, "no RX DMA channel!\n"); > - return; > - } > - > dmaengine_slave_config(chan, &rx_conf); > uap->dmarx.chan = chan; > > @@ -315,6 +325,7 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) > struct dma_uap { > struct list_head node; > struct uart_amba_port *uap; > + struct device *dev; > }; > > static LIST_HEAD(pl011_dma_uarts); > @@ -325,7 +336,7 @@ static int __init pl011_dma_initcall(void) > > list_for_each_safe(node, tmp, &pl011_dma_uarts) { > struct dma_uap *dmau = list_entry(node, struct dma_uap, node); > - pl011_dma_probe_initcall(dmau->uap); > + pl011_dma_probe_initcall(dmau->dev, dmau->uap); > list_del(node); > kfree(dmau); > } > @@ -334,18 +345,19 @@ static int __init pl011_dma_initcall(void) > > device_initcall(pl011_dma_initcall); > > -static void pl011_dma_probe(struct uart_amba_port *uap) > +static void pl011_dma_probe(struct device *dev, struct uart_amba_port *uap) > { > struct dma_uap *dmau = kzalloc(sizeof(struct dma_uap), GFP_KERNEL); > if (dmau) { > dmau->uap = uap; > + dmau->dev = dev; > list_add_tail(&dmau->node, &pl011_dma_uarts); > } > } > #else > -static void pl011_dma_probe(struct uart_amba_port *uap) > +static void pl011_dma_probe(struct device *dev, struct uart_amba_port *uap) > { > - pl011_dma_probe_initcall(uap); > + pl011_dma_probe_initcall(dev, uap); > } > #endif > > @@ -2020,7 +2032,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) > uap->port.ops = &amba_pl011_pops; > uap->port.flags = UPF_BOOT_AUTOCONF; > uap->port.line = i; > - pl011_dma_probe(uap); > + pl011_dma_probe(&dev->dev, uap); > > /* Ensure interrupts from this UART are masked and cleared */ > writew(0, uap->port.membase + UART011_IMSC); > -- > 1.8.0 > -- Grant Likely, B.Sc, P.Eng. Secret Lab Technologies, Ltd. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 0/5] dmaengine: convert dw_dmac/spear13xx to generic binding [not found] ` <1359395857-1235-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-28 17:57 ` [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible Arnd Bergmann 2013-01-28 17:57 ` [PATCH 3/5] serial: pl011: " Arnd Bergmann @ 2013-01-28 21:58 ` Arnd Bergmann [not found] ` <1359410300-26113-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2 siblings, 1 reply; 20+ messages in thread From: Arnd Bergmann @ 2013-01-28 21:58 UTC (permalink / raw) To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r Cc: Vinod Koul, Arnd Bergmann, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, Jon Hunter, Greg Kroah-Hartman, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, Jiri Slaby, Jeff Garzik, Linus Walleij Hi everyone, I'm rather embarrassed to have sent yet another patch series to the wrong mailing list address, this now goes to the correct linux-arm-kernel list, so please comment here, not on the first version. I have also made some smaller changes and updated the DT bindings where I extended the drivers. I also uploaded the git branch to the spear/dma branch of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git This is my attempt to convert the spear platform and the dw_dmac to the generic device tree binding for DMA, so that we don't get a release with the broken version. I'm pretty sure that this has bugs, but it's as good as I could do without access to hardware or specs. Please review and comment, Arnd Arnd Bergmann (5): dmaengine: dw_dmac: move to generic DMA binding spi: pl022: use generic DMA slave configuration if possible serial: pl011: use generic DMA slave configuration if possible ata: arasan: remove the need for platform_data ARM: SPEAr13xx: Pass generic DW DMAC platform data from DT .../devicetree/bindings/ata/pata-arasan.txt | 22 ++++ Documentation/devicetree/bindings/dma/snps-dma.txt | 70 +++++------ arch/arm/boot/dts/spear1340.dtsi | 2 + arch/arm/boot/dts/spear13xx.dtsi | 25 +++- arch/arm/mach-spear/generic.h | 6 - arch/arm/mach-spear/include/mach/spear.h | 2 - arch/arm/mach-spear/spear1310.c | 30 +---- arch/arm/mach-spear/spear1340.c | 32 +---- arch/arm/mach-spear/spear13xx-dma.h | 128 -------------------- arch/arm/mach-spear/spear13xx.c | 58 --------- drivers/ata/pata_arasan_cf.c | 31 +++-- drivers/dma/dw_dmac.c | 130 ++++++++++----------- drivers/dma/dw_dmac_regs.h | 4 - drivers/spi/spi-pl022.c | 43 ++++++- drivers/tty/serial/amba-pl011.c | 62 ++++++---- include/linux/dw_dmac.h | 5 - include/linux/pata_arasan_cf_data.h | 2 - 17 files changed, 243 insertions(+), 409 deletions(-) delete mode 100644 arch/arm/mach-spear/spear13xx-dma.h -- 1.8.0 Cc: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> Cc: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> Cc: Jeff Garzik <jgarzik-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: Jon Hunter <jon-hunter-l0cyMroinI0@public.gmane.org> Cc: Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org> Cc: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> Cc: Vinod Koul <vinod.koul-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d ^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <1359410300-26113-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>]
* [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <1359410300-26113-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> @ 2013-01-28 21:58 ` Arnd Bergmann [not found] ` <1359410300-26113-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-28 21:58 ` [PATCH 3/5] serial: pl011: " Arnd Bergmann 1 sibling, 1 reply; 20+ messages in thread From: Arnd Bergmann @ 2013-01-28 21:58 UTC (permalink / raw) To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r Cc: Vinod Koul, Arnd Bergmann, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, Jon Hunter, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko With the new OF DMA binding, it is possible to completely avoid the need for platform_data for configuring a DMA channel. In cases where the platform has already been converted, calling dma_request_slave_channel should get all the necessary information from the device tree. Like the patch that converts the dw_dma controller, this is completely untested and is looking for someone to try it out. Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> Cc: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Cc: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: Vinod Koul <vinod.koul-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org --- .../devicetree/bindings/spi/spi_pl022.txt | 36 ++++++++++++++++++ drivers/spi/spi-pl022.c | 43 +++++++++++++++++++++- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/spi_pl022.txt b/Documentation/devicetree/bindings/spi/spi_pl022.txt index f158fd3..22ed679 100644 --- a/Documentation/devicetree/bindings/spi/spi_pl022.txt +++ b/Documentation/devicetree/bindings/spi/spi_pl022.txt @@ -16,6 +16,11 @@ Optional properties: device will be suspended immediately - pl022,rt : indicates the controller should run the message pump with realtime priority to minimise the transfer latency on the bus (boolean) +- dmas : Two or more DMA channel specifiers following the convention outlined + in bindings/dma/dma.txt +- dma-names: Names for the dma channels, if present. There must be at + least one channel named "tx" for transmit and named "rx" for + receive. SPI slave nodes must be children of the SPI master node and can @@ -32,3 +37,34 @@ contain the following properties. - pl022,wait-state : Microwire interface: Wait state - pl022,duplex : Microwire interface: Full/Half duplex + +Example: + + spi@e0100000 { + compatible = "arm,pl022", "arm,primecell"; + reg = <0xe0100000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <0 31 0x4>; + dmas = <&dma-controller 23 1>, + <&dma-controller 24 0>; + dma-names = "rx", "tx"; + + m25p80@1 { + compatible = "st,m25p80"; + reg = <1>; + spi-max-frequency = <12000000>; + spi-cpol; + spi-cpha; + pl022,hierarchy = <0>; + pl022,interface = <0>; + pl022,slave-tx-disable; + pl022,com-mode = <0x2>; + pl022,rx-level-trig = <0>; + pl022,tx-level-trig = <0>; + pl022,ctrl-len = <0x11>; + pl022,wait-state = <0>; + pl022,duplex = <0>; + }; + }; + diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index b0fe393..371cc66f 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -1139,6 +1139,35 @@ err_no_rxchan: return -ENODEV; } +static int pl022_dma_autoprobe(struct pl022 *pl022) +{ + struct device *dev = &pl022->adev->dev; + + /* automatically configure DMA channels from platform, normally using DT */ + pl022->dma_rx_channel = dma_request_slave_channel(dev, "rx"); + if (!pl022->dma_rx_channel) + goto err_no_rxchan; + + pl022->dma_tx_channel = dma_request_slave_channel(dev, "tx"); + if (!pl022->dma_tx_channel) + goto err_no_txchan; + + pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!pl022->dummypage) + goto err_no_dummypage; + + return 0; + +err_no_dummypage: + dma_release_channel(pl022->dma_tx_channel); + pl022->dma_tx_channel = NULL; +err_no_txchan: + dma_release_channel(pl022->dma_rx_channel); + pl022->dma_rx_channel = NULL; +err_no_rxchan: + return -ENODEV; +} + static void terminate_dma(struct pl022 *pl022) { struct dma_chan *rxchan = pl022->dma_rx_channel; @@ -1167,6 +1196,11 @@ static inline int configure_dma(struct pl022 *pl022) return -ENODEV; } +static inline int pl022_dma_autoprobe(struct pl022 *pl022) +{ + return 0; +} + static inline int pl022_dma_probe(struct pl022 *pl022) { return 0; @@ -2226,8 +2260,13 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) goto err_no_irq; } - /* Get DMA channels */ - if (platform_info->enable_dma) { + /* Get DMA channels, try autoconfiguration first */ + status = pl022_dma_autoprobe(pl022); + + /* If that failed, use channels from platform_info */ + if (status == 0) + platform_info->enable_dma = 1; + else if (platform_info->enable_dma) { status = pl022_dma_probe(pl022); if (status != 0) platform_info->enable_dma = 0; -- 1.8.0 ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d ^ permalink raw reply related [flat|nested] 20+ messages in thread
[parent not found: <1359410300-26113-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>]
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <1359410300-26113-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> @ 2013-01-29 2:41 ` Mark Brown 2013-01-29 7:49 ` Andy Shevchenko 1 sibling, 0 replies; 20+ messages in thread From: Mark Brown @ 2013-01-29 2:41 UTC (permalink / raw) To: Arnd Bergmann Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r [-- Attachment #1.1: Type: text/plain, Size: 655 bytes --] On Mon, Jan 28, 2013 at 09:58:17PM +0000, Arnd Bergmann wrote: > With the new OF DMA binding, it is possible to completely avoid the > need for platform_data for configuring a DMA channel. In cases where the > platform has already been converted, calling dma_request_slave_channel > should get all the necessary information from the device tree. > > Like the patch that converts the dw_dma controller, this is completely > untested and is looking for someone to try it out. Acked-by: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> I've no ability to test this but it looks good from a code point of view. [-- Attachment #1.2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] [-- Attachment #2: Type: text/plain, Size: 192 bytes --] _______________________________________________ devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org https://lists.ozlabs.org/listinfo/devicetree-discuss ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <1359410300-26113-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-29 2:41 ` Mark Brown @ 2013-01-29 7:49 ` Andy Shevchenko 2013-01-29 13:13 ` Arnd Bergmann 1 sibling, 1 reply; 20+ messages in thread From: Andy Shevchenko @ 2013-01-29 7:49 UTC (permalink / raw) To: Arnd Bergmann Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Mon, 2013-01-28 at 21:58 +0000, Arnd Bergmann wrote: > With the new OF DMA binding, it is possible to completely avoid the > need for platform_data for configuring a DMA channel. In cases where the > platform has already been converted, calling dma_request_slave_channel > should get all the necessary information from the device tree. > > Like the patch that converts the dw_dma controller, this is completely > untested and is looking for someone to try it out. > > Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> > Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> > Cc: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> > Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > Cc: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > Cc: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > Cc: Vinod Koul <vinod.koul-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org > Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org > --- > .../devicetree/bindings/spi/spi_pl022.txt | 36 ++++++++++++++++++ > drivers/spi/spi-pl022.c | 43 +++++++++++++++++++++- > 2 files changed, 77 insertions(+), 2 deletions(-) > > --- a/drivers/spi/spi-pl022.c > +++ b/drivers/spi/spi-pl022.c > @@ -1139,6 +1139,35 @@ err_no_rxchan: > return -ENODEV; > } > > +static int pl022_dma_autoprobe(struct pl022 *pl022) > +{ > + struct device *dev = &pl022->adev->dev; > + > + /* automatically configure DMA channels from platform, normally using DT */ > + pl022->dma_rx_channel = dma_request_slave_channel(dev, "rx"); > + if (!pl022->dma_rx_channel) > + goto err_no_rxchan; > + > + pl022->dma_tx_channel = dma_request_slave_channel(dev, "tx"); > + if (!pl022->dma_tx_channel) > + goto err_no_txchan; > + > + pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); Where this memory will be freed? In dependence of the answer could you consider to use devm_kmalloc or __get_free_page? > + if (!pl022->dummypage) > + goto err_no_dummypage; > + > + return 0; > + > +err_no_dummypage: > + dma_release_channel(pl022->dma_tx_channel); > + pl022->dma_tx_channel = NULL; > +err_no_txchan: > + dma_release_channel(pl022->dma_rx_channel); > + pl022->dma_rx_channel = NULL; > +err_no_rxchan: > + return -ENODEV; > +} > + > static void terminate_dma(struct pl022 *pl022) > { > struct dma_chan *rxchan = pl022->dma_rx_channel; > @@ -1167,6 +1196,11 @@ static inline int configure_dma(struct pl022 *pl022) > return -ENODEV; > } > > +static inline int pl022_dma_autoprobe(struct pl022 *pl022) > +{ > + return 0; > +} > + > static inline int pl022_dma_probe(struct pl022 *pl022) > { > return 0; > @@ -2226,8 +2260,13 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) > goto err_no_irq; > } > > - /* Get DMA channels */ > - if (platform_info->enable_dma) { > + /* Get DMA channels, try autoconfiguration first */ > + status = pl022_dma_autoprobe(pl022); > + > + /* If that failed, use channels from platform_info */ > + if (status == 0) > + platform_info->enable_dma = 1; > + else if (platform_info->enable_dma) { > status = pl022_dma_probe(pl022); > if (status != 0) > platform_info->enable_dma = 0; -- Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Intel Finland Oy ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible 2013-01-29 7:49 ` Andy Shevchenko @ 2013-01-29 13:13 ` Arnd Bergmann [not found] ` <201301291313.03511.arnd-r2nGTMty4D4@public.gmane.org> 0 siblings, 1 reply; 20+ messages in thread From: Arnd Bergmann @ 2013-01-29 13:13 UTC (permalink / raw) To: Andy Shevchenko Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, Jon Hunter, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Tuesday 29 January 2013, Andy Shevchenko wrote: > > +static int pl022_dma_autoprobe(struct pl022 *pl022) > > +{ > > + struct device *dev = &pl022->adev->dev; > > + > > + /* automatically configure DMA channels from platform, normally using DT */ > > + pl022->dma_rx_channel = dma_request_slave_channel(dev, "rx"); > > + if (!pl022->dma_rx_channel) > > + goto err_no_rxchan; > > + > > + pl022->dma_tx_channel = dma_request_slave_channel(dev, "tx"); > > + if (!pl022->dma_tx_channel) > > + goto err_no_txchan; > > + > > + pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); > > Where this memory will be freed? > In dependence of the answer could you consider to use > devm_kmalloc or __get_free_page? There is another function like this called pl022_dma_probe() that has the same allocation, and it gets freed in the same place. It's probably worth changing this into something different, but I felt that it didn't belong into this patch. I was also not sure if the best option would be dmam_alloc_coherent, dev_kzalloc, or __get_free_page. Arnd ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d ^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <201301291313.03511.arnd-r2nGTMty4D4@public.gmane.org>]
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <201301291313.03511.arnd-r2nGTMty4D4@public.gmane.org> @ 2013-02-07 18:29 ` Linus Walleij [not found] ` <CACRpkdZNpCJwp-uaH6feTcaPesNouwpHt-hO-M9v52G=Ux+Hqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 20+ messages in thread From: Linus Walleij @ 2013-02-07 18:29 UTC (permalink / raw) To: Arnd Bergmann Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, Jon Hunter, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Tue, Jan 29, 2013 at 2:13 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote: > On Tuesday 29 January 2013, Andy Shevchenko wrote: >> > + pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); >> >> Where this memory will be freed? >> In dependence of the answer could you consider to use >> devm_kmalloc or __get_free_page? > > There is another function like this called pl022_dma_probe() > that has the same allocation, and it gets freed in the same place. > > It's probably worth changing this into something different, but > I felt that it didn't belong into this patch. I was also not > sure if the best option would be dmam_alloc_coherent, dev_kzalloc, > or __get_free_page. Actually I once read about a feature where the kernel provides a static page full of zeroes or something like this, that would be ideal to use in cases like this, then all of this dummy page allocation and freeing can be deleted. Yours, Linus Walleij ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb ^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <CACRpkdZNpCJwp-uaH6feTcaPesNouwpHt-hO-M9v52G=Ux+Hqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <CACRpkdZNpCJwp-uaH6feTcaPesNouwpHt-hO-M9v52G=Ux+Hqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2013-02-07 19:42 ` Arnd Bergmann [not found] ` <201302071942.54642.arnd-r2nGTMty4D4@public.gmane.org> 2013-02-08 16:20 ` Russell King - ARM Linux 1 sibling, 1 reply; 20+ messages in thread From: Arnd Bergmann @ 2013-02-07 19:42 UTC (permalink / raw) To: Linus Walleij Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, Jon Hunter, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Thursday 07 February 2013, Linus Walleij wrote: > On Tue, Jan 29, 2013 at 2:13 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote: > > On Tuesday 29 January 2013, Andy Shevchenko wrote: > > >> > + pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); > >> > >> Where this memory will be freed? > >> In dependence of the answer could you consider to use > >> devm_kmalloc or __get_free_page? > > > > There is another function like this called pl022_dma_probe() > > that has the same allocation, and it gets freed in the same place. > > > > It's probably worth changing this into something different, but > > I felt that it didn't belong into this patch. I was also not > > sure if the best option would be dmam_alloc_coherent, dev_kzalloc, > > or __get_free_page. > > Actually I once read about a feature where the kernel provides > a static page full of zeroes or something like this, that would be > ideal to use in cases like this, then all of this dummy page > allocation and freeing can be deleted. You mean empty_zero_page? That only works if this page is read-only from the perspective of the DMA controller, but then it would be a good fit, yes. Arnd ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb ^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <201302071942.54642.arnd-r2nGTMty4D4@public.gmane.org>]
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <201302071942.54642.arnd-r2nGTMty4D4@public.gmane.org> @ 2013-02-07 20:19 ` Linus Walleij [not found] ` <CACRpkdbunPGtR4p_kY4q8WEb8iwkEbdo_icDyrLZwKrCe0wXqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 20+ messages in thread From: Linus Walleij @ 2013-02-07 20:19 UTC (permalink / raw) To: Arnd Bergmann Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, Jon Hunter, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Thu, Feb 7, 2013 at 8:42 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote: > On Thursday 07 February 2013, Linus Walleij wrote: >> Actually I once read about a feature where the kernel provides >> a static page full of zeroes or something like this, that would be >> ideal to use in cases like this, then all of this dummy page >> allocation and freeing can be deleted. > > You mean empty_zero_page? That only works if this page is > read-only from the perspective of the DMA controller, but > then it would be a good fit, yes. That's actually how it's used. SPI is symmetric, and in the DMA case we're not poking data into the buffers from the CPU so the controller need something - anything - to stream to the block. If we can use that page we'll even save a few remaps. Yours, Linus Walleij ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb ^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <CACRpkdbunPGtR4p_kY4q8WEb8iwkEbdo_icDyrLZwKrCe0wXqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <CACRpkdbunPGtR4p_kY4q8WEb8iwkEbdo_icDyrLZwKrCe0wXqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2013-02-07 21:15 ` Arnd Bergmann 2013-02-08 16:22 ` Russell King - ARM Linux 0 siblings, 1 reply; 20+ messages in thread From: Arnd Bergmann @ 2013-02-07 21:15 UTC (permalink / raw) To: Linus Walleij Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, Jon Hunter, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Thursday 07 February 2013 21:19:04 Linus Walleij wrote: > On Thu, Feb 7, 2013 at 8:42 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote: > > On Thursday 07 February 2013, Linus Walleij wrote: > > >> Actually I once read about a feature where the kernel provides > >> a static page full of zeroes or something like this, that would be > >> ideal to use in cases like this, then all of this dummy page > >> allocation and freeing can be deleted. > > > > You mean empty_zero_page? That only works if this page is > > read-only from the perspective of the DMA controller, but > > then it would be a good fit, yes. > > That's actually how it's used. > > SPI is symmetric, and in the DMA case we're not poking > data into the buffers from the CPU so the controller need > something - anything - to stream to the block. > > If we can use that page we'll even save a few remaps. I'm slightly worried about the caching effects though. The idea of the empty-zero page is that all user processes get it when they read a page before they write to it, so the data in it can essentially always be cache-hot. If we do DMA from that page to a device what would be the overhead of flushing the (clean) cache lines? Arnd ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible 2013-02-07 21:15 ` Arnd Bergmann @ 2013-02-08 16:22 ` Russell King - ARM Linux 2013-02-08 16:28 ` Arnd Bergmann 0 siblings, 1 reply; 20+ messages in thread From: Russell King - ARM Linux @ 2013-02-08 16:22 UTC (permalink / raw) To: Arnd Bergmann Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Thu, Feb 07, 2013 at 10:15:48PM +0100, Arnd Bergmann wrote: > On Thursday 07 February 2013 21:19:04 Linus Walleij wrote: > > On Thu, Feb 7, 2013 at 8:42 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote: > > > On Thursday 07 February 2013, Linus Walleij wrote: > > > > >> Actually I once read about a feature where the kernel provides > > >> a static page full of zeroes or something like this, that would be > > >> ideal to use in cases like this, then all of this dummy page > > >> allocation and freeing can be deleted. > > > > > > You mean empty_zero_page? That only works if this page is > > > read-only from the perspective of the DMA controller, but > > > then it would be a good fit, yes. > > > > That's actually how it's used. > > > > SPI is symmetric, and in the DMA case we're not poking > > data into the buffers from the CPU so the controller need > > something - anything - to stream to the block. > > > > If we can use that page we'll even save a few remaps. > > I'm slightly worried about the caching effects though. The > idea of the empty-zero page is that all user processes get > it when they read a page before they write to it, so the > data in it can essentially always be cache-hot. > > If we do DMA from that page to a device what would be the > overhead of flushing the (clean) cache lines? If it's DMA _to_ a device, then we will only ever clean the lines prior to a transfer, never invalidate them. So that's not really a concern. (There better not be any dirty cache lines associated with the empty zero page either.) ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible 2013-02-08 16:22 ` Russell King - ARM Linux @ 2013-02-08 16:28 ` Arnd Bergmann 2013-02-08 22:10 ` Linus Walleij 0 siblings, 1 reply; 20+ messages in thread From: Arnd Bergmann @ 2013-02-08 16:28 UTC (permalink / raw) To: Russell King - ARM Linux Cc: Vinod Koul, Viresh Kumar, devicetree-discuss, Mark Brown, Jon Hunter, spi-devel-general, Andy Shevchenko, Linus Walleij, linux-arm-kernel On Friday 08 February 2013 16:22:48 Russell King - ARM Linux wrote: > If it's DMA _to_ a device, then we will only ever clean the lines prior to > a transfer, never invalidate them. So that's not really a concern. (There > better not be any dirty cache lines associated with the empty zero page > either.) Right, makes sense. I thought I had read about a CPU that could not flush a cache line without also invalidating it, but that must have been something other than ARM, or maybe I'm misremembering it. Arnd ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible 2013-02-08 16:28 ` Arnd Bergmann @ 2013-02-08 22:10 ` Linus Walleij 0 siblings, 0 replies; 20+ messages in thread From: Linus Walleij @ 2013-02-08 22:10 UTC (permalink / raw) To: Arnd Bergmann Cc: Vinod Koul, Russell King - ARM Linux, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Fri, Feb 8, 2013 at 5:28 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote: > On Friday 08 February 2013 16:22:48 Russell King - ARM Linux wrote: >> If it's DMA _to_ a device, then we will only ever clean the lines prior to >> a transfer, never invalidate them. So that's not really a concern. (There >> better not be any dirty cache lines associated with the empty zero page >> either.) > > Right, makes sense. I thought I had read about a CPU that > could not flush a cache line without also invalidating > it, but that must have been something other than ARM, > or maybe I'm misremembering it. I don't think it matters one bit. The page can contain a bitmap of Donald Duck or zero FWIW. It's just that the DMA controller just neeeds to read *something* that does not cause a bus stall. It's due to the syncronous nature of the SPI protocol, to get something out you need to put something in. So when reading, this is a way to feed in some junk. So this goes on my TODO... Yours, Linus Walleij ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible [not found] ` <CACRpkdZNpCJwp-uaH6feTcaPesNouwpHt-hO-M9v52G=Ux+Hqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2013-02-07 19:42 ` Arnd Bergmann @ 2013-02-08 16:20 ` Russell King - ARM Linux 1 sibling, 0 replies; 20+ messages in thread From: Russell King - ARM Linux @ 2013-02-08 16:20 UTC (permalink / raw) To: Linus Walleij Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Mark Brown, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Thu, Feb 07, 2013 at 07:29:17PM +0100, Linus Walleij wrote: > Actually I once read about a feature where the kernel provides > a static page full of zeroes or something like this, that would be > ideal to use in cases like this, then all of this dummy page > allocation and freeing can be deleted. I think you're thinking of empty_zero_page which is used to provide the initial BSS pages for user apps. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 3/5] serial: pl011: use generic DMA slave configuration if possible [not found] ` <1359410300-26113-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-28 21:58 ` [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible Arnd Bergmann @ 2013-01-28 21:58 ` Arnd Bergmann [not found] ` <1359410300-26113-4-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 1 sibling, 1 reply; 20+ messages in thread From: Arnd Bergmann @ 2013-01-28 21:58 UTC (permalink / raw) To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Greg Kroah-Hartman, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, Jiri Slaby With the new OF DMA binding, it is possible to completely avoid the need for platform_data for configuring a DMA channel. In cases where the platform has already been converted, calling dma_request_slave_channel should get all the necessary information from the device tree. This also adds a binding document specific to the pl011 controller, and extends the generic primecell binding to mention "dmas" and other common properties. Like the patch that converts the dw_dma controller, this is completely untested and is looking for someone to try it out. Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> Cc: Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org> Cc: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> Cc: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Cc: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: Vinod Koul <vinod.koul-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org --- .../devicetree/bindings/arm/primecell.txt | 19 ++++++- Documentation/devicetree/bindings/serial/pl011.txt | 17 ++++++ drivers/tty/serial/amba-pl011.c | 62 +++++++++++++--------- 3 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 Documentation/devicetree/bindings/serial/pl011.txt diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt index 64fc82b..0df6aca 100644 --- a/Documentation/devicetree/bindings/arm/primecell.txt +++ b/Documentation/devicetree/bindings/arm/primecell.txt @@ -16,14 +16,31 @@ Optional properties: - clocks : From common clock binding. First clock is phandle to clock for apb pclk. Additional clocks are optional and specific to those peripherals. - clock-names : From common clock binding. Shall be "apb_pclk" for first clock. +- dmas : From common DMA binding. If present, refers to one or more dma channels. +- dma-names : From common DMA binding, needs to match the 'dmas' property. + Devices with exactly one receive and transmit channel shall name + these "rx" and "tx", respectively. +- pinctrl-<n> : Pinctrl states as described in bindings/pinctrl/pinctrl-bindings.txt +- pinctrl-names : Names corresponding to the numbered pinctrl states +- interrupts : one or more interrupt specifiers +- interrupt-names : names corresponding to the interrupts properties Example: serial@fff36000 { compatible = "arm,pl011", "arm,primecell"; arm,primecell-periphid = <0x00341011>; + clocks = <&pclk>; clock-names = "apb_pclk"; - + + dmas = <&dma-controller 4>, <&dma-controller 5>; + dma-names = "rx", "tx"; + + pinctrl-0 = <&uart0_default_mux>, <&uart0_default_mode>; + pinctrl-1 = <&uart0_sleep_mode>; + pinctrl-names = "default","sleep"; + + interrupts = <0 11 0x4>; }; diff --git a/Documentation/devicetree/bindings/serial/pl011.txt b/Documentation/devicetree/bindings/serial/pl011.txt new file mode 100644 index 0000000..5d2e840 --- /dev/null +++ b/Documentation/devicetree/bindings/serial/pl011.txt @@ -0,0 +1,17 @@ +* ARM AMBA Primecell PL011 serial UART + +Required properties: +- compatible: must be "arm,primecell", "arm,pl011" +- reg: exactly one register range with length 0x1000 +- interrupts: exactly one interrupt specifier + +Optional properties: +- pinctrl: When present, must have one state named "sleep" + and one state named "default" +- clocks: When present, must refer to exactly one clock named + "apb_pclk" +- dmas: When present, may have one or two dma channels. + The first one must be named "rx", the second one + must be named "tx". + +See also bindings/arm/primecell.txt diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 7fca402..f9af04d 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -245,7 +245,7 @@ static void pl011_sgbuf_free(struct dma_chan *chan, struct pl011_sgbuf *sg, } } -static void pl011_dma_probe_initcall(struct uart_amba_port *uap) +static void pl011_dma_probe_initcall(struct device *dev, struct uart_amba_port *uap) { /* DMA is the sole user of the platform data right now */ struct amba_pl011_data *plat = uap->port.dev->platform_data; @@ -259,20 +259,25 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) struct dma_chan *chan; dma_cap_mask_t mask; - /* We need platform data */ - if (!plat || !plat->dma_filter) { - dev_info(uap->port.dev, "no DMA platform data\n"); - return; - } + chan = dma_request_slave_channel(dev, "tx"); - /* Try to acquire a generic DMA engine slave TX channel */ - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); - - chan = dma_request_channel(mask, plat->dma_filter, plat->dma_tx_param); if (!chan) { - dev_err(uap->port.dev, "no TX DMA channel!\n"); - return; + /* We need platform data */ + if (!plat || !plat->dma_filter) { + dev_info(uap->port.dev, "no DMA platform data\n"); + return; + } + + /* Try to acquire a generic DMA engine slave TX channel */ + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); + + chan = dma_request_channel(mask, plat->dma_filter, + plat->dma_tx_param); + if (!chan) { + dev_err(uap->port.dev, "no TX DMA channel!\n"); + return; + } } dmaengine_slave_config(chan, &tx_conf); @@ -282,7 +287,18 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) dma_chan_name(uap->dmatx.chan)); /* Optionally make use of an RX channel as well */ - if (plat->dma_rx_param) { + chan = dma_request_slave_channel(dev, "rx"); + + if (!chan && plat->dma_rx_param) { + chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param); + + if (!chan) { + dev_err(uap->port.dev, "no RX DMA channel!\n"); + return; + } + } + + if (chan) { struct dma_slave_config rx_conf = { .src_addr = uap->port.mapbase + UART01x_DR, .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, @@ -291,12 +307,6 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) .device_fc = false, }; - chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param); - if (!chan) { - dev_err(uap->port.dev, "no RX DMA channel!\n"); - return; - } - dmaengine_slave_config(chan, &rx_conf); uap->dmarx.chan = chan; @@ -315,6 +325,7 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap) struct dma_uap { struct list_head node; struct uart_amba_port *uap; + struct device *dev; }; static LIST_HEAD(pl011_dma_uarts); @@ -325,7 +336,7 @@ static int __init pl011_dma_initcall(void) list_for_each_safe(node, tmp, &pl011_dma_uarts) { struct dma_uap *dmau = list_entry(node, struct dma_uap, node); - pl011_dma_probe_initcall(dmau->uap); + pl011_dma_probe_initcall(dmau->dev, dmau->uap); list_del(node); kfree(dmau); } @@ -334,18 +345,19 @@ static int __init pl011_dma_initcall(void) device_initcall(pl011_dma_initcall); -static void pl011_dma_probe(struct uart_amba_port *uap) +static void pl011_dma_probe(struct device *dev, struct uart_amba_port *uap) { struct dma_uap *dmau = kzalloc(sizeof(struct dma_uap), GFP_KERNEL); if (dmau) { dmau->uap = uap; + dmau->dev = dev; list_add_tail(&dmau->node, &pl011_dma_uarts); } } #else -static void pl011_dma_probe(struct uart_amba_port *uap) +static void pl011_dma_probe(struct device *dev, struct uart_amba_port *uap) { - pl011_dma_probe_initcall(uap); + pl011_dma_probe_initcall(dev, uap); } #endif @@ -2023,7 +2035,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) uap->port.ops = &amba_pl011_pops; uap->port.flags = UPF_BOOT_AUTOCONF; uap->port.line = i; - pl011_dma_probe(uap); + pl011_dma_probe(&dev->dev, uap); /* Ensure interrupts from this UART are masked and cleared */ writew(0, uap->port.membase + UART011_IMSC); -- 1.8.0 ^ permalink raw reply related [flat|nested] 20+ messages in thread
[parent not found: <1359410300-26113-4-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>]
* Re: [PATCH 3/5] serial: pl011: use generic DMA slave configuration if possible [not found] ` <1359410300-26113-4-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> @ 2013-01-30 4:38 ` Greg Kroah-Hartman 0 siblings, 0 replies; 20+ messages in thread From: Greg Kroah-Hartman @ 2013-01-30 4:38 UTC (permalink / raw) To: Arnd Bergmann Cc: Vinod Koul, Viresh Kumar, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jon Hunter, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko, Jiri Slaby, Linus Walleij, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On Mon, Jan 28, 2013 at 09:58:18PM +0000, Arnd Bergmann wrote: > With the new OF DMA binding, it is possible to completely avoid the > need for platform_data for configuring a DMA channel. In cases where the > platform has already been converted, calling dma_request_slave_channel > should get all the necessary information from the device tree. > > This also adds a binding document specific to the pl011 controller, > and extends the generic primecell binding to mention "dmas" and other > common properties. > > Like the patch that converts the dw_dma controller, this is completely > untested and is looking for someone to try it out. > > Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> > Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> > Cc: Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org> > Cc: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> > Cc: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > Cc: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > Cc: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > Cc: Vinod Koul <vinod.koul-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org > Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Acked-by: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2013-02-08 22:10 UTC | newest] Thread overview: 20+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1359395857-1235-1-git-send-email-arnd@arndb.de> [not found] ` <1359395857-1235-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-28 17:57 ` [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible Arnd Bergmann [not found] ` <1359395857-1235-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-02-05 14:22 ` Grant Likely 2013-02-07 18:27 ` Linus Walleij 2013-01-28 17:57 ` [PATCH 3/5] serial: pl011: " Arnd Bergmann [not found] ` <1359395857-1235-4-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-02-05 14:22 ` Grant Likely 2013-01-28 21:58 ` [PATCH v2 0/5] dmaengine: convert dw_dmac/spear13xx to generic binding Arnd Bergmann [not found] ` <1359410300-26113-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-28 21:58 ` [PATCH 2/5] spi: pl022: use generic DMA slave configuration if possible Arnd Bergmann [not found] ` <1359410300-26113-3-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-29 2:41 ` Mark Brown 2013-01-29 7:49 ` Andy Shevchenko 2013-01-29 13:13 ` Arnd Bergmann [not found] ` <201301291313.03511.arnd-r2nGTMty4D4@public.gmane.org> 2013-02-07 18:29 ` Linus Walleij [not found] ` <CACRpkdZNpCJwp-uaH6feTcaPesNouwpHt-hO-M9v52G=Ux+Hqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2013-02-07 19:42 ` Arnd Bergmann [not found] ` <201302071942.54642.arnd-r2nGTMty4D4@public.gmane.org> 2013-02-07 20:19 ` Linus Walleij [not found] ` <CACRpkdbunPGtR4p_kY4q8WEb8iwkEbdo_icDyrLZwKrCe0wXqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2013-02-07 21:15 ` Arnd Bergmann 2013-02-08 16:22 ` Russell King - ARM Linux 2013-02-08 16:28 ` Arnd Bergmann 2013-02-08 22:10 ` Linus Walleij 2013-02-08 16:20 ` Russell King - ARM Linux 2013-01-28 21:58 ` [PATCH 3/5] serial: pl011: " Arnd Bergmann [not found] ` <1359410300-26113-4-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2013-01-30 4:38 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).