All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: David Daney <ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages.
Date: Sun, 06 Sep 2015 19:16:29 -0700	[thread overview]
Message-ID: <55ECF37D.7050401@gmail.com> (raw)
In-Reply-To: <CAL_JsqK0uW4F7HAcUMSQ-2wCvp_i3a5MTxsyW3XerHAxBrW=SQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 9/6/2015 1:46 PM, Rob Herring wrote:
> On Fri, Sep 4, 2015 at 8:14 PM, Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> On 9/4/2015 12:12 PM, David Daney wrote:
>>> From: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
>>>
>>> It is perfectly legitimate for a PCI device to have an
>>> PCI_INTERRUPT_PIN value of zero.  This happens if the device doesn't
>>> use interrupts, or on PCIe devices, where only MSI/MSI-X are
>>> supported.
>>>
>>> Silence the annoying "of_irq_parse_pci() failed with rc=-19" error
>>> messages by making them conditional on !-ENODEV (which can only be
>>> produced in the PCI_INTERRUPT_PIN == 0 case).
>>>
>>> Signed-off-by: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
>>> ---
>>>  drivers/of/of_pci_irq.c | 4 +++-
>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c
>>> index 1710d9d..33d242a 100644
>>> --- a/drivers/of/of_pci_irq.c
>>> +++ b/drivers/of/of_pci_irq.c
>>> @@ -106,7 +106,9 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
>>>
>>>       ret = of_irq_parse_pci(dev, &oirq);
>>>       if (ret) {
>>> -             dev_err(&dev->dev, "of_irq_parse_pci() failed with rc=%d\n", ret);
>>> +             if (ret != -ENODEV)
>>> +                     dev_err(&dev->dev,
>>> +                             "of_irq_parse_pci() failed with rc=%d\n", ret);
>>>               return 0; /* Proper return code 0 == NO_IRQ */
>>>       }
>>>
>>>
>>
>> It is not safe to assume that the functions that of_irq_parse_pci() calls
>> will never be modified to return -ENODEV, thus resulting in of_irq_parse_pci()
>> returning -ENODEV for a reason other than PCI_INTERRUPT_PIN == 0.
> 
> Yes, but we're talking about a print statement.
> 
>>
>> A more robust solution would be something like:

< snip my bad solution >

>> I'm not sure I like my solution, there might be a better way.
> 
> I don't like it. That's way too complex for just silencing an
> erroneous error message.
> 
> Perhaps just move the error message into of_irq_parse_pci and then you
> can control the print more easily. Or just change to dev_dbg would be
> okay by me.

I knew I was making it way too hard.  Yes, just move the error message
to of_irq_parse_pci(), where the "/* No pin, exit */" test occurs.

 
>> I also noticed another bug while looking at of_irq_parse_pci().  It returns
>> the non-zero return value from pci_read_config_byte().  But that value is
>> one of the PCI function error values from include/linux/pci.h, such as:
>>
>>    #define PCIBIOS_BAD_REGISTER_NUMBER     0x87
>>
>> instead of a negative errno.
> 
> I was puzzled by why this is not standard error codes a while back. My
> best guess is that that there is some legacy here. Changing error
> values on widely used functions is impossible to audit. NO_IRQ being 0
> or -1 is one such case.
> 
> Rob
> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Frank Rowand <frowand.list@gmail.com>
To: Rob Herring <robherring2@gmail.com>
Cc: David Daney <ddaney.cavm@gmail.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Grant Likely <grant.likely@linaro.org>,
	David Daney <david.daney@cavium.com>
Subject: Re: [PATCH] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages.
Date: Sun, 06 Sep 2015 19:16:29 -0700	[thread overview]
Message-ID: <55ECF37D.7050401@gmail.com> (raw)
In-Reply-To: <CAL_JsqK0uW4F7HAcUMSQ-2wCvp_i3a5MTxsyW3XerHAxBrW=SQ@mail.gmail.com>

On 9/6/2015 1:46 PM, Rob Herring wrote:
> On Fri, Sep 4, 2015 at 8:14 PM, Frank Rowand <frowand.list@gmail.com> wrote:
>> On 9/4/2015 12:12 PM, David Daney wrote:
>>> From: David Daney <david.daney@cavium.com>
>>>
>>> It is perfectly legitimate for a PCI device to have an
>>> PCI_INTERRUPT_PIN value of zero.  This happens if the device doesn't
>>> use interrupts, or on PCIe devices, where only MSI/MSI-X are
>>> supported.
>>>
>>> Silence the annoying "of_irq_parse_pci() failed with rc=-19" error
>>> messages by making them conditional on !-ENODEV (which can only be
>>> produced in the PCI_INTERRUPT_PIN == 0 case).
>>>
>>> Signed-off-by: David Daney <david.daney@cavium.com>
>>> ---
>>>  drivers/of/of_pci_irq.c | 4 +++-
>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c
>>> index 1710d9d..33d242a 100644
>>> --- a/drivers/of/of_pci_irq.c
>>> +++ b/drivers/of/of_pci_irq.c
>>> @@ -106,7 +106,9 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
>>>
>>>       ret = of_irq_parse_pci(dev, &oirq);
>>>       if (ret) {
>>> -             dev_err(&dev->dev, "of_irq_parse_pci() failed with rc=%d\n", ret);
>>> +             if (ret != -ENODEV)
>>> +                     dev_err(&dev->dev,
>>> +                             "of_irq_parse_pci() failed with rc=%d\n", ret);
>>>               return 0; /* Proper return code 0 == NO_IRQ */
>>>       }
>>>
>>>
>>
>> It is not safe to assume that the functions that of_irq_parse_pci() calls
>> will never be modified to return -ENODEV, thus resulting in of_irq_parse_pci()
>> returning -ENODEV for a reason other than PCI_INTERRUPT_PIN == 0.
> 
> Yes, but we're talking about a print statement.
> 
>>
>> A more robust solution would be something like:

< snip my bad solution >

>> I'm not sure I like my solution, there might be a better way.
> 
> I don't like it. That's way too complex for just silencing an
> erroneous error message.
> 
> Perhaps just move the error message into of_irq_parse_pci and then you
> can control the print more easily. Or just change to dev_dbg would be
> okay by me.

I knew I was making it way too hard.  Yes, just move the error message
to of_irq_parse_pci(), where the "/* No pin, exit */" test occurs.

 
>> I also noticed another bug while looking at of_irq_parse_pci().  It returns
>> the non-zero return value from pci_read_config_byte().  But that value is
>> one of the PCI function error values from include/linux/pci.h, such as:
>>
>>    #define PCIBIOS_BAD_REGISTER_NUMBER     0x87
>>
>> instead of a negative errno.
> 
> I was puzzled by why this is not standard error codes a while back. My
> best guess is that that there is some legacy here. Changing error
> values on widely used functions is impossible to audit. NO_IRQ being 0
> or -1 is one such case.
> 
> Rob
> 


  parent reply	other threads:[~2015-09-07  2:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04 19:12 [PATCH] of_pci_irq: Silence bogus "of_irq_parse_pci() failed ..." messages David Daney
     [not found] ` <1441393926-23225-1-git-send-email-ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-05  1:14   ` Frank Rowand
2015-09-05  1:14     ` Frank Rowand
     [not found]     ` <55EA41E3.5010103-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-05  1:40       ` David Daney
2015-09-05  1:40         ` David Daney
     [not found]         ` <55EA480C.6090306-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-05  2:38           ` Frank Rowand
2015-09-05  2:38             ` Frank Rowand
2015-09-06 20:46       ` Rob Herring
2015-09-06 20:46         ` Rob Herring
     [not found]         ` <CAL_JsqK0uW4F7HAcUMSQ-2wCvp_i3a5MTxsyW3XerHAxBrW=SQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-07  2:16           ` Frank Rowand [this message]
2015-09-07  2:16             ` Frank Rowand
2015-09-07  3:50             ` Frank Rowand
2015-09-07 23:44               ` Frank Rowand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55ECF37D.7050401@gmail.com \
    --to=frowand.list-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org \
    --cc=ddaney.cavm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.