From: Thierry Reding <thierry.reding@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>,
Patrice CHOTARD <patrice.chotard@st.com>,
Tejun Heo <tj@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
"linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH] ata: ahci-platform: add reset control support
Date: Mon, 9 Apr 2018 13:59:01 +0200 [thread overview]
Message-ID: <20180409115901.GB29946@ulmo> (raw)
In-Reply-To: <22a2bcd7-eff5-c20f-e056-f5946e579d5e@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 7277 bytes --]
On Fri, Apr 06, 2018 at 10:29:37AM +0200, Hans de Goede wrote:
> Hi,
>
> On 06-04-18 06:48, Kunihiko Hayashi wrote:
> > Hi Hans,
> >
> > On Thu, 5 Apr 2018 16:08:24 +0200
> > Hans de Goede <hdegoede@redhat.com> wrote:
> >
> > > Hi,
> > >
> > > On 05-04-18 16:00, Hans de Goede wrote:
> > > > Hi,
> > > > > On 05-04-18 15:54, Thierry Reding wrote:
> > > > > On Thu, Apr 05, 2018 at 03:27:03PM +0200, Hans de Goede wrote:
> > > > > > Hi,
> > > > > >
> > > > > > On 05-04-18 15:17, Patrice CHOTARD wrote:
> > > > > > > Hi Thierry
> > > > > > >
> > > > > > > On 04/05/2018 11:54 AM, Thierry Reding wrote:
> > > > > > > > On Fri, Mar 23, 2018 at 10:30:53AM +0900, Kunihiko Hayashi wrote:
> > > > > > > > > Add support to get and control a list of resets for the device
> > > > > > > > > as optional and shared. These resets must be kept de-asserted until
> > > > > > > > > the device is enabled.
> > > > > > > > >
> > > > > > > > > This is specified as shared because some SoCs like UniPhier series
> > > > > > > > > have common reset controls with all ahci controller instances.
> > > > > > > > >
> > > > > > > > > Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
> > > > > > > > > ---
> > > > > > > > > ??? .../devicetree/bindings/ata/ahci-platform.txt????? |? 1 +
> > > > > > > > > ??? drivers/ata/ahci.h???????????????????????????????? |? 1 +
> > > > > > > > > ??? drivers/ata/libahci_platform.c???????????????????? | 24 +++++++++++++++++++---
> > > > > > > > > ??? 3 files changed, 23 insertions(+), 3 deletions(-)
> > > > > > > >
> > > > > > > > This causes a regression on Tegra because we explicitly request the
> > > > > > > > resets after the call to ahci_platform_get_resources().
> > > > > > >
> > > > > > > I confirm, we got exactly the same behavior on STi platform.
> > > > > > >
> > > > > > > >
> > > > > > > > ?? From a quick look, ahci_mtk and ahci_st are in the same boat, adding the
> > > > > > > > corresponding maintainers to Cc.
> > > > > > > >
> > > > > > > > Patrice, Matthias: does SATA still work for you after this patch? This
> > > > > > > > has been in linux-next since next-20180327.
> > > > > > >
> > > > > > > SATA is still working after this patch, but a kernel warning is
> > > > > > > triggered due to the fact that resets are both requested by
> > > > > > > libahci_platform and by ahci_st driver.
> > > > > >
> > > > > > So in your case you might be able to remove the reset handling
> > > > > > from the ahci_st driver and rely on the new libahci_platform
> > > > > > handling instead? If that works that seems like a win to me.
> > > > > >
> > > > > > As said elsewhere in this thread I think it makes sense to keep (or re-add
> > > > > > after a revert) the libahci_platform reset code, but make it conditional
> > > > > > on a flag passed to ahci_platform_get_resources(). This way we get
> > > > > > the shared code for most cases and platforms which need special handling
> > > > > > can opt-out.
> > > > >
> > > > > Agreed, although I prefer such helpers to be opt-in, rather than
> > > > > opt-out. In my experience that tends make the helpers more resilient to
> > > > > this kind of regression. It also simplifies things because instead of
> > > > > drivers saying "I want all the helpers except this one and that one",
> > > > > they can simply say "I want these helpers and that one". In the former
> > > > > case whenever you add some new (opt-out) feature, you have to update all
> > > > > drivers and add the exception. In the latter you only need to extend the
> > > > > drivers that want to make use of the new helper.
> > >
> > > Erm, the idea never was to make this opt-out but rather opt in, so
> > > we add a flags parameter to ahci_platform_get_resources() and all
> > > current users pass in 0 for that to keep the current behavior.
> > >
> > > And only the generic drivers/ata/ahci_platform.c driver will pass
> > > in a the new AHCI_PLATFORM_GET_RESETS flag, which makes
> > > ahci_platform_get_resources() (and the other functions) also deal
> > > with resets.
> > >
> > > > > With that in mind, rather than adding a flag to the
> > > > > ahci_platform_get_resources() function, it might be more flexible to
> > > > > split the helpers into finer-grained functions. That way drivers can
> > > > > pick whatever functionality they want from the helpers.
> > > > > Good point, so lets:
> > > > > 1) Revert the patch for now
> > > > 2) Have a new version of the patch which adds a ahci_platform_get_resets() helper
> > > > 3) Modify the generic drivers/ata/ahci_platform.c driver to call the new
> > > > ?? ahci_platform_get_resets() between its ahci_platform_get_resources()
> > > > ?? and ahci_platform_enable_resources() calls.
> > > > ?? I think that ahci_platform_enable_resources() should still automatically
> > > > ?? do the right thing wrt resets if ahci_platform_get_resets() was called
> > > > ?? (otherwise the resets array will be empty and should be skipped)
> > > > > This should make the generic driver usable for the UniPhier SoCs and
> > > > maybe some other drivers like the ahci_st driver can also switch to the
> > > > new ahci_platform_get_resets() functionality to reduce their code a bit.
> > >
> > > So thinking slightly longer about this, with the opt-in variant
> > > (which is what I intended all along) I do think that a flags parameter
> > > is better, because the whole idea behind lib_ahci_platform is to avoid
> > > having to do err = get_resource_a(), if (err) bail, err = get_resource_b()
> > > if (err) bail, etc. in all the ahci (platform) drivers. And having fine
> > > grained helpers re-introduces that.
> >
> > In case of adding a flag instead of get_resource_a(),
> > for example, we add the flag for use of resets,
> >
> > -struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
> > +struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
> > + bool use_reset)
> >
> > and for now all the drivers using this function need to add the argument as false
> > to the caller.
> >
> > - hpriv = ahci_platform_get_resources(pdev);
> > + hpriv = ahci_platform_get_resources(pdev, false);
> >
> > Surely this can avoid adding functions such get_resource_a(). If we apply another
> > feature later, we add its flag as one of the arguments instead. Is it right?
>
> Yes, that is right, but instead of adding a "bool use_reset" please add
> an "unsigned int flags" parameter instead and a:
>
> #define AHCI_PLATFORM_GET_RESETS 0x01
>
> And update all callers of ahci_platform_get_resources to pass 0 for flags
> except for drivers/ata/ahci_platform.c. This way we only need to modify
> all callers once, and if we want to add another optional resource in
> the future we can add a:
>
> #define AHCI_PLATFORM_GET_FOO 0x02
>
> Without needing to change all callers again.
On a side-note, I also think the symbolic flags make the code easier to
read. Having something like:
ahci_platform_get_resources(pdev, true, false, true);
becomes really difficult to understand.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-04-09 11:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-23 1:30 [PATCH] ata: ahci-platform: add reset control support Kunihiko Hayashi
2018-03-23 8:19 ` Hans de Goede
2018-03-26 22:24 ` Rob Herring
2018-04-05 9:54 ` Thierry Reding
2018-04-05 9:59 ` Thierry Reding
2018-04-05 11:23 ` Kunihiko Hayashi
2018-04-05 11:30 ` Hans de Goede
2018-04-05 13:17 ` Patrice CHOTARD
2018-04-05 13:17 ` Patrice CHOTARD
2018-04-05 13:27 ` Hans de Goede
2018-04-05 13:54 ` Thierry Reding
2018-04-05 14:00 ` Hans de Goede
2018-04-05 14:08 ` Hans de Goede
2018-04-06 4:48 ` Kunihiko Hayashi
2018-04-06 8:29 ` Hans de Goede
2018-04-06 9:36 ` Kunihiko Hayashi
2018-04-06 10:12 ` Hans de Goede
2018-04-09 11:59 ` Thierry Reding [this message]
[not found] ` <1f7d0738-1963-21c5-c293-e46fb0214ecf-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-04-05 14:00 ` Patrice CHOTARD
2018-04-05 14:00 ` Patrice CHOTARD
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=20180409115901.GB29946@ulmo \
--to=thierry.reding@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=hayashi.kunihiko@socionext.com \
--cc=hdegoede@redhat.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=patrice.chotard@st.com \
--cc=robh+dt@kernel.org \
--cc=tj@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 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.