linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Mario Limonciello <mario.limonciello@amd.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Basavaraj Natikar <Basavaraj.Natikar@amd.com>,
	Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
	"open list:PIN CONTROL SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Nehal Shah <Nehal-bakulchandra.Shah@amd.com>,
	stable@kernel.org, Joerie de Gram <j.de.gram@gmail.com>
Subject: Re: [PATCH v6 2/2] pinctrl: amd: Fix wakeups when IRQ is shared with SCI
Date: Sun, 31 Oct 2021 15:15:12 +0200	[thread overview]
Message-ID: <CAHp75VfOBBpt84aQYGOW32kKqeNH5gZUbJtqf1sPP7O-ZZkW+g@mail.gmail.com> (raw)
In-Reply-To: <20211029204017.8223-2-mario.limonciello@amd.com>

On Fri, Oct 29, 2021 at 11:42 PM Mario Limonciello
<mario.limonciello@amd.com> wrote:
>
> On some Lenovo AMD Gen2 platforms the IRQ for the SCI and pinctrl drivers
> are shared.  Due to how the s2idle loop handling works, this case needs
> an extra explicit check whether the interrupt was caused by SCI or by
> the GPIO controller.
>
> To fix this rework the existing IRQ handler function to function as a
> checker and an IRQ handler depending on the calling arguments.
>
> Cc: stable@kernel.org
> BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1738
> Reported-by: Joerie de Gram <j.de.gram@gmail.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> Acked-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

...

> +static bool _amd_gpio_irq_handler(int irq, void *dev_id)

I know Linus does not like leading _* in the function names, what
about 'do_' instead?

...

> +                       /* called from resume context on a shared IRQ, just
> +                        * checking wake source.
> +                        */

Is this comment aligned with the style used elsewhere in the driver code?

...

> +                               dev_dbg(&gpio_dev->pdev->dev,
> +                                       "Waking due to GPIO %ld: 0x%x",
> +                                       (long)(regs + i - ((u32 __iomem *)gpio_dev->base)), regval);

Oy vey, these castings are ugly. The rule of thumb is that if one does
such a thing for printf() it means something is really wrong (in 99%
of the cases).

AFAICS you may simply use 'irqnr + i' as the other message does.

...

>         platform_set_drvdata(pdev, gpio_dev);
> +       acpi_register_wakeup_handler(gpio_dev->irq, amd_gpio_check_wake, gpio_dev);
>
>         dev_dbg(&pdev->dev, "amd gpio driver loaded\n");
>         return ret;
> @@ -1021,6 +1045,7 @@ static int amd_gpio_remove(struct platform_device *pdev)
>         gpio_dev = platform_get_drvdata(pdev);
>
>         gpiochip_remove(&gpio_dev->gc);
> +       acpi_unregister_wakeup_handler(amd_gpio_check_wake, gpio_dev);

Thinking about making this in the generic GPIO library code, but this
is out of scope of the patch...

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2021-10-31 13:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 20:40 [PATCH v6 1/2] ACPI: Add stubs for wakeup handler functions Mario Limonciello
2021-10-29 20:40 ` [PATCH v6 2/2] pinctrl: amd: Fix wakeups when IRQ is shared with SCI Mario Limonciello
2021-10-31 13:15   ` Andy Shevchenko [this message]
2021-11-01  1:50     ` Limonciello, Mario

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=CAHp75VfOBBpt84aQYGOW32kKqeNH5gZUbJtqf1sPP7O-ZZkW+g@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=Nehal-bakulchandra.Shah@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=j.de.gram@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=stable@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).