* [PATCH 0/2] Correctly handle plaform_get_irq()'s result in the libata drivers
@ 2021-03-25 20:46 Sergey Shtylyov
2021-03-25 20:50 ` [PATCH 1/2] pata_arasan_cf: fix IRQ check Sergey Shtylyov
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2021-03-25 20:46 UTC (permalink / raw)
To: Jens Axboe, Viresh Kumar, linux-ide
Here are 2 patches against the 'master' branch of the Jens Axboe's 'linux-block.git' repo.
The affected drivers call platform_get_irq() but mis-interprete its result -- they consider
IRQ0 as error and the real error codes as valid IRQs... :-/
[1/2] pata_arasan_cf: fix IRQ check
[2/2] pata_ipx4xx_cf: fix IRQ check
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] pata_arasan_cf: fix IRQ check
2021-03-25 20:46 [PATCH 0/2] Correctly handle plaform_get_irq()'s result in the libata drivers Sergey Shtylyov
@ 2021-03-25 20:50 ` Sergey Shtylyov
2021-03-26 3:11 ` Viresh Kumar
2021-03-25 20:51 ` [PATCH 2/2] pata_ipx4xx_cf: " Sergey Shtylyov
2021-03-26 23:13 ` [PATCH 0/2] Correctly handle plaform_get_irq()'s result in the libata drivers Jens Axboe
2 siblings, 1 reply; 5+ messages in thread
From: Sergey Shtylyov @ 2021-03-25 20:50 UTC (permalink / raw)
To: Jens Axboe, Viresh Kumar, linux-ide
The driver's probe() method is written as if platform_get_irq() returns 0
on error, while actually it returns a negative error code (with all the
other values considered valid IRQs). Rewrite the driver's IRQ checking code
to pass the positive IRQ #s to ata_host_activate(), propagate upstream
-EPROBE_DEFER, and set up the driver to polling mode on (negative) errors
and IRQ0 (libata treats IRQ #0 as a polling mode anyway)...
Fixes: a480167b23ef ("pata_arasan_cf: Adding support for arasan compact flash host controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
---
This patch is against the 'master' branch of Jens Axboe's 'linux-block.git'
repo.
drivers/ata/pata_arasan_cf.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
Index: linux-block/drivers/ata/pata_arasan_cf.c
===================================================================
--- linux-block.orig/drivers/ata/pata_arasan_cf.c
+++ linux-block/drivers/ata/pata_arasan_cf.c
@@ -818,12 +818,19 @@ static int arasan_cf_probe(struct platfo
else
quirk = CF_BROKEN_UDMA; /* as it is on spear1340 */
- /* if irq is 0, support only PIO */
- acdev->irq = platform_get_irq(pdev, 0);
- if (acdev->irq)
+ /*
+ * If there's an error getting IRQ (or we do get IRQ0),
+ * support only PIO
+ */
+ ret = platform_get_irq(pdev, 0);
+ if (ret > 0) {
+ acdev->irq = ret;
irq_handler = arasan_cf_interrupt;
- else
+ } else if (ret == -EPROBE_DEFER) {
+ return ret;
+ } else {
quirk |= CF_BROKEN_MWDMA | CF_BROKEN_UDMA;
+ }
acdev->pbase = res->start;
acdev->vbase = devm_ioremap(&pdev->dev, res->start,
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] pata_ipx4xx_cf: fix IRQ check
2021-03-25 20:46 [PATCH 0/2] Correctly handle plaform_get_irq()'s result in the libata drivers Sergey Shtylyov
2021-03-25 20:50 ` [PATCH 1/2] pata_arasan_cf: fix IRQ check Sergey Shtylyov
@ 2021-03-25 20:51 ` Sergey Shtylyov
2021-03-26 23:13 ` [PATCH 0/2] Correctly handle plaform_get_irq()'s result in the libata drivers Jens Axboe
2 siblings, 0 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2021-03-25 20:51 UTC (permalink / raw)
To: Jens Axboe, Viresh Kumar, linux-ide
The driver's probe() method is written as if platform_get_irq() returns 0
on error, while actually it returns a negative error code (with all the
other values considered valid IRQs). Rewrite the driver's IRQ checking
code to pass the positive IRQ #s to ata_host_activate(), propagate errors
upstream, and treat IRQ0 as error, returning -EINVAL, as the libata code
treats 0 as an indication that polling should be used anyway...
Fixes: 0df0d0a0ea9f ("[libata] ARM: add ixp4xx PATA driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
---
drivers/ata/pata_ixp4xx_cf.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Index: linux-block/drivers/ata/pata_ixp4xx_cf.c
===================================================================
--- linux-block.orig/drivers/ata/pata_ixp4xx_cf.c
+++ linux-block/drivers/ata/pata_ixp4xx_cf.c
@@ -165,8 +165,12 @@ static int ixp4xx_pata_probe(struct plat
return -ENOMEM;
irq = platform_get_irq(pdev, 0);
- if (irq)
+ if (irq > 0)
irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
+ else if (irq < 0)
+ return irq;
+ else
+ return -EINVAL;
/* Setup expansion bus chip selects */
*data->cs0_cfg = data->cs0_bits;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] pata_arasan_cf: fix IRQ check
2021-03-25 20:50 ` [PATCH 1/2] pata_arasan_cf: fix IRQ check Sergey Shtylyov
@ 2021-03-26 3:11 ` Viresh Kumar
0 siblings, 0 replies; 5+ messages in thread
From: Viresh Kumar @ 2021-03-26 3:11 UTC (permalink / raw)
To: Sergey Shtylyov; +Cc: Jens Axboe, Viresh Kumar, linux-ide
On 25-03-21, 23:50, Sergey Shtylyov wrote:
> The driver's probe() method is written as if platform_get_irq() returns 0
> on error, while actually it returns a negative error code (with all the
> other values considered valid IRQs). Rewrite the driver's IRQ checking code
> to pass the positive IRQ #s to ata_host_activate(), propagate upstream
> -EPROBE_DEFER, and set up the driver to polling mode on (negative) errors
> and IRQ0 (libata treats IRQ #0 as a polling mode anyway)...
>
> Fixes: a480167b23ef ("pata_arasan_cf: Adding support for arasan compact flash host controller")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
>
> ---
> This patch is against the 'master' branch of Jens Axboe's 'linux-block.git'
> repo.
>
> drivers/ata/pata_arasan_cf.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> Index: linux-block/drivers/ata/pata_arasan_cf.c
> ===================================================================
> --- linux-block.orig/drivers/ata/pata_arasan_cf.c
> +++ linux-block/drivers/ata/pata_arasan_cf.c
> @@ -818,12 +818,19 @@ static int arasan_cf_probe(struct platfo
> else
> quirk = CF_BROKEN_UDMA; /* as it is on spear1340 */
>
> - /* if irq is 0, support only PIO */
> - acdev->irq = platform_get_irq(pdev, 0);
> - if (acdev->irq)
> + /*
> + * If there's an error getting IRQ (or we do get IRQ0),
> + * support only PIO
> + */
> + ret = platform_get_irq(pdev, 0);
> + if (ret > 0) {
> + acdev->irq = ret;
> irq_handler = arasan_cf_interrupt;
> - else
> + } else if (ret == -EPROBE_DEFER) {
> + return ret;
> + } else {
> quirk |= CF_BROKEN_MWDMA | CF_BROKEN_UDMA;
> + }
>
> acdev->pbase = res->start;
> acdev->vbase = devm_ioremap(&pdev->dev, res->start,
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Correctly handle plaform_get_irq()'s result in the libata drivers
2021-03-25 20:46 [PATCH 0/2] Correctly handle plaform_get_irq()'s result in the libata drivers Sergey Shtylyov
2021-03-25 20:50 ` [PATCH 1/2] pata_arasan_cf: fix IRQ check Sergey Shtylyov
2021-03-25 20:51 ` [PATCH 2/2] pata_ipx4xx_cf: " Sergey Shtylyov
@ 2021-03-26 23:13 ` Jens Axboe
2 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2021-03-26 23:13 UTC (permalink / raw)
To: Sergey Shtylyov, Viresh Kumar, linux-ide
On 3/25/21 2:46 PM, Sergey Shtylyov wrote:
> Here are 2 patches against the 'master' branch of the Jens Axboe's 'linux-block.git' repo.
> The affected drivers call platform_get_irq() but mis-interprete its result -- they consider
> IRQ0 as error and the real error codes as valid IRQs... :-/
>
> [1/2] pata_arasan_cf: fix IRQ check
> [2/2] pata_ipx4xx_cf: fix IRQ check
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-03-26 23:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-25 20:46 [PATCH 0/2] Correctly handle plaform_get_irq()'s result in the libata drivers Sergey Shtylyov
2021-03-25 20:50 ` [PATCH 1/2] pata_arasan_cf: fix IRQ check Sergey Shtylyov
2021-03-26 3:11 ` Viresh Kumar
2021-03-25 20:51 ` [PATCH 2/2] pata_ipx4xx_cf: " Sergey Shtylyov
2021-03-26 23:13 ` [PATCH 0/2] Correctly handle plaform_get_irq()'s result in the libata drivers Jens Axboe
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).