* [PATCH 1/3] spi: pxa2xx: handle error of pxa2xx_spi_dma_prepare() @ 2016-03-23 15:29 Jarkko Nikula [not found] ` <1458746964-9335-1-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 0 siblings, 1 reply; 8+ messages in thread From: Jarkko Nikula @ 2016-03-23 15:29 UTC (permalink / raw) To: linux-spi-u79uwXL29TY76Z2rM5mHXA Cc: Mark Brown, Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mika Westerberg, Andy Shevchenko, Jarkko Nikula From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> If by some reason pxa2xx_spi_dma_prepare() fails we have not to ignore its error. In such case we abort the transfer and return the error to upper level. Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Signed-off-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> --- Reposting Andy's fix from December that got buried to list during holidays. --- drivers/spi/spi-pxa2xx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 85e59a406a4c..47bdbd350a24 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -928,6 +928,7 @@ static void pump_transfers(unsigned long data) u32 dma_thresh = drv_data->cur_chip->dma_threshold; u32 dma_burst = drv_data->cur_chip->dma_burst_size; u32 change_mask = pxa2xx_spi_get_ssrc1_change_mask(drv_data); + int err; /* Get current state information */ message = drv_data->cur_msg; @@ -1047,7 +1048,12 @@ static void pump_transfers(unsigned long data) /* Ensure we have the correct interrupt handler */ drv_data->transfer_handler = pxa2xx_spi_dma_transfer; - pxa2xx_spi_dma_prepare(drv_data, dma_burst); + err = pxa2xx_spi_dma_prepare(drv_data, dma_burst); + if (err) { + message->status = err; + giveback(drv_data); + return; + } /* Clear status and start DMA engine */ cr1 = chip->cr1 | dma_thresh | drv_data->dma_cr1; -- 2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 8+ messages in thread
[parent not found: <1458746964-9335-1-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>]
* [PATCH 2/3] spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data [not found] ` <1458746964-9335-1-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> @ 2016-03-23 15:29 ` Jarkko Nikula [not found] ` <1458746964-9335-2-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2016-03-23 15:29 ` [PATCH 3/3] spi: pxa2xx: Use dummy buffers provided by SPI core Jarkko Nikula 2016-03-23 18:15 ` [PATCH 1/3] spi: pxa2xx: handle error of pxa2xx_spi_dma_prepare() Robert Jarzmik 2 siblings, 1 reply; 8+ messages in thread From: Jarkko Nikula @ 2016-03-23 15:29 UTC (permalink / raw) To: linux-spi-u79uwXL29TY76Z2rM5mHXA Cc: Mark Brown, Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mika Westerberg, Jarkko Nikula spi-pxa2xx-dma.c DMA engine implementation stopped using PIO for unaligned trailing bytes in the commit 111e0a9dc71e ("spi/pxa2xx: Prevent DMA from transferring too many bytes"). This means there is no need to update tx/rx transfer buffer pointers after DMA completion. These buffer pointers will be set to new buffers when handling the next transfer. Because this buffer pointer update was only remaining use for rx_map_len and tx_map_len members in struct driver_data after removing the legacy PXA DMA implementation they can be removed now. Signed-off-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> --- drivers/spi/spi-pxa2xx-dma.c | 5 ----- drivers/spi/spi-pxa2xx.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c index 365fc22c3572..696a340230eb 100644 --- a/drivers/spi/spi-pxa2xx-dma.c +++ b/drivers/spi/spi-pxa2xx-dma.c @@ -33,12 +33,10 @@ static int pxa2xx_spi_map_dma_buffer(struct driver_data *drv_data, dmadev = drv_data->tx_chan->device->dev; sgt = &drv_data->tx_sgt; buf = drv_data->tx; - drv_data->tx_map_len = len; } else { dmadev = drv_data->rx_chan->device->dev; sgt = &drv_data->rx_sgt; buf = drv_data->rx; - drv_data->rx_map_len = len; } nents = DIV_ROUND_UP(len, SZ_2K); @@ -133,9 +131,6 @@ static void pxa2xx_spi_dma_transfer_complete(struct driver_data *drv_data, if (!error) { pxa2xx_spi_unmap_dma_buffers(drv_data); - drv_data->tx += drv_data->tx_map_len; - drv_data->rx += drv_data->rx_map_len; - msg->actual_length += drv_data->len; msg->state = pxa2xx_spi_next_transfer(drv_data); } else { diff --git a/drivers/spi/spi-pxa2xx.h b/drivers/spi/spi-pxa2xx.h index a1ef88948144..85017f9ca67c 100644 --- a/drivers/spi/spi-pxa2xx.h +++ b/drivers/spi/spi-pxa2xx.h @@ -69,8 +69,6 @@ struct driver_data { void *rx; void *rx_end; int dma_mapped; - size_t rx_map_len; - size_t tx_map_len; u8 n_bytes; int (*write)(struct driver_data *drv_data); int (*read)(struct driver_data *drv_data); -- 2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 8+ messages in thread
[parent not found: <1458746964-9335-2-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>]
* Re: [PATCH 2/3] spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data [not found] ` <1458746964-9335-2-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> @ 2016-03-23 18:16 ` Robert Jarzmik 2016-03-29 7:42 ` Applied "spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data" to the spi tree Mark Brown 1 sibling, 0 replies; 8+ messages in thread From: Robert Jarzmik @ 2016-03-23 18:16 UTC (permalink / raw) To: Jarkko Nikula Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown, Daniel Mack, Haojian Zhuang, Mika Westerberg Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> writes: > spi-pxa2xx-dma.c DMA engine implementation stopped using PIO for > unaligned trailing bytes in the commit 111e0a9dc71e ("spi/pxa2xx: Prevent > DMA from transferring too many bytes"). This means there is no need to > update tx/rx transfer buffer pointers after DMA completion. These buffer > pointers will be set to new buffers when handling the next transfer. > > Because this buffer pointer update was only remaining use for rx_map_len > and tx_map_len members in struct driver_data after removing the legacy PXA > DMA implementation they can be removed now. > > Signed-off-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Acked-by: Robert Jarzmik <robert.jarzmik-GANU6spQydw@public.gmane.org> -- Robert -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Applied "spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data" to the spi tree [not found] ` <1458746964-9335-2-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2016-03-23 18:16 ` Robert Jarzmik @ 2016-03-29 7:42 ` Mark Brown 1 sibling, 0 replies; 8+ messages in thread From: Mark Brown @ 2016-03-29 7:42 UTC (permalink / raw) To: Jarkko Nikula, Robert Jarzmik, Mark Brown Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA The patch spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 68335ec76e45fb3a1b796b26c3ea49ce1231d8fb Mon Sep 17 00:00:00 2001 From: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Date: Thu, 24 Mar 2016 15:35:43 +0200 Subject: [PATCH] spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data spi-pxa2xx-dma.c DMA engine implementation stopped using PIO for unaligned trailing bytes in the commit 111e0a9dc71e ("spi/pxa2xx: Prevent DMA from transferring too many bytes"). This means there is no need to update tx/rx transfer buffer pointers after DMA completion. These buffer pointers will be set to new buffers when handling the next transfer. Because this buffer pointer update was only remaining use for rx_map_len and tx_map_len members in struct driver_data after removing the legacy PXA DMA implementation they can be removed now. Signed-off-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Acked-by: Robert Jarzmik <robert.jarzmik-GANU6spQydw@public.gmane.org> Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> --- drivers/spi/spi-pxa2xx-dma.c | 5 ----- drivers/spi/spi-pxa2xx.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c index b1883d228103..624cb06bd2e1 100644 --- a/drivers/spi/spi-pxa2xx-dma.c +++ b/drivers/spi/spi-pxa2xx-dma.c @@ -33,12 +33,10 @@ static int pxa2xx_spi_map_dma_buffer(struct driver_data *drv_data, dmadev = drv_data->tx_chan->device->dev; sgt = &drv_data->tx_sgt; buf = drv_data->tx; - drv_data->tx_map_len = len; } else { dmadev = drv_data->rx_chan->device->dev; sgt = &drv_data->rx_sgt; buf = drv_data->rx; - drv_data->rx_map_len = len; } nents = DIV_ROUND_UP(len, SZ_2K); @@ -133,9 +131,6 @@ static void pxa2xx_spi_dma_transfer_complete(struct driver_data *drv_data, if (!error) { pxa2xx_spi_unmap_dma_buffers(drv_data); - drv_data->tx += drv_data->tx_map_len; - drv_data->rx += drv_data->rx_map_len; - msg->actual_length += drv_data->len; msg->state = pxa2xx_spi_next_transfer(drv_data); } else { diff --git a/drivers/spi/spi-pxa2xx.h b/drivers/spi/spi-pxa2xx.h index a1ef88948144..85017f9ca67c 100644 --- a/drivers/spi/spi-pxa2xx.h +++ b/drivers/spi/spi-pxa2xx.h @@ -69,8 +69,6 @@ struct driver_data { void *rx; void *rx_end; int dma_mapped; - size_t rx_map_len; - size_t tx_map_len; u8 n_bytes; int (*write)(struct driver_data *drv_data); int (*read)(struct driver_data *drv_data); -- 2.8.0.rc3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] spi: pxa2xx: Use dummy buffers provided by SPI core [not found] ` <1458746964-9335-1-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2016-03-23 15:29 ` [PATCH 2/3] spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data Jarkko Nikula @ 2016-03-23 15:29 ` Jarkko Nikula [not found] ` <1458746964-9335-3-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2016-03-23 18:15 ` [PATCH 1/3] spi: pxa2xx: handle error of pxa2xx_spi_dma_prepare() Robert Jarzmik 2 siblings, 1 reply; 8+ messages in thread From: Jarkko Nikula @ 2016-03-23 15:29 UTC (permalink / raw) To: linux-spi-u79uwXL29TY76Z2rM5mHXA Cc: Mark Brown, Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mika Westerberg, Jarkko Nikula Dummy buffer is used for half duplex transfers that don't have TX or RX buffer set. Instead of own dummy buffer management here let the SPI core to handle it by setting the SPI_MASTER_MUST_RX and SPI_MASTER_MUST_TX flags. Then core makes sure both transfer buffers are set. Signed-off-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> --- drivers/spi/spi-pxa2xx-dma.c | 10 +--------- drivers/spi/spi-pxa2xx.c | 1 + drivers/spi/spi-pxa2xx.h | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c index 696a340230eb..bef707f7ae99 100644 --- a/drivers/spi/spi-pxa2xx-dma.c +++ b/drivers/spi/spi-pxa2xx-dma.c @@ -53,11 +53,7 @@ static int pxa2xx_spi_map_dma_buffer(struct driver_data *drv_data, for_each_sg(sgt->sgl, sg, sgt->nents, i) { size_t bytes = min_t(size_t, len, SZ_2K); - if (buf) - sg_set_buf(sg, pbuf, bytes); - else - sg_set_buf(sg, drv_data->dummy, bytes); - + sg_set_buf(sg, pbuf, bytes); pbuf += bytes; len -= bytes; } @@ -303,10 +299,6 @@ int pxa2xx_spi_dma_setup(struct driver_data *drv_data) dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); - drv_data->dummy = devm_kzalloc(dev, SZ_2K, GFP_KERNEL); - if (!drv_data->dummy) - return -ENOMEM; - drv_data->tx_chan = dma_request_slave_channel_compat(mask, pdata->dma_filter, pdata->tx_param, dev, "tx"); if (!drv_data->tx_chan) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 47bdbd350a24..86c155aea0cf 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1562,6 +1562,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) master->unprepare_transfer_hardware = pxa2xx_spi_unprepare_transfer; master->fw_translate_cs = pxa2xx_spi_fw_translate_cs; master->auto_runtime_pm = true; + master->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX; drv_data->ssp_type = ssp->type; diff --git a/drivers/spi/spi-pxa2xx.h b/drivers/spi/spi-pxa2xx.h index 85017f9ca67c..e6b09000ff14 100644 --- a/drivers/spi/spi-pxa2xx.h +++ b/drivers/spi/spi-pxa2xx.h @@ -56,7 +56,6 @@ struct driver_data { struct sg_table tx_sgt; int rx_nents; int tx_nents; - void *dummy; atomic_t dma_running; /* Current message transfer state info */ -- 2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 8+ messages in thread
[parent not found: <1458746964-9335-3-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>]
* Applied "spi: pxa2xx: Use dummy buffers provided by SPI core" to the spi tree [not found] ` <1458746964-9335-3-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> @ 2016-03-29 7:42 ` Mark Brown 0 siblings, 0 replies; 8+ messages in thread From: Mark Brown @ 2016-03-29 7:42 UTC (permalink / raw) To: Jarkko Nikula, Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA The patch spi: pxa2xx: Use dummy buffers provided by SPI core has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 8c3ad488fe0e4478b3b29b9501074c5fb1bfda0d Mon Sep 17 00:00:00 2001 From: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Date: Thu, 24 Mar 2016 15:35:44 +0200 Subject: [PATCH] spi: pxa2xx: Use dummy buffers provided by SPI core Dummy buffer is used for half duplex transfers that don't have TX or RX buffer set. Instead of own dummy buffer management here let the SPI core to handle it by setting the SPI_MASTER_MUST_RX and SPI_MASTER_MUST_TX flags. Then core makes sure both transfer buffers are set. Signed-off-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> --- drivers/spi/spi-pxa2xx-dma.c | 10 +--------- drivers/spi/spi-pxa2xx.c | 1 + drivers/spi/spi-pxa2xx.h | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c index 624cb06bd2e1..a18a03d0afb7 100644 --- a/drivers/spi/spi-pxa2xx-dma.c +++ b/drivers/spi/spi-pxa2xx-dma.c @@ -53,11 +53,7 @@ static int pxa2xx_spi_map_dma_buffer(struct driver_data *drv_data, for_each_sg(sgt->sgl, sg, sgt->nents, i) { size_t bytes = min_t(size_t, len, SZ_2K); - if (buf) - sg_set_buf(sg, pbuf, bytes); - else - sg_set_buf(sg, drv_data->dummy, bytes); - + sg_set_buf(sg, pbuf, bytes); pbuf += bytes; len -= bytes; } @@ -312,10 +308,6 @@ int pxa2xx_spi_dma_setup(struct driver_data *drv_data) dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); - drv_data->dummy = devm_kzalloc(dev, SZ_2K, GFP_KERNEL); - if (!drv_data->dummy) - return -ENOMEM; - drv_data->tx_chan = dma_request_slave_channel_compat(mask, pdata->dma_filter, pdata->tx_param, dev, "tx"); if (!drv_data->tx_chan) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 47bdbd350a24..86c155aea0cf 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1562,6 +1562,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) master->unprepare_transfer_hardware = pxa2xx_spi_unprepare_transfer; master->fw_translate_cs = pxa2xx_spi_fw_translate_cs; master->auto_runtime_pm = true; + master->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX; drv_data->ssp_type = ssp->type; diff --git a/drivers/spi/spi-pxa2xx.h b/drivers/spi/spi-pxa2xx.h index 85017f9ca67c..e6b09000ff14 100644 --- a/drivers/spi/spi-pxa2xx.h +++ b/drivers/spi/spi-pxa2xx.h @@ -56,7 +56,6 @@ struct driver_data { struct sg_table tx_sgt; int rx_nents; int tx_nents; - void *dummy; atomic_t dma_running; /* Current message transfer state info */ -- 2.8.0.rc3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] spi: pxa2xx: handle error of pxa2xx_spi_dma_prepare() [not found] ` <1458746964-9335-1-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2016-03-23 15:29 ` [PATCH 2/3] spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data Jarkko Nikula 2016-03-23 15:29 ` [PATCH 3/3] spi: pxa2xx: Use dummy buffers provided by SPI core Jarkko Nikula @ 2016-03-23 18:15 ` Robert Jarzmik [not found] ` <87fuvhrrgb.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> 2 siblings, 1 reply; 8+ messages in thread From: Robert Jarzmik @ 2016-03-23 18:15 UTC (permalink / raw) To: Jarkko Nikula Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown, Daniel Mack, Haojian Zhuang, Mika Westerberg, Andy Shevchenko Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> writes: > From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > > If by some reason pxa2xx_spi_dma_prepare() fails we have not to ignore its > error. In such case we abort the transfer and return the error to upper > level. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > Signed-off-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> > --- > Reposting Andy's fix from December that got buried to list during > holidays. > --- > drivers/spi/spi-pxa2xx.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c > index 85e59a406a4c..47bdbd350a24 100644 > --- a/drivers/spi/spi-pxa2xx.c > +++ b/drivers/spi/spi-pxa2xx.c > @@ -928,6 +928,7 @@ static void pump_transfers(unsigned long data) > u32 dma_thresh = drv_data->cur_chip->dma_threshold; > u32 dma_burst = drv_data->cur_chip->dma_burst_size; > u32 change_mask = pxa2xx_spi_get_ssrc1_change_mask(drv_data); > + int err; > > /* Get current state information */ > message = drv_data->cur_msg; > @@ -1047,7 +1048,12 @@ static void pump_transfers(unsigned long data) > /* Ensure we have the correct interrupt handler */ > drv_data->transfer_handler = pxa2xx_spi_dma_transfer; > > - pxa2xx_spi_dma_prepare(drv_data, dma_burst); > + err = pxa2xx_spi_dma_prepare(drv_data, dma_burst); > + if (err) { > + message->status = err; > + giveback(drv_data); > + return; > + } Hi Jarrko, Even if this patch is perfectly fine, isn't pxa2xx_spi_dma_prepare() leaking tx_desc if its rx_desc allocation failed ? If so, wouldn't it make sense to add it to this patch ? Cheers. -- Robert -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <87fuvhrrgb.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org>]
* Re: [PATCH 1/3] spi: pxa2xx: handle error of pxa2xx_spi_dma_prepare() [not found] ` <87fuvhrrgb.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> @ 2016-03-24 9:12 ` Jarkko Nikula 0 siblings, 0 replies; 8+ messages in thread From: Jarkko Nikula @ 2016-03-24 9:12 UTC (permalink / raw) To: Robert Jarzmik Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown, Daniel Mack, Haojian Zhuang, Mika Westerberg, Andy Shevchenko On 03/23/2016 08:15 PM, Robert Jarzmik wrote: > Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> writes: > >> From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> >> >> If by some reason pxa2xx_spi_dma_prepare() fails we have not to ignore its >> error. In such case we abort the transfer and return the error to upper >> level. >> >> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> >> Signed-off-by: Jarkko Nikula <jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> >> --- >> Reposting Andy's fix from December that got buried to list during >> holidays. >> --- >> drivers/spi/spi-pxa2xx.c | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c >> index 85e59a406a4c..47bdbd350a24 100644 >> --- a/drivers/spi/spi-pxa2xx.c >> +++ b/drivers/spi/spi-pxa2xx.c >> @@ -928,6 +928,7 @@ static void pump_transfers(unsigned long data) >> u32 dma_thresh = drv_data->cur_chip->dma_threshold; >> u32 dma_burst = drv_data->cur_chip->dma_burst_size; >> u32 change_mask = pxa2xx_spi_get_ssrc1_change_mask(drv_data); >> + int err; >> >> /* Get current state information */ >> message = drv_data->cur_msg; >> @@ -1047,7 +1048,12 @@ static void pump_transfers(unsigned long data) >> /* Ensure we have the correct interrupt handler */ >> drv_data->transfer_handler = pxa2xx_spi_dma_transfer; >> >> - pxa2xx_spi_dma_prepare(drv_data, dma_burst); >> + err = pxa2xx_spi_dma_prepare(drv_data, dma_burst); >> + if (err) { >> + message->status = err; >> + giveback(drv_data); >> + return; >> + } > Hi Jarrko, > > Even if this patch is perfectly fine, isn't pxa2xx_spi_dma_prepare() leaking > tx_desc if its rx_desc allocation failed ? If so, wouldn't it make sense to add > it to this patch ? > Good catch, it indeeds leak. Also unmapping needs to be done too. Will fix and resend. -- Jarkko -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-03-29 7:42 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-03-23 15:29 [PATCH 1/3] spi: pxa2xx: handle error of pxa2xx_spi_dma_prepare() Jarkko Nikula [not found] ` <1458746964-9335-1-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2016-03-23 15:29 ` [PATCH 2/3] spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data Jarkko Nikula [not found] ` <1458746964-9335-2-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2016-03-23 18:16 ` Robert Jarzmik 2016-03-29 7:42 ` Applied "spi: pxa2xx: Remove rx_/tx_map_len members from struct driver_data" to the spi tree Mark Brown 2016-03-23 15:29 ` [PATCH 3/3] spi: pxa2xx: Use dummy buffers provided by SPI core Jarkko Nikula [not found] ` <1458746964-9335-3-git-send-email-jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> 2016-03-29 7:42 ` Applied "spi: pxa2xx: Use dummy buffers provided by SPI core" to the spi tree Mark Brown 2016-03-23 18:15 ` [PATCH 1/3] spi: pxa2xx: handle error of pxa2xx_spi_dma_prepare() Robert Jarzmik [not found] ` <87fuvhrrgb.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org> 2016-03-24 9:12 ` Jarkko Nikula
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.