linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Terry Bowman <terry.bowman@amd.com>,
	linux-watchdog@vger.kernel.org, Jean Delvare <jdelvare@suse.com>,
	linux-i2c <linux-i2c@vger.kernel.org>,
	Wolfram Sang <wsa@kernel.org>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Robert Richter <rrichter@amd.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	"Shah, Nehal-bakulchandra" <Nehal-bakulchandra.Shah@amd.com>,
	Basavaraj Natikar <Basavaraj.Natikar@amd.com>,
	Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
	Mario Limonciello <Mario.Limonciello@amd.com>
Subject: Re: [PATCH v3 2/4] Watchdog: sp5100_tco: Refactor MMIO base address initialization
Date: Thu, 20 Jan 2022 13:13:03 +0200	[thread overview]
Message-ID: <CAHp75VfcJ1HBM=Rw5LcTZWYMxxpASC2b=gTWTrRs4--CmqafpQ@mail.gmail.com> (raw)
In-Reply-To: <b4f66a42-6f25-7e93-2a3b-5d73af39e72e@roeck-us.net>

On Wed, Jan 19, 2022 at 5:46 PM Guenter Roeck <linux@roeck-us.net> wrote:
> On 1/19/22 3:53 AM, Andy Shevchenko wrote:
> > On Tue, Jan 18, 2022 at 10:23 PM Terry Bowman <terry.bowman@amd.com> wrote:

...

> >> +               devm_release_mem_region(dev, mmio_addr,
> >> +                                       SP5100_WDT_MEM_MAP_SIZE);
> >
> > Why? If it's a short live mapping, do not use devm.
>
> This is not short lived; it is needed by the driver. The release
> is an artifact of calling this function twice and ignoring the error
> from devm_ioremap() if the first call fails. devm_release_mem_region()
> isn't strictly needed but that would result in keeping the memory
> region reserved even though it isn't used by the driver.

So, this seems like micro-optimization, but okay, at least it
justifies it. Thanks for explaining.

> There is a functional difference to the original code, though.
> The failing devm_ioremap() causes the code to try the alternate
> address. I am not sure if that really adds value; devm_ioremap()
> fails because the system is out of virtual memory, and calling
> it again on a different address doesn't seem to add much value.
> I preferred the original code, which would only call devm_ioremap()
> after successfully reserving a memory region.

...

> > On top of above it's a NIH devm_ioremap_resource().
>
> Not sure what NIH means

Not Invented Here (syndrome)

...

> >> +       /* Check MMIO address conflict */
> >> +       ret = __sp5100_tco_prepare_base(tco, mmio_addr, dev_name);
> >
> >> +
> >> +       /* Check alternate MMIO address conflict */
> >
> > Unify this with the previous comment.
>
> Why ? It refers to the code below. If that is a single or two comments
> is really just POV.

It depends on the angle from which you see it (i.o.w. like you said
POV). I considered it from the code perspective and personally found
the
/*
 * Bla bla bla
 */
ret = foo();
if (ret)
  bar();

better than above.

> >> +       if (ret)
> >> +               ret = __sp5100_tco_prepare_base(tco, alt_mmio_addr,
> >> +                                               dev_name);

...

> >>          release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE);
> >
> > Is it still needed? I have no context to say if devm_iomap() and this
> > are not colliding, please double check the correctness.
> >
> Not sure I understand. This is the release of the io region reserved with
> request_muxed_region() at the beginning of this function. Why would it no
> longer be necessary to release that region ?

Thank you for explaining, as I said I have no full context here, and I
simply asked for double check.

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2022-01-20 11:14 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 [this message]
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
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='CAHp75VfcJ1HBM=Rw5LcTZWYMxxpASC2b=gTWTrRs4--CmqafpQ@mail.gmail.com' \
    --to=andy.shevchenko@gmail.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=jdelvare@suse.com \
    --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=terry.bowman@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).