From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Hardik Prakash <hardikprakash.official@gmail.com>
Cc: linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org,
linus.walleij@linaro.org, wsa@kernel.org
Subject: Re: [PATCH 2/2] i2c: designware: fix probe ordering for AMD GPIO on Lenovo Yoga 7 14AGP11
Date: Tue, 12 May 2026 12:55:30 +0200 [thread overview]
Message-ID: <agMHIhMzS_8AicAI@black.igk.intel.com> (raw)
In-Reply-To: <20260512073139.16343-3-hardikprakash.official@gmail.com>
On Tue, May 12, 2026 at 01:01:39PM +0530, Hardik Prakash wrote:
> The existing dw_i2c_amd_gpio_defer_dmi quirk for Lenovo 83TD checks
Existing? Is this message and the whole stuff is somehow AI-assisted?
> gpio_dev->driver to determine if the GPIO controller is ready, but
> this pointer is set before pinctrl-amd's probe completes, causing
> i2c_designware to probe AMDI0010:02 before the GPIO IRQ quirk runs.
>
> Switch to device_is_bound() under device_lock() to correctly defer
> until GPIO probe has fully completed. Also replace the string-based
> device lookup with ACPI HID/UID matching for robustness, and add
> DMI_BOARD_NAME to the DMI match to reduce false positives.
> Fixes: the lost arbitration on AMDI0010:02 at boot on Lenovo 83TD.
This is incorrect way of providing a Fixes tag.
...
> +struct dw_i2c_hid_uid {
> + const char *hid;
> + u64 uid;
> +};
Useless as duplicates the existing strictures. See also below.
...
> +static int dw_i2c_match_hid_uid(struct device *dev, const void *data)
> +{
> + struct acpi_device *adev = ACPI_COMPANION(dev);
> + const struct dw_i2c_hid_uid *id = data;
> +
> + if (!adev)
> + return 0;
> +
> + return acpi_dev_hid_uid_match(adev, id->hid, id->uid);
> +}
> +
> +static struct device *dw_i2c_find_platform_hid_uid(const char *hid, u64 uid)
> +{
> + struct dw_i2c_hid_uid data = {
> + .hid = hid,
> + .uid = uid,
> + };
> +
> + return bus_find_device(&platform_bus_type, NULL, &data, dw_i2c_match_hid_uid);
> +}
> +
> +static bool dw_i2c_needs_amd_gpio_dep(struct device *device)
> +{
> + struct acpi_device *adev = ACPI_COMPANION(device);
> +
> + if (!dmi_check_system(dw_i2c_amd_gpio_defer_dmi))
> + return false;
> + if (!adev)
> + return false;
> +
> + return acpi_dev_hid_uid_match(adev, "AMDI0010", 2);
> +}
The whole flow is just a repetition of acpi_dev_get_first_match_dev().
...
> +static int dw_i2c_defer_for_amd_gpio(struct device *device)
> +{
> + struct device *gpio_dev;
> +
> + if (!dw_i2c_needs_amd_gpio_dep(device))
> + return 0;
> +
> + gpio_dev = dw_i2c_find_platform_hid_uid("AMDI0030", 0);
> + if (!gpio_dev)
> + return -EPROBE_DEFER;
> +
> + device_lock(gpio_dev);
> + if (!device_is_bound(gpio_dev)) {
> + device_unlock(gpio_dev);
> + put_device(gpio_dev);
> + return -EPROBE_DEFER;
> + }
> + device_unlock(gpio_dev);
Interesting dance. Needs a comment explaining what's going on here and why this
deferral probe won't be a problem in other scenarios.
> + if (!device_link_add(device, gpio_dev, DL_FLAG_AUTOREMOVE_CONSUMER))
This needs a good comment explaining what's going on.
> + dev_warn(device, "failed to add device link to AMDI0030:00\n");
Why :00? Is it guaranteed that this is going to be with :00? Note, this suffix
is instance number in Linux and strictly speaking might differ even from boot
to boot on the same machine.
> + put_device(gpio_dev);
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-05-12 10:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 7:31 [PATCH 0/2] Fix WACF2200 touchscreen on Lenovo Yoga 7 14AGP11 Hardik Prakash
2026-05-12 7:31 ` [PATCH 1/2] pinctrl-amd: enable IRQ for " Hardik Prakash
2026-05-12 8:47 ` Linus Walleij
2026-05-12 10:46 ` Andy Shevchenko
2026-05-13 7:33 ` Linus Walleij
2026-05-12 7:31 ` [PATCH 2/2] i2c: designware: fix probe ordering for AMD GPIO " Hardik Prakash
2026-05-12 10:55 ` Andy Shevchenko [this message]
[not found] ` <CANTFpSX-U5pJ3zQ7NMQMpSu+bw1wB5weW7E-oQ51oE7oZg1cZw@mail.gmail.com>
2026-05-12 11:10 ` Hardik Prakash
2026-05-12 18:05 ` Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2026-05-13 6:13 [PATCH v2 0/2] Fix WACF2200 touchscreen " Hardik Prakash
2026-05-13 6:13 ` [PATCH 2/2] i2c: designware: fix probe ordering for AMD GPIO " Hardik Prakash
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=agMHIhMzS_8AicAI@black.igk.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=hardikprakash.official@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.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