linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Terry Bowman <Terry.Bowman@amd.com>
To: Jean Delvare <jdelvare@suse.de>
Cc: linux@roeck-us.net, linux-watchdog@vger.kernel.org,
	linux-i2c@vger.kernel.org, wsa@kernel.org,
	andy.shevchenko@gmail.com, rafael.j.wysocki@intel.com,
	linux-kernel@vger.kernel.org, wim@linux-watchdog.org,
	rrichter@amd.com, thomas.lendacky@amd.com,
	Nehal-bakulchandra.Shah@amd.com, Basavaraj.Natikar@amd.com,
	Shyam-sundar.S-k@amd.com, Mario.Limonciello@amd.com
Subject: Re: [PATCH v3 2/4] Watchdog: sp5100_tco: Refactor MMIO base address initialization
Date: Tue, 25 Jan 2022 12:02:45 -0600	[thread overview]
Message-ID: <717b02cc-ba0c-ddd4-d15d-cc0828fbb3fd@amd.com> (raw)
In-Reply-To: <20220125173857.1c85fddc@endymion>



On 1/25/22 10:38 AM, Jean Delvare wrote:
> On Tue, 25 Jan 2022 09:18:59 -0600, Terry Bowman wrote:
>> On 1/25/22 7:45 AM, Jean Delvare wrote:
>>> On Tue, 18 Jan 2022 14:22:32 -0600, Terry Bowman wrote:  
>>>> +static int __sp5100_tco_prepare_base(struct sp5100_tco *tco,
>>>> +				     u32 mmio_addr,
>>>> +				     const char *dev_name)
>>>> +{
>>>> +	struct device *dev = tco->wdd.parent;
>>>> +	int ret = 0;
>>>> +
>>>> +	if (!mmio_addr)
>>>> +		return -ENOMEM;  
>>>
>>> Can this actually happen? If it does, is -ENOMEM really the best error
>>> value?
>>
>> This can happen if mmio_addr is not assigned in sp5100_tco_setupdevice_mmio() 
>> before calling sp5100_tco_prepare_base() and __sp5100_tco_prepare_base().
> 
> Ah yes, I can see it now.
> 
>> I can move the NULL check out of __sp5100_tco_prepare_base() and into
>> sp5100_tco_prepare_base() before calling __sp5100_tco_prepare_base().
>> As you describe below.
>>
>> The ENOMEM return value should be interpreted as the mmio_addr is not 
>> available. EBUSY does not describe the failure correctly because EBUSY 
>> implies the resource is present and normally available but not available 
>> at this time. Do you have a return value preference ?
> 
> Well, if one mmio_addr isn't set, you shouldn't call
> __sp5100_tco_prepare_base() for it so there's no error to return. If
> neither mmio_addr is set then the hardware is simply not configured to
> be used, so that would be a -NODEV returned by
> sp5100_tco_prepare_base() I suppose?

I agree, -NODEV communicates the error status better.

> 
> BTW...
>  
>>>> (...)
>>>> +	if (ret)
>>>> +		dev_err(dev, "Failed to reserve-map MMIO (%X) and alternate MMIO (%X) regions. ret=%X",
>>>> +			mmio_addr, alt_mmio_addr, ret);  
> 
> ... I think that should be a "or" rather than "and", and singular
> "region", in this error message? I mean, the plan was never to
> reserve-map both of them, if I understand correctly.
> 

This dev_err() is executed when both mmio_addr and alt_mmio_addr addresses failed either 
devm_request_mem_region() or failed devm_ioremap(). I think the following would be most accurate:

dev_err(dev, 
        "Failed to reserve or map the MMIO (0x%X) and alternate MMIO (0x%X) regions, ret=%d",
        mmio_addr, alt_mmio_addr, ret);  

Above is my preference but I don't have a strong opinion. Providing the address and error code 
information in the message is most important. I will make the change as you requested. 

Regards,
Terry




  reply	other threads:[~2022-01-25 18:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18 20:22 [PATCH v3 0/4] Watchdog: sp5100_tco: Replace cd6h/cd7h port I/O accesses with MMIO accesses Terry Bowman
2022-01-18 20:22 ` [PATCH v3 1/4] Watchdog: sp5100_tco: Move timer initialization into function Terry Bowman
2022-01-19 11:40   ` Andy Shevchenko
2022-01-25 13:05   ` Jean Delvare
2022-01-18 20:22 ` [PATCH v3 2/4] Watchdog: sp5100_tco: Refactor MMIO base address initialization Terry Bowman
2022-01-19 11:53   ` Andy Shevchenko
2022-01-19 15:46     ` Guenter Roeck
2022-01-20 11:13       ` Andy Shevchenko
2022-01-19 16:57     ` Terry Bowman
2022-01-19 17:08       ` Guenter Roeck
2022-01-20 11:07       ` Andy Shevchenko
2022-01-25 13:45   ` Jean Delvare
2022-01-25 15:18     ` Terry Bowman
2022-01-25 16:38       ` Jean Delvare
2022-01-25 18:02         ` Terry Bowman [this message]
2022-01-25 18:19           ` Jean Delvare
2022-01-18 20:22 ` [PATCH v3 3/4] Watchdog: sp5100_tco: Add initialization using EFCH MMIO Terry Bowman
2022-01-24 17:36   ` Jean Delvare
2022-01-24 19:20     ` Terry Bowman
2022-01-24 22:36     ` Terry Bowman
2022-01-25 12:42       ` Jean Delvare
2022-01-18 20:22 ` [PATCH v3 4/4] Watchdog: sp5100_tco: Enable Family 17h+ CPUs Terry Bowman
2022-01-25 12:43   ` Jean Delvare
2022-01-19 15:30 ` [PATCH v3 0/4] Watchdog: sp5100_tco: Replace cd6h/cd7h port I/O accesses with MMIO accesses Jean Delvare
2022-01-19 17:33   ` Terry Bowman
2022-01-19 17:47     ` Wolfram Sang
2022-01-19 18:39       ` Guenter Roeck
2022-01-19 18:44         ` Wolfram Sang
2022-01-19 18:45         ` Terry Bowman
2022-01-24 14:42 ` Jean Delvare

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=717b02cc-ba0c-ddd4-d15d-cc0828fbb3fd@amd.com \
    --to=terry.bowman@amd.com \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Nehal-bakulchandra.Shah@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rrichter@amd.com \
    --cc=thomas.lendacky@amd.com \
    --cc=wim@linux-watchdog.org \
    --cc=wsa@kernel.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 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).