ata: libahci_platform: Get rid of dup message when IRQ can't be retrieved
Subsystems (2)
PATCH 1/2 ata: libahci_platform: Get rid of dup message when IRQ can't be retrieved
platform_get_irq() will print a message when it fails. No need to repeat this.
While at it, drop redundant check for 0 as platform_get_irq() spills out a big WARN() in such case.
--- drivers/ata/libahci_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/ata/libahci_platform.c +1 -6
@@ -579,13 +579,8 @@ int ahci_platform_init_host(struct platform_device *pdev,int i, irq, n_ports, rc; irq =platform_get_irq (pdev,0 ); -if (irq <0 ) { -if (irq != -EPROBE_DEFER ) -dev_err (dev,"no irq\n" ); +if (irq <0 )return irq; - } -if (!irq) -return -EINVAL ; hpriv->irq = irq;
Signature · 1 line
2.33.0
PATCH 2/2 ata: libahci_platform: Remove bogus 32-bit DMA mask attempt
If 64-bit mask attempt fails, the 32-bit will fail by the very same reason. Don't even try the latter. It's a continuation of the changes that contains, e.g. dcc02c19cc06 ("sata_sil24: use dma_set_mask_and_coherent").
--- drivers/ata/libahci_platform.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/ata/libahci_platform.c +2 -7
@@ -637,13 +637,8 @@ int ahci_platform_init_host(struct platform_device *pdev,if (hpriv->cap &HOST_CAP_64 ) { rc =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (64 ));if (rc) { - rc =dma_coerce_mask_and_coherent (dev, -DMA_BIT_MASK (32 )); -if (rc) { -dev_err (dev,"Failed to enable 64-bit DMA.\n" ); -return rc; - } -dev_warn (dev,"Enable 32-bit DMA instead of 64-bit.\n" ); +dev_err (dev,"Failed to enable 64-bit DMA.\n" ); +return rc; } }
Signature · 1 line
2.33.0
Re: [PATCH v1 2/2] ata: libahci_platform: Remove bogus 32-bit DMA mask attempt
Quoted 3 lines · Andy Shevchenko
If 64-bit mask attempt fails, the 32-bit will fail by the very same reason. Don't even try the latter. It's a continuation of the changes that contains, e.g.
dcc02c19cc06("sata_sil24: usedma_set_mask_and_coherent").
I understand that some people have nothing besides bikeshedding, but this patch seems fine to everybody, am I right? Can it be applied (it's independent from patch 1 anyways)?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 2/2] ata: libahci_platform: Remove bogus 32-bit DMA mask attempt
Quoted 9 lines · Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
If 64-bit mask attempt fails, the 32-bit will fail by the very same reason. Don't even try the latter. It's a continuation of the changes that contains, e.g.
dcc02c19cc06("sata_sil24: usedma_set_mask_and_coherent").I understand that some people have nothing besides bikeshedding, but this patch seems fine to everybody, am I right? Can it be applied (it's independent from patch 1 anyways)?
Yes, this one seems fine to me. It would be good to get a different review though (I know hard to get reviews on ata patches...).
I will queue it for 5.17.
Signature · 2 lines
Damien Le Moal Western Digital Research
Damien Le Moal
AppliedRe: [PATCH v1 2/2] ata: libahci_platform: Remove bogus 32-bit DMA mask attempt
In reply to Andy ShevchenkoQuoted 20 lines · Andy Shevchenko
If 64-bit mask attempt fails, the 32-bit will fail by the very same reason. Don't even try the latter. It's a continuation of the changes that contains, e.g.
dcc02c19cc06("sata_sil24: usedma_set_mask_and_coherent").Signed-off-by Andy Shevchenko <[email protected]>--- drivers/ata/libahci_platform.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)drivers/ata/libahci_platform.c +0
-2@@ -637,13 +637,8 @@ int ahci_platform_init_host(struct platform_device *pdev,if (hpriv->cap &HOST_CAP_64 ) { rc =dma_coerce_mask_and_coherent (dev,DMA_BIT_MASK (64 ));if (rc) { - rc =dma_coerce_mask_and_coherent (dev, -DMA_BIT_MASK (32 ));
drivers/ata/libahci_platform.c int ahci_platform_init_host(struct platform_device *pdev, · line 644
Quoted 10 lines
drivers/ata/libahci_platform.c +2
-5-if (rc) { -dev_err (dev,"Failed to enable 64-bit DMA.\n" ); -return rc; - } -dev_warn (dev,"Enable 32-bit DMA instead of 64-bit.\n" ); +dev_err (dev,"Failed to enable 64-bit DMA.\n" ); +return rc; } }
Applied to for-5.17.
For patch 1/2, waiting for you v2 restoring the irq == 0 check.
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH v1 2/2] ata: libahci_platform: Remove bogus 32-bit DMA mask attempt
Quoted 1 line · Damien Le Moal
On 12/9/21 23:59, Andy Shevchenko wrote:
...
Quoted 1 line
For patch 1/2, waiting for you v2 restoring the irq == 0 check.
Just sent a v2 of it, thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi,
Quoted 7 lines · Andy Shevchenko
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.Signed-off-by Andy Shevchenko <[email protected]>
Thanks, the series looks good to me:
for the series.
Regards,
Hans
Quoted 24 lines
--- drivers/ata/libahci_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/ata/libahci_platform.c +1
-6@@ -579,13 +579,8 @@ int ahci_platform_init_host(struct platform_device *pdev,int i, irq, n_ports, rc; irq =platform_get_irq (pdev,0 ); -if (irq <0 ) { -if (irq != -EPROBE_DEFER ) -dev_err (dev,"no irq\n" ); +if (irq <0 )return irq; - } -if (!irq) -return -EINVAL ; hpriv->irq = irq;
Quoted 5 lines · Andy Shevchenko
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.
And? IRQ0 is still returned! :-(
Quoted 11 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/ata/libahci_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/ata/libahci_platform.c +0
-0@@ -579,13 +579,8 @@ int ahci_platform_init_host(struct platform_device *pdev,int i, irq, n_ports, rc;
drivers/ata/libahci_platform.c int ahci_platform_init_host(struct platform_device *pdev, · line 588
Quoted 10 lines
drivers/ata/libahci_platform.c +1
-6irq =platform_get_irq (pdev,0 ); -if (irq <0 ) { -if (irq != -EPROBE_DEFER ) -dev_err (dev,"no irq\n" ); +if (irq <0 )return irq; - } -if (!irq) -return -EINVAL ;
This is prermature -- let's wait till my patch that stops returning IRQ0 fromplatform_get_irq() and friends gets merged....
MBR, Sergey
Quoted 9 lines · Sergey Shtylyov
Quoted 5 lines · Andy Shevchenko
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.And? IRQ0 is still returned! :-(
It should not be returned in the first place.
...
Quoted 5 lines
drivers/ata/libahci_platform.c int ahci_platform_init_host(struct platform_device *pdev, · line 588
Quoted 2 lines
drivers/ata/libahci_platform.c +0
-2-if (!irq) -return -EINVAL ;This is prermature -- let's wait till my patch that stops returning IRQ0 from
platform_get_irq()and friends gets merged....
What patch?
Does it fix platform_get_irq_optional()?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 9 lines · Andy Shevchenko
Quoted 7 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.And? IRQ0 is still returned! :-(It should not be returned in the first place.
But it still is, despite the WARN(), right?
Quoted 9 lines
...
Quoted 5 lines
drivers/ata/libahci_platform.c int ahci_platform_init_host(struct platform_device *pdev, · line 588
Quoted 2 lines
drivers/ata/libahci_platform.c +0
-2-if (!irq) -return -EINVAL ;This is prermature -- let's wait till my patch that stops returning IRQ0 from
platform_get_irq()and friends gets merged....What patch?
https://marc.info/?l=linux-kernel&m=163623041902285
Quoted 1 line
Does it fix
platform_get_irq_optional()?
Of course! :-)
MBR, Sergey
Quoted 1 line · Sergey Shtylyov
On 12/9/21 8:42 PM, Andy Shevchenko wrote:
...
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
No need to repeat this.
While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.And? IRQ0 is still returned! :-(It should not be returned in the first place.
But it still is, despite the
WARN(), right?
So, you admit that there is a code which does that? That code should be fixed first. Have you sent a patch?
...
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/ata/libahci_platform.c int ahci_platform_init_host(struct platform_device *pdev, · line 588
Quoted 2 lines
drivers/ata/libahci_platform.c +0
-2-if (!irq) -return -EINVAL ;This is prermature -- let's wait till my patch that stops returning IRQ0 from
platform_get_irq()and friends gets merged....
Quoted 7 lines
Quoted 1 line
What patch?
https://marc.info/?l=linux-kernel&m=163623041902285Quoted 1 line
Does it fix
platform_get_irq_optional()?Of course! :-)
Can you share link to lore.kernel.org, please?
It will make much easier to try and comment.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Sergey Shtylyov
On 12/9/21 8:42 PM, Andy Shevchenko wrote:
...
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Does it fix
platform_get_irq_optional()?Of course! :-)Can you share link to lore.kernel.org, please?
It will make much easier to try and comment.
For the record it does not fix platform_get_irq_optional() AFAICS.
Have you read the discussion:
https://lore.kernel.org/lkml/[email protected]/T/#u
?
Signature · 2 lines
With Best Regards, Andy Shevchenko
On 12/9/21 10:27 PM, Andy Shevchenko wrote:
[...]
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Does it fix
platform_get_irq_optional()?Of course! :-)Can you share link to lore.kernel.org, please?
It will make much easier to try and comment.For the record it does not fix
platform_get_irq_optional()AFAICS.
Again, why? My only issue is stoppping to return IRQ0 --- which it does. :-)
Quoted 3 lines
Have you read the discussion:
https://lore.kernel.org/lkml/[email protected]/T/#u
?
Yes, I have. I just don't care about it much... :-)
MBR, Sergey
On 12/9/21 10:22 PM, Andy Shevchenko wrote:
[...]
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
No need to repeat this.
While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
And? IRQ0 is still returned! :-(It should not be returned in the first place.
But it still is, despite the
WARN(), right?So, you admit that there is a code which does that?
I admit *what*?! That platfrom_get_irq() and its ilk return IRQ0 while they
shouldn't? =)
Quoted 1 line
That code should be fixed first. Have you sent a patch?
Which code?! You got me totally muddled. =)
Quoted 10 lines
...
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
drivers/ata/libahci_platform.c int ahci_platform_init_host(struct platform_device *pdev, · line 588
Quoted 2 lines
drivers/ata/libahci_platform.c +0
-2-if (!irq) -return -EINVAL ;This is prermature -- let's wait till my patch that stops returning IRQ0 from
platform_get_irq()and friends gets merged....What patch?
Quoted 8 lines
Quoted 5 lines
https://marc.info/?l=linux-kernel&m=163623041902285Quoted 1 line
Does it fix
platform_get_irq_optional()?Of course! :-)Can you share link to lore.kernel.org, please?
It will make much easier to try and comment.
I don't know how to uise it yet, and I'm a little busy with other IRQ0 issues ATM,
so I'm afraid you're on your own here...
MBR, Sergey
Quoted 1 line · Sergey Shtylyov
On 12/9/21 10:22 PM, Andy Shevchenko wrote:
...
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.And? IRQ0 is still returned! :-(
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
It should not be returned in the first place.
But it still is, despite the
WARN(), right?So, you admit that there is a code which does that?
I admit *what*?! That
platfrom_get_irq()and its ilk return IRQ0 while they
shouldn't? =)
That there is a code beneath platform_get_irq() that returns 0, yes.
Quoted 3 lines
Quoted 1 line
That code should be fixed first. Have you sent a patch?
Which code?! You got me totally muddled. =)
Above mentioned.
...
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 7 lines
Quoted 5 lines
drivers/ata/libahci_platform.c int ahci_platform_init_host(struct platform_device *pdev, · line 588
Quoted 2 lines
drivers/ata/libahci_platform.c +0
-2-if (!irq) -return -EINVAL ;This is prermature -- let's wait till my patch that stops returning IRQ0 from
platform_get_irq()and friends gets merged....What patch?
https://marc.info/?l=linux-kernel&m=163623041902285Quoted 1 line
Does it fix
platform_get_irq_optional()?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Of course! :-)Can you share link to lore.kernel.org, please?
It will make much easier to try and comment.I don't know how to uise it yet, and I'm a little busy with other IRQ0 issues ATM,
so I'm afraid you're on your own here...
lore.kernel.org is the official mailing list archive for Linux kernel work AFAIU. Other sites may do whatever they want with that information, so --> they are unreliable. If you wish to follow the better process, use lore.kernel.org. Understanding how it works takes no more than 5 minutes by engineer with your kind of experience with Linux kernel development.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hello!
Quoted 7 lines · Andy Shevchenko
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.And? IRQ0 is still returned! :-(It should not be returned in the first place.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
But it still is, despite the
WARN(), right?So, you admit that there is a code which does that?
I admit *what*?! That
platfrom_get_irq()and its ilk return IRQ0 while they
shouldn't? =)That there is a code beneath
platform_get_irq()that returns 0, yes.
Look at the ACPI-specific GpioInt handling code (just above the out_not_found label) --
I'm not sure the check there is correct -- I'm not very familiar with ACPI, you seem to know it much better. :-)
Also, 0 can be specified via the normal IRQ resource. I know of e.g. the Alchemy MIPS SoCs
that have IRQ0 used by UART0; luckily, currently SoC IRQs are mapped starting at Linux IRQ8 (but it wasn't the case in the 2.6.1x time frame where we had issue with the serial driver)...
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
That code should be fixed first. Have you sent a patch?
Which code?! You got me totally muddled. =)
Above mentioned.
What needs to be fixed in this case is the interrupt controller driver. Quoting Linus
(imprecisely :-)), IRQ #s should be either mapped starting with #1 or IRQ0 remapped at the end of the controller's interrupt range... I currently have no information on the platforms requiring such kind of fixing (Alchemy don't seem to need it now)...
Quoted 12 lines
...
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +0
-2- if (!irq) - return -EINVAL;This is prermature -- let's wait till my patch that stops returning IRQ0 from
platform_get_irq()and friends gets merged....What patch?
https://marc.info/?l=linux-kernel&m=163623041902285
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Does it fix
platform_get_irq_optional()?Of course! :-)Can you share link to lore.kernel.org, please?
It will make much easier to try and comment.I don't know how to uise it yet, and I'm a little busy with other IRQ0 issues ATM,
A little bit, I meant to type.
Quoted 7 lines
Quoted 1 line
so I'm afraid you're on your own here...
lore.kernel.org is the official mailing list archive for Linux kernel work AFAIU. Other sites may do whatever they want with that information, so --> they are unreliable. If you wish to follow the better process, use lore.kernel.org. Understanding how it works takes no more than 5 minutes by engineer with your kind of experience with Linux kernel development.
OK, I'll explore this archive when I have time. BTW, does it keep the messages not
posted to LKML (I tend to only CC LKML if there's no other mailing lists to post to)?
MBR, Sergey
Quoted 13 lines · Sergey Shtylyov
Quoted 11 lines · Andy Shevchenko
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.And? IRQ0 is still returned! :-(It should not be returned in the first place.
But it still is, despite the
WARN(), right?So, you admit that there is a code which does that?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I admit *what*?! That
platfrom_get_irq()and its ilk return IRQ0 while they
shouldn't? =)That there is a code beneath
platform_get_irq()that returns 0, yes.Look at the ACPI-specific GpioInt handling code (just above the
out_not_foundlabel) --
I'm not sure the check there is correct -- I'm not very familiar with ACPI, you seem to know it much better. :-)
And what is your point here exactly? If == 0 case happens, it will be immediately WARN() and reported (I hope) since it will mean bug in the code.
Quoted 3 lines
Also, 0 can be specified via the normal IRQ resource. I know of e.g. the Alchemy MIPS SoCs
that have IRQ0 used by UART0; luckily, currently SoC IRQs are mapped starting at Linux IRQ8 (but it wasn't the case in the 2.6.1x time frame where we had issue with the serial driver)...
You mixed up HW IRQ with vIRQ. The former one may be 0 and it's completely valid case, while the second one is not.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
That code should be fixed first. Have you sent a patch?
Which code?! You got me totally muddled. =)
Above mentioned.
What needs to be fixed in this case is the interrupt controller driver.
What do you mean by that? vIRQ is handled by IRQ core, IRQ controller driver just a mere provider of the resource. And those exceptions for vIRQ == 0 shouldn't be propagated to the platform code or so.
Quoted 4 lines
Quoting Linus
(imprecisely :-)), IRQ #s should be either mapped starting with #1 or IRQ0 remapped at the end of the controller's interrupt range... I currently have no information on the platforms requiring such kind of fixing (Alchemy don't seem to need it now)...
Again, do not mix vIRQ (about which Linus ranted) and HW IRQ.
...
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 7 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +0
-2- if (!irq) - return -EINVAL;This is prermature -- let's wait till my patch that stops returning IRQ0 from
platform_get_irq()and friends gets merged....What patch?
https://marc.info/?l=linux-kernel&m=163623041902285Quoted 1 line
Does it fix
platform_get_irq_optional()?
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Of course! :-)Can you share link to lore.kernel.org, please?
It will make much easier to try and comment.I don't know how to uise it yet, and I'm a little busy with other IRQ0 issues ATM,
A little bit, I meant to type.
No problem. I just haven't got what other IRQ0 issues except fixing platform_get_irq_optional() et al. could be possibly needed...
Quoted 10 lines
Quoted 7 lines
Quoted 1 line
so I'm afraid you're on your own here...
lore.kernel.org is the official mailing list archive for Linux kernel work AFAIU. Other sites may do whatever they want with that information, so --> they are unreliable. If you wish to follow the better process, use lore.kernel.org. Understanding how it works takes no more than 5 minutes by engineer with your kind of experience with Linux kernel development.
OK, I'll explore this archive when I have time. BTW, does it keep the messages not
posted to LKML (I tend to only CC LKML if there's no other mailing lists to post to)?
TL;DR: yes.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 14 lines · Andy Shevchenko
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.And? IRQ0 is still returned! :-(It should not be returned in the first place.
But it still is, despite the
WARN(), right?So, you admit that there is a code which does that?
I admit *what*?! That
platfrom_get_irq()and its ilk return IRQ0 while they
shouldn't? =)
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
That there is a code beneath
platform_get_irq()that returns 0, yes.Look at the ACPI-specific GpioInt handling code (just above the
out_not_foundlabel) --
I'm not sure the check there is correct -- I'm not very familiar with ACPI, you seem to know it much better. :-)And what is your point here exactly?
You're saying IRQ0 shouldn't be returned (by the ACPI code) -- from this fragment
we can see that it may be returned...
Quoted 2 lines
If == 0 case happens, it will be
immediatelyWARN()and reported (I hope)
Well, "hope dies last"... :-)
Quoted 7 lines
since it will mean bug in the code.
Quoted 3 lines
Also, 0 can be specified via the normal IRQ resource. I know of e.g. the Alchemy MIPS SoCs
that have IRQ0 used by UART0; luckily, currently SoC IRQs are mapped starting at Linux IRQ8 (but it wasn't the case in the 2.6.1x time frame where we had issue with the serial driver)...You mixed up HW IRQ with vIRQ.
I didn't. Linux expects the vIRQs (I called them Linux IRQs). In the 2.6.1x time frame
those corresponded 1:1 on Alchemy. Also, there's 8259 which is always mapped at vIRQ0 (or the legacy drivers won't work).
Quoted 2 lines
The former one may be 0 and it's completely valid case, while the second one is not.
Well, request_irq() happilly takes vIRQ0. Moreover, there are 8253 drivers in e.g. the arch/x86/
(PPC and MIPS too) which do use vIRQ0.
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
That code should be fixed first. Have you sent a patch?
Which code?! You got me totally muddled. =)
Above mentioned.
What needs to be fixed in this case is the interrupt controller driver.
What do you mean by that?
You better ask Linus... ;-)
Quoted 8 lines
vIRQ is handled by IRQ core, IRQ controller driver
just a mere provider of the resource. And those exceptions for vIRQ == 0 shouldn't be propagated to the platform code or so.Quoted 4 lines
Quoting Linus
(imprecisely :-)), IRQ #s should be either mapped starting with #1 or IRQ0 remapped at the end of the controller's interrupt range... I currently have no information on the platforms requiring such kind of fixing (Alchemy don't seem to need it now)...
Well, actually that Linus' quote predates drivers/irqchip/, so I must confess this
argument was wrong... :-)
Quoted 21 lines
Again, do not mix vIRQ (about which Linus ranted) and HW IRQ.
...
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +0
-2- if (!irq) - return -EINVAL;This is prermature -- let's wait till my patch that stops returning IRQ0 from
platform_get_irq()and friends gets merged....Quoted 7 lines
Quoted 1 line
What patch?
https://marc.info/?l=linux-kernel&m=163623041902285Quoted 1 line
Does it fix
platform_get_irq_optional()?Of course! :-)Can you share link to lore.kernel.org, please?
It will make much easier to try and comment.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
I don't know how to uise it yet, and I'm a little busy with other IRQ0 issues ATM,
A little bit, I meant to type.
No problem. I just haven't got what other IRQ0 issues except fixing
platform_get_irq_optional()et al. could be possibly needed...
There is other IRQ0 issue which is very old already...
[...]
MBR, Sergey
Quoted 18 lines · Sergey Shtylyov
Quoted 16 lines · Andy Shevchenko
Quoted 16 lines
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.And? IRQ0 is still returned! :-(Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
It should not be returned in the first place.
But it still is, despite the
WARN(), right?So, you admit that there is a code which does that?
I admit *what*?! That
platfrom_get_irq()and its ilk return IRQ0 while they
shouldn't? =)That there is a code beneath
platform_get_irq()that returns 0, yes.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Look at the ACPI-specific GpioInt handling code (just above the
out_not_foundlabel) --
I'm not sure the check there is correct -- I'm not very familiar with ACPI, you seem to know it much better. :-)And what is your point here exactly?
You're saying IRQ0 shouldn't be returned (by the ACPI code) -- from this fragment
we can see that it may be returned...
Please, provide your analysis, I really don't see how it's possible. If you prove that, we must fix the severe bug then.
Quoted 4 lines
Quoted 2 lines
If == 0 case happens, it will be
immediatelyWARN()and reported (I hope)Well, "hope dies last"... :-)
Believe, big WARNs are quite likely to be reported if not by humans, then by CIs and fuzzers. So, the hope is rather to word 'immediately'.
Quoted 12 lines
Quoted 7 lines
since it will mean bug in the code.
Quoted 3 lines
Also, 0 can be specified via the normal IRQ resource. I know of e.g. the Alchemy MIPS SoCs
that have IRQ0 used by UART0; luckily, currently SoC IRQs are mapped starting at Linux IRQ8 (but it wasn't the case in the 2.6.1x time frame where we had issue with the serial driver)...You mixed up HW IRQ with vIRQ.
I didn't. Linux expects the vIRQs (I called them Linux IRQs). In the 2.6.1x time frame
those corresponded 1:1 on Alchemy. Also, there's 8259 which is always mapped at vIRQ0 (or the legacy drivers won't work).
Quoted 5 lines
Quoted 2 lines
The former one may be 0 and it's completely valid case, while the second one is not.
Well,
request_irq()happilly takes vIRQ0. Moreover, there are 8253 drivers in e.g. thearch/x86/
(PPC and MIPS too) which do use vIRQ0.
This is an exception which is not in the scope here. Let me remind that the topic here is libahci_platform and platform_get_irq().
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
That code should be fixed first. Have you sent a patch?
Which code?! You got me totally muddled. =)
Above mentioned.
What needs to be fixed in this case is the interrupt controller driver.
What do you mean by that?
You better ask Linus... ;-)
If you cite somebody you have to understand what they said, right? Lemme repeat the question, what do you mean by that? In your own words, please.
Quoted 13 lines
Quoted 8 lines
vIRQ is handled by IRQ core, IRQ controller driver
just a mere provider of the resource. And those exceptions for vIRQ == 0 shouldn't be propagated to the platform code or so.Quoted 4 lines
Quoting Linus
(imprecisely :-)), IRQ #s should be either mapped starting with #1 or IRQ0 remapped at the end of the controller's interrupt range... I currently have no information on the platforms requiring such kind of fixing (Alchemy don't seem to need it now)...Well, actually that Linus' quote predates
drivers/irqchip/, so I must confess this
argument was wrong... :-)Quoted 1 line
Again, do not mix vIRQ (about which Linus ranted) and HW IRQ.
...
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +0
-2- if (!irq) - return -EINVAL;This is prermature -- let's wait till my patch that stops returning IRQ0 from
platform_get_irq()and friends gets merged....Quoted 7 lines
Quoted 1 line
What patch?
https://marc.info/?l=linux-kernel&m=163623041902285Quoted 1 line
Does it fix
platform_get_irq_optional()?Of course! :-)Can you share link to lore.kernel.org, please?
It will make much easier to try and comment.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
I don't know how to uise it yet, and I'm a little busy with other IRQ0 issues ATM,
A little bit, I meant to type.
No problem. I just haven't got what other IRQ0 issues except fixing
platform_get_irq_optional()et al. could be possibly needed...There is other IRQ0 issue which is very old already...
Is it big secret? What is that issue?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 5 lines · Andy Shevchenko
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.
The reason you should be able to remove the "if (!irq)" test is that platform_get_irq() never returns 0. At least, that is what the function kdoc says. But looking at platform_get_irq_optional(), which is called by platform_get_irq(), the out label is:
WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;
So 0 will be returned as-is. That is rather weird. That should be fixed to return -ENXIO:
if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Quoted 25 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/ata/libahci_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/ata/libahci_platform.c +1
-6@@ -579,13 +579,8 @@ int ahci_platform_init_host(struct platform_device *pdev,int i, irq, n_ports, rc; irq =platform_get_irq (pdev,0 ); -if (irq <0 ) { -if (irq != -EPROBE_DEFER ) -dev_err (dev,"no irq\n" ); +if (irq <0 )return irq; - } -if (!irq) -return -EINVAL ; hpriv->irq = irq;
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 15 lines · Damien Le Moal
Quoted 5 lines · Andy Shevchenko
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;
Quoted 8 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Replying to myself :)
I replied before reading Sergei replies that points this out.
Quoted 28 lines
Quoted 26 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/ata/libahci_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/ata/libahci_platform.c +1
-6@@ -579,13 +579,8 @@ int ahci_platform_init_host(struct platform_device *pdev,int i, irq, n_ports, rc; irq =platform_get_irq (pdev,0 ); -if (irq <0 ) { -if (irq != -EPROBE_DEFER ) -dev_err (dev,"no irq\n" ); +if (irq <0 )return irq; - } -if (!irq) -return -EINVAL ; hpriv->irq = irq;
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 12 lines · Damien Le Moal
Quoted 5 lines · Andy Shevchenko
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:
Quoted 8 lines
WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO;
No, this is wrong for the same reasons I explained to Sergey. The problem is that this is _optional API and it has been misdesigned. Replacing things like above will increase the mess.
Quoted 3 lines
return ret;Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
No. This is not a business of the caller to workaround implementation details (bugs) of the core APIs.
If something goes wrong, then it's platform_get_irq() to blame, and not the libahci_platform.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 11 lines · Andy Shevchenko
Quoted 11 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:
Quoted 8 lines
Quoted 8 lines
WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO;
-ENXIO seems to me more fitting indeed (than -EINVAL that I used).
Quoted 2 lines
No, this is wrong for the same reasons I explained to Sergey.
I fail to understand you, sorry. We're going in circles, it seems... :-/
Quoted 2 lines
The problem is that this is
_optionalAPI and it has been misdesigned. Replacing things like above will increase the mess.
What's wrong with replacing IRQ0 with -ENXIO now? platform_get_irq_optional()
(as in your patch) could then happily return 0 ISO -ENXIO. Contrarywise, if we don't replace IRQ0 with -ENXIO, platform_get_irq_optional() will return 0 for both IRQ0 and missing IRQ! Am I clear enough? If you don't understand me now, I don't know what to say... :-/
Quoted 9 lines
Quoted 4 lines
return ret;Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
No. This is not a business of the caller to workaround implementation details (bugs) of the core APIs.
If something goes wrong, then it'splatform_get_irq()to blame, and not thelibahci_platform.
I'm repeating myself already: we don't work around the bug in platform_get_irq(),
we're working around the driver subsystems that treat 0 specially (and so don't support IRQ0); libata treats 0 as an indication of the polling mode (moreover, it will curse if you pass to it both IRQ == 0 and a pointer to an interrupt handler! Am I clear enough this time? :-)
MBR, Sergey
Quoted 22 lines · Sergey Shtylyov
Quoted 11 lines · Andy Shevchenko
Quoted 11 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:Quoted 8 lines
Quoted 8 lines
WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO;
Quoted 6 lines
-ENXIOseems to me more fitting indeed (than-EINVALthat I used).Quoted 2 lines
No, this is wrong for the same reasons I explained to Sergey.
I fail to understand you, sorry. We're going in circles, it seems... :-/
platform_get_irq_optional() is supposed to return 0 when there is no IRQ found, but everything else went alright.
I'm tired to waste my time to go circles.
Again, the problem is that platform_get_irq_optional() has wrong set of output values. And your patch doesn't fix that. And it has nothing to do with my code here.
Quoted 8 lines
Quoted 2 lines
The problem is that this is
_optionalAPI and it has been misdesigned. Replacing things like above will increase the mess.What's wrong with replacing IRQ0 with
-ENXIOnow?platform_get_irq_optional()
(as in your patch) could then happily return 0 ISO-ENXIO. Contrarywise, if we don't replace IRQ0 with-ENXIO,platform_get_irq_optional()will return 0 for both IRQ0 and missing IRQ! Am I clear enough? If you don't understand me now, I don't know what to say... :-/
See above. Read my messages again, please. I'm really tired to explain again and again the same.
TL;DR: You simply try to "fix" in a correct place but in a wrong way.
Quoted 10 lines
Quoted 8 lines
Quoted 3 lines
return ret;Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
No. This is not a business of the caller to workaround implementation details (bugs) of the core APIs.
If something goes wrong, then it'splatform_get_irq()to blame, and not thelibahci_platform.I'm repeating myself already: we don't work around the bug in
platform_get_irq(),
Yes, you do.
Quoted 4 lines
we're working around the driver subsystems that treat 0 specially (and so don't support IRQ0); libata treats 0 as an indication of the polling mode (moreover, it will curse if you pass to it both IRQ == 0 and a pointer to an interrupt handler! Am I clear enough this time? :-)
Yes, and it doesn't contradict to what my patch does. Read comment against platform_get_irq(). If it returns 0, it's not a business of the callers to work around it.
Am I clear enough this time? :-)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 14 lines · Damien Le Moal
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;
Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;
My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns -EINVAL instead.
Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Of course it isn't...
Quoted 1 line
Quoted 1 line
Signed-off-by Andy Shevchenko <[email protected]>
[...]
MBR, Sergey
Quoted 23 lines · Sergey Shtylyov
Quoted 14 lines · Damien Le Moal
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;
Quoted 6 lines
My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Of course it isn't...
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls. If it is the case, go and fix them, no need to workaround in each of the callers.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 24 lines · Andy Shevchenko
Quoted 24 lines
Quoted 14 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Of course it isn't...
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls.
We do _not_ know what needs to be fixed, that's the problem, and that's why the WARN()
is there...
Quoted 2 lines
If it is the case, go and fix them, no need to workaround in each of the callers.
There's a need to work around as long as IRQ0 ican be returned, otherwise we get
partly functioning or non-functioning drivers...
MBR, Sergey
Quoted 28 lines · Sergey Shtylyov
Quoted 26 lines · Andy Shevchenko
Quoted 26 lines
Quoted 14 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Of course it isn't...
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls.
We do _not_ know what needs to be fixed, that's the problem, and that's why the
WARN()
is there...
So, have you seen this warning (being reported) related to libahci_platform? If no, what we are discussing about then? The workaround is redundant and no need to have a dead code in the driver, really.
Quoted 5 lines
Quoted 2 lines
If it is the case, go and fix them, no need to workaround in each of the callers.
There's a need to work around as long as IRQ0 ican be returned, otherwise we get partly functioning or non-functioning drivers...
You get them unfunctioning anyways and you get the big WARN() even before this patch.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 28 lines · Andy Shevchenko
Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 14 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Of course it isn't...
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls.
We do _not_ know what needs to be fixed, that's the problem, and that's why the
WARN()
is there...So, have you seen this warning (being reported) related to
libahci_platform?
No (as if you need to really see this while it's obvious from the code review).
Quoted 1 line
If no, what we are discussing about then? The workaround is redundant and
I don't know. :-) Your arguments so far seem bogus (sorry! :-))...
Quoted 1 line
no need to have a dead code in the driver, really.
"Jazz isn't dead, it just smells funny". :-)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
If it is the case, go and fix them, no need to workaround in each of the callers.
There's a need to work around as long as IRQ0 ican be returned, otherwise we get partly functioning or non-functioning drivers...
You get them unfunctioning anyways
The drivers would be broken in not quite obvious ways. With IRQ0 check, they just
don't probe anymore. See the explanation of the IRQ0 check (in the drivers) in my previous mail...
Quoted 1 line
and you get the big
WARN()even before this patch.
As if that was enough...
The IRQ0 problem exists for at least 15 (if not 20) years...
MBR, Sergey
Quoted 36 lines · Sergei Shtylyov
Quoted 34 lines · Andy Shevchenko
Quoted 33 lines
Quoted 24 lines
Quoted 24 lines
Quoted 14 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Of course it isn't...
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls.
We do _not_ know what needs to be fixed, that's the problem, and that's why the
WARN()
is there...
Quoted 7 lines
Quoted 1 line
So, have you seen this warning (being reported) related to
libahci_platform?No (as if you need to really see this while it's obvious from the code review).
Quoted 1 line
If no, what we are discussing about then? The workaround is redundant and
I don't know. :-) Your arguments so far seem bogus (sorry! :-))...
It seems you haven't got them at all. The problems of platform_get_irq() et al shouldn't be worked around in the callers.
Quoted 20 lines
Quoted 1 line
no need to have a dead code in the driver, really.
"Jazz isn't dead, it just smells funny". :-)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
If it is the case, go and fix them, no need to workaround in each of the callers.
There's a need to work around as long as IRQ0 ican be returned, otherwise we get partly functioning or non-functioning drivers...
You get them unfunctioning anyways
The drivers would be broken in not quite obvious ways. With IRQ0 check, they just
don't probe anymore. See the explanation of the IRQ0 check (in the drivers) in my previous mail...Quoted 1 line
and you get the big
WARN()even before this patch.As if that was enough...
The IRQ0 problem exists for at least 15 (if not 20) years...
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 36 lines · Andy Shevchenko
Quoted 36 lines
Quoted 35 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 14 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Of course it isn't...
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls.
We do _not_ know what needs to be fixed, that's the problem, and that's why the
WARN()
is there...So, have you seen this warning (being reported) related to
libahci_platform?
Quoted 8 lines
Quoted 5 lines
No (as if you need to really see this while it's obvious from the code review).
Quoted 1 line
If no, what we are discussing about then? The workaround is redundant and
I don't know. :-) Your arguments so far seem bogus (sorry! :-))...
It seems you haven't got them at all. The problems of
platform_get_irq()et al shouldn't be worked around in the callers.
I have clearly explained to you what I'm working around there. If that wasn't clear
enough, I don't want to continue this talk anymore. Good luck with your patch (not this one).
[...]
MBR, Sergey
Quoted 42 lines · Sergey Shtylyov
Quoted 40 lines · Andy Shevchenko
Quoted 40 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 14 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Of course it isn't...
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls.
We do _not_ know what needs to be fixed, that's the problem, and that's why the
WARN()
is there...So, have you seen this warning (being reported) related to
libahci_platform?No (as if you need to really see this while it's obvious from the code review).
Quoted 1 line
If no, what we are discussing about then? The workaround is redundant and
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
I don't know. :-) Your arguments so far seem bogus (sorry! :-))...
It seems you haven't got them at all. The problems of
platform_get_irq()et al shouldn't be worked around in the callers.I have clearly explained to you what I'm working around there. If that wasn't clear
enough, I don't want to continue this talk anymore. Good luck with your patch (not this one).
Good luck with yours, not the one that touches platform_get_irq_optional() though!
Signature · 2 lines
With Best Regards, Andy Shevchenko
On 12/10/21 10:25 PM, Andy Shevchenko wrote:
[...]
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 14 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Of course it isn't...
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls.
We do _not_ know what needs to be fixed, that's the problem, and that's why the
WARN()
is there...So, have you seen this warning (being reported) related to
libahci_platform?No (as if you need to really see this while it's obvious from the code review).
Quoted 1 line
If no, what we are discussing about then? The workaround is redundant and
I don't know. :-) Your arguments so far seem bogus (sorry! :-))...
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
It seems you haven't got them at all. The problems of
platform_get_irq()et al shouldn't be worked around in the callers.I have clearly explained to you what I'm working around there. If that wasn't clear
enough, I don't want to continue this talk anymore. Good luck with your patch (not this one).Good luck with yours, not the one that touches
platform_get_irq_optional()though!
Mmh, I'm not touching it any way that would break what your patch was trying to do,
unless you've re-thopught that. It also shoudn't matter whose patch gets merged 1st other than some small adaptation).
MBR, Sergey
On 12/10/21 10:30 PM, Sergey Shtylyov wrote:
[...]
Quoted 49 lines
Quoted 49 lines
Quoted 48 lines
Quoted 36 lines
Quoted 36 lines
Quoted 35 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 14 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Of course it isn't...
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls.
We do _not_ know what needs to be fixed, that's the problem, and that's why the
WARN()
is there...So, have you seen this warning (being reported) related to
libahci_platform?Quoted 8 lines
Quoted 5 lines
No (as if you need to really see this while it's obvious from the code review).
Quoted 1 line
If no, what we are discussing about then? The workaround is redundant and
I don't know. :-) Your arguments so far seem bogus (sorry! :-))...
It seems you haven't got them at all. The problems of
platform_get_irq()et al shouldn't be worked around in the callers.I have clearly explained to you what I'm working around there. If that wasn't clear
enough, I don't want to continue this talk anymore. Good luck with your patch (not this one).
Quoted 5 lines
Quoted 1 line
Good luck with yours, not the one that touches
platform_get_irq_optional()though!Mmh, I'm not touching it any way that would break what your patch was trying to do,
unless you've re-thopught that. It also shoudn't matter whose patch gets merged 1st other than some small adaptation).
BTW, looking at [1], this comment is wrong:
+ * Return: non-zero IRQ number on success, negative error number on failure.
It doesn't mention 0 which you return from this function.
MBR, Sergey
On 10.12.2021 22:35, Sergei Shtylyov wrote:
[...]
Quoted 55 lines
Quoted 49 lines
Quoted 49 lines
Quoted 48 lines
Quoted 36 lines
Quoted 36 lines
Quoted 35 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 14 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does thisbut returns
-EINVALinstead.Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Of course it isn't...
It's unsubstantiated statement. The vIRQ 0 shouldn't be returned by any of those API calls.
We do _not_ know what needs to be fixed, that's the problem, and that's why the
WARN()
is there...So, have you seen this warning (being reported) related to
libahci_platform?Quoted 8 lines
Quoted 5 lines
No (as if you need to really see this while it's obvious from the code review).
Quoted 1 line
If no, what we are discussing about then? The workaround is redundant and
I don't know. :-) Your arguments so far seem bogus (sorry! :-))...
It seems you haven't got them at all. The problems of
platform_get_irq()et al shouldn't be worked around in the callers.I have clearly explained to you what I'm working around there. If that wasn't clear
enough, I don't want to continue this talk anymore. Good luck with your patch (not this one).Quoted 5 lines
Quoted 1 line
Good luck with yours, not the one that touches
platform_get_irq_optional()though!Mmh, I'm not touching it any way that would break what your patch was trying to do,
unless you've re-thopught that. It also shoudn't matter whose patch gets merged 1st other than some small adaptation).
Quoted 5 lines
BTW, looking at [1], this comment is wrong:
+ * Return: non-zero IRQ number on success, negative error number on failure.
It doesn't mention 0 which you return from this function.
Also, your commit log is wrong in the description of how to handle the result:
<<
Now:
ret = platform_get_irq_optional(...); if (ret != -ENXIO) return ret; // respect deferred probe if (ret > 0) ...we get an IRQ...
Quoted 1 line
Quoted 1 line
The (ret != -ENXIO) check also succeeds on the (positive) IRQ #s, so the
following code becomes unreachable. :-/
Quoted 1 line
MBR, Sergey
Quoted 1 line · Sergey Shtylyov
On 10.12.2021 22:35, Sergei Shtylyov wrote:
...
Quoted 11 lines
Also, your commit log is wrong in the description of how to handle the result:
<<
Now:ret = platform_get_irq_optional(...); if (ret != -ENXIO) return ret; // respect deferred probe if (ret > 0) ...we get an IRQ...Quoted 1 line
Quoted 1 line
Quoted 2 lines
The (ret !=
-ENXIO) check also succeeds on the (positive) IRQ #s, so the
following code becomes unreachable. :-/
Indeed, thanks!
Should be
if (ret < 0 && ret != -ENXIO)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 19 lines · Sergey Shtylyov
Quoted 17 lines · Damien Le Moal
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:
Quoted 6 lines
Quoted 3 lines
if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.
Thinking more about this, shouldn't this change go into platform_get_irq() instead of platform_get_irq_optional() ?
The way I see it, I think that the intended behavior for platform_get_irq_optional() is:
1) If have IRQ, return it, always > 0
2) If no IRQ, return 0
3) If error, return < 0
no ?
And for platform_get_irq(), case (2) becomes an error.
Is this the intended semantic ?
I am really not sure here as the functions kdoc description and the code do not match. Which one is correct ?
Quoted 9 lines
Quoted 2 lines
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Of course it isn't...
Quoted 1 line
Quoted 1 line
Signed-off-by Andy Shevchenko <[email protected]>[...]
MBR, Sergey
Signature · 2 lines
Damien Le Moal Western Digital Research
Hello!
On 11.12.2021 2:45, Damien Le Moal wrote:
[...]
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;
Quoted 5 lines
Quoted 2 lines
My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does thisbut returns
-EINVALinstead.Thinking more about this, shouldn't this change go into
platform_get_irq()instead ofplatform_get_irq_optional()?
Why? platform_get_irq() currently just calls platform_get_irq_optional()...
Quoted 4 lines
The way I see it, I think that the intended behavior for
platform_get_irq_optional()is:
1) If have IRQ, return it, always > 0
2) If no IRQ, return 0
That does include the IRQ0 case, right?
Quoted 2 lines
3) If error, return < 0
no ?
I completely agree, I (after thinking a bit) have no issues with that...
Quoted 2 lines
And for
platform_get_irq(), case (2) becomes an error. Is this the intended semantic ?
I don't see how it's different from the current behavior. But we can do
that as well, I just don't see whether it's really better...
Quoted 2 lines
I am really not sure here as the functions kdoc description and the code do not match. Which one is correct ?
It seems both are wrong. :-)
[...]
MBR, Sergey
Quoted 32 lines · Sergey Shtylyov
Hello!
On 11.12.2021 2:45, Damien Le Moal wrote:
[...]
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;Quoted 5 lines
Quoted 2 lines
My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does thisbut returns
-EINVALinstead.Thinking more about this, shouldn't this change go into
platform_get_irq()instead ofplatform_get_irq_optional()?
Quoted 8 lines
Why?
platform_get_irq()currently just callsplatform_get_irq_optional()...Quoted 4 lines
The way I see it, I think that the intended behavior for
platform_get_irq_optional()is:
1) If have IRQ, return it, always > 0
2) If no IRQ, return 0That does include the IRQ0 case, right?
IRQ 0 being invalid, I think that case should be dealt with internally within platform_get_irq_optional() and warn/error return. IRQ 0 showing up would thus be case (3), an error.
Quoted 11 lines
Quoted 3 lines
3) If error, return < 0
no ?I completely agree, I (after thinking a bit) have no issues with that...
Quoted 2 lines
And for
platform_get_irq(), case (2) becomes an error. Is this the intended semantic ?I don't see how it's different from the current behavior. But we can do
that as well, I just don't see whether it's really better...
The problem I see is that the current behavior is unclear: what does platform_get_irq_optional() returning 0 mean ? IRQ == 0 ? or "no IRQ" ? I think it should be the latter rather than the former. Note that the function could return ENOENT (or similar) for the "no IRQ" case. With that, case (2) goes away, but then I do not see any difference between platform_get_irq_optional() and platform_get_irq().
If the preferred API semantic is to allow returning IRQ 0 with a warning, then the kdoc comments of platform_get_irq_optional() and platform_get_irq() are totally broken, and the code for many drivers is probably wrong too.
Quoted 9 lines
Quoted 3 lines
I am really not sure here as the functions kdoc description and the code do not match. Which one is correct ?
It seems both are wrong. :-)
[...]
MBR, Sergey
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 2 lines · Damien Le Moal
Quoted 1 line · Sergey Shtylyov
On 11.12.2021 2:45, Damien Le Moal wrote:
...
Quoted 45 lines
Quoted 13 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;Quoted 5 lines
Quoted 2 lines
My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does thisbut returns
-EINVALinstead.Thinking more about this, shouldn't this change go into
platform_get_irq()instead ofplatform_get_irq_optional()?Quoted 8 lines
Why?
platform_get_irq()currently just callsplatform_get_irq_optional()...Quoted 4 lines
The way I see it, I think that the intended behavior for
platform_get_irq_optional()is:
1) If have IRQ, return it, always > 0
2) If no IRQ, return 0That does include the IRQ0 case, right?
IRQ 0 being invalid, I think that case should be dealt with internally within
platform_get_irq_optional()and warn/error return. IRQ 0 showing up would thus be case (3), an error.Quoted 11 lines
Quoted 3 lines
3) If error, return < 0
no ?I completely agree, I (after thinking a bit) have no issues with that...
Quoted 2 lines
And for
platform_get_irq(), case (2) becomes an error. Is this the intended semantic ?I don't see how it's different from the current behavior. But we can do
that as well, I just don't see whether it's really better...The problem I see is that the current behavior is unclear: what does
platform_get_irq_optional()returning 0 mean ? IRQ == 0 ? or "no IRQ" ? I think it should be the latter rather than the former. Note that the function could return ENOENT (or similar) for the "no IRQ" case. With that, case (2) goes away, but then I do not see any difference betweenplatform_get_irq_optional()andplatform_get_irq().
Quoted 3 lines
If the preferred API semantic is to allow returning IRQ 0 with a warning, then the kdoc comments of
platform_get_irq_optional()andplatform_get_irq()are totally broken, and the code for many drivers is probably wrong too.
Yeah, what we need to do is that (roughly a roadmap):
- revisit callers of platform_get_irq_optional() to be prepared for new behaviour
- rewrite platform_get_irq() to return -ENOENT
- rewrite platform_get_irq_optional() to return 0 on -ENOENT
This is how other similar (i.e. _optional) APIs do.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 55 lines · Andy Shevchenko
Quoted 2 lines · Damien Le Moal
Quoted 1 line · Sergey Shtylyov
On 11.12.2021 2:45, Damien Le Moal wrote:
...
Quoted 45 lines
Quoted 13 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;Quoted 5 lines
Quoted 2 lines
My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does thisbut returns
-EINVALinstead.Thinking more about this, shouldn't this change go into
platform_get_irq()instead ofplatform_get_irq_optional()?Quoted 8 lines
Why?
platform_get_irq()currently just callsplatform_get_irq_optional()...Quoted 4 lines
The way I see it, I think that the intended behavior for
platform_get_irq_optional()is:
1) If have IRQ, return it, always > 0
2) If no IRQ, return 0That does include the IRQ0 case, right?
IRQ 0 being invalid, I think that case should be dealt with internally within
platform_get_irq_optional()and warn/error return. IRQ 0 showing up would thus be case (3), an error.Quoted 11 lines
Quoted 3 lines
3) If error, return < 0
no ?I completely agree, I (after thinking a bit) have no issues with that...
Quoted 2 lines
And for
platform_get_irq(), case (2) becomes an error. Is this the intended semantic ?I don't see how it's different from the current behavior. But we can do
that as well, I just don't see whether it's really better...The problem I see is that the current behavior is unclear: what does
platform_get_irq_optional()returning 0 mean ? IRQ == 0 ? or "no IRQ" ? I think it should be the latter rather than the former. Note that the function could return ENOENT (or similar) for the "no IRQ" case. With that, case (2) goes away, but then I do not see any difference betweenplatform_get_irq_optional()andplatform_get_irq().Quoted 3 lines
If the preferred API semantic is to allow returning IRQ 0 with a warning, then the kdoc comments of
platform_get_irq_optional()andplatform_get_irq()are totally broken, and the code for many drivers is probably wrong too.
Quoted 7 lines
Yeah, what we need to do is that (roughly a roadmap):
- revisit callers ofplatform_get_irq_optional()to be prepared for new behaviour
- rewriteplatform_get_irq()to return-ENOENT
- rewriteplatform_get_irq_optional()to return 0 on-ENOENTThis is how other similar (i.e.
_optional) APIs do.
Sounds like a good plan to me. In the mean time though, your patch 1/2 should keep the "if (!irq)" test and return an error for that case. No ?
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 3 lines · Damien Le Moal
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Damien Le Moal
On 2021/12/11 19:25, Sergey Shtylyov wrote:
...
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
The problem I see is that the current behavior is unclear: what does
platform_get_irq_optional()returning 0 mean ? IRQ == 0 ? or "no IRQ" ? I think it should be the latter rather than the former. Note that the function could return ENOENT (or similar) for the "no IRQ" case. With that, case (2) goes away, but then I do not see any difference betweenplatform_get_irq_optional()andplatform_get_irq().If the preferred API semantic is to allow returning IRQ 0 with a warning, then the kdoc comments of
platform_get_irq_optional()andplatform_get_irq()are totally broken, and the code for many drivers is probably wrong too.Yeah, what we need to do is that (roughly a roadmap):
- revisit callers ofplatform_get_irq_optional()to be prepared for new behaviour
- rewriteplatform_get_irq()to return-ENOENT
- rewriteplatform_get_irq_optional()to return 0 on-ENOENT
Quoted 4 lines
Quoted 1 line
This is how other similar (i.e.
_optional) APIs do.Sounds like a good plan to me. In the mean time though, your patch 1/2 should keep the "if (!irq)" test and return an error for that case. No ?
No problem. I can send a v2.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 1 line · Sergey Shtylyov
On 11.12.2021 2:45, Damien Le Moal wrote:
...
Quoted 27 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;Quoted 5 lines
Quoted 2 lines
My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does thisbut returns
-EINVALinstead.Thinking more about this, shouldn't this change go into
platform_get_irq()instead ofplatform_get_irq_optional()?
Quoted 8 lines
Why?
platform_get_irq()currently just callsplatform_get_irq_optional()...Quoted 4 lines
The way I see it, I think that the intended behavior for
platform_get_irq_optional()is:
1) If have IRQ, return it, always > 0
2) If no IRQ, return 0That does include the IRQ0 case, right?
What IRQ0 case? We do not expect platform APIs ever to handle vIRQ0 (mind letter v) case. Platforms, where it's the case, should handle it exceptionally on per architecture basis.
Quoted 15 lines
Quoted 2 lines
3) If error, return < 0
no ?I completely agree, I (after thinking a bit) have no issues with that...
Quoted 2 lines
And for
platform_get_irq(), case (2) becomes an error. Is this the intended semantic ?I don't see how it's different from the current behavior. But we can do
that as well, I just don't see whether it's really better...Quoted 2 lines
I am really not sure here as the functions kdoc description and the code do not match. Which one is correct ?
It seems both are wrong. :-)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 30 lines · Damien Le Moal
Quoted 19 lines · Sergey Shtylyov
Quoted 17 lines · Damien Le Moal
Quoted 5 lines
platform_get_irq()will print a message when it fails. No need to repeat this.While at it, drop redundant check for 0 as
platform_get_irq()spills out a bigWARN()in such case.The reason you should be able to remove the "if (!irq)" test is that
platform_get_irq()never returns 0. At least, that is what the function kdoc says. But looking atplatform_get_irq_optional(), which is called byplatform_get_irq(), the out label is:WARN(ret == 0, "0 is an invalid IRQ number\n"); return ret;So 0 will be returned as-is. That is rather weird. That should be fixed to return
-ENXIO:Quoted 6 lines
Quoted 3 lines
if (WARN(ret == 0, "0 is an invalid IRQ number\n")) return -ENXIO; return ret;My unmerged patch (https://marc.info/?l=linux-kernel&m=163623041902285) does this
but returns-EINVALinstead.Thinking more about this, shouldn't this change go into
platform_get_irq()instead ofplatform_get_irq_optional()?
Quoted 6 lines
The way I see it, I think that the intended behavior for
platform_get_irq_optional()is:
1) If have IRQ, return it, always > 0
2) If no IRQ, return 0
3) If error, return < 0
no ?
At least this is my understanding on how it _should_ be.
Quoted 1 line
And for
platform_get_irq(), case (2) becomes an error.
Precisely!
Quoted 3 lines
Is this the intended semantic ?
I am really not sure here as the functions kdoc description and the code do not match. Which one is correct ?
The problem is that platform_get_irq_optional() doesn't follow above mentioned logic and needs to be fixed. While trying to fix that it appears that it's not an simple and 5 minutes task since it needs a revisiting of all callers first followed by rectifying the API itself.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Otherwise, I do not think that removing the "if (!irq)" hunk is safe. no ?
Of course it isn't...
Signature · 2 lines
With Best Regards, Andy Shevchenko