linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI / device_sysfs: Prefer "compatible" modalias
@ 2021-01-22 12:53 Kai-Heng Feng
  2021-01-22 13:00 ` Mika Westerberg
  2021-01-22 13:06 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Kai-Heng Feng @ 2021-01-22 12:53 UTC (permalink / raw)
  To: rjw
  Cc: Kai-Heng Feng, AceLan Kao, Rafael J. Wysocki, Greg Kroah-Hartman,
	Andy Shevchenko, Mika Westerberg, Len Brown, open list:ACPI,
	open list

Commit 8765c5ba1949 ("ACPI / scan: Rework modalias creation when
"compatible" is present") may create two "MODALIAS=" in uevent file if
conditions are met.

This breaks systemd-udevd, which assumes each "key" in uevent file is
unique. The internal implementation of systemd-udevd overwrites the
first MODALIAS with the second one, so its kmod rule doesn't load driver
for the first MODALIAS.

So if both ACPI modalias and OF modalias are present, use the latter
one to ensure there's only one MODALIAS.

Reference: https://github.com/systemd/systemd/pull/18163
Cc: AceLan Kao <acelan.kao@canonical.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes: 8765c5ba1949 ("ACPI / scan: Rework modalias creation when "compatible" is present")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/acpi/device_sysfs.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index 96869f1538b9..bfca116482b8 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -251,20 +251,12 @@ int __acpi_device_uevent_modalias(struct acpi_device *adev,
 	if (add_uevent_var(env, "MODALIAS="))
 		return -ENOMEM;
 
-	len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
-				  sizeof(env->buf) - env->buflen);
-	if (len < 0)
-		return len;
-
-	env->buflen += len;
-	if (!adev->data.of_compatible)
-		return 0;
-
-	if (len > 0 && add_uevent_var(env, "MODALIAS="))
-		return -ENOMEM;
-
-	len = create_of_modalias(adev, &env->buf[env->buflen - 1],
-				 sizeof(env->buf) - env->buflen);
+	if (adev->data.of_compatible)
+		len = create_of_modalias(adev, &env->buf[env->buflen - 1],
+					 sizeof(env->buf) - env->buflen);
+	else
+		len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
+					  sizeof(env->buf) - env->buflen);
 	if (len < 0)
 		return len;
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI / device_sysfs: Prefer "compatible" modalias
  2021-01-22 12:53 [PATCH] ACPI / device_sysfs: Prefer "compatible" modalias Kai-Heng Feng
@ 2021-01-22 13:00 ` Mika Westerberg
  2021-01-22 13:06 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Mika Westerberg @ 2021-01-22 13:00 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: rjw, AceLan Kao, Rafael J. Wysocki, Greg Kroah-Hartman,
	Andy Shevchenko, Len Brown, open list:ACPI, open list

On Fri, Jan 22, 2021 at 08:53:02PM +0800, Kai-Heng Feng wrote:
> Commit 8765c5ba1949 ("ACPI / scan: Rework modalias creation when
> "compatible" is present") may create two "MODALIAS=" in uevent file if
> conditions are met.
> 
> This breaks systemd-udevd, which assumes each "key" in uevent file is
> unique. The internal implementation of systemd-udevd overwrites the
> first MODALIAS with the second one, so its kmod rule doesn't load driver
> for the first MODALIAS.
> 
> So if both ACPI modalias and OF modalias are present, use the latter
> one to ensure there's only one MODALIAS.
> 
> Reference: https://github.com/systemd/systemd/pull/18163
> Cc: AceLan Kao <acelan.kao@canonical.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Fixes: 8765c5ba1949 ("ACPI / scan: Rework modalias creation when "compatible" is present")
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI / device_sysfs: Prefer "compatible" modalias
  2021-01-22 12:53 [PATCH] ACPI / device_sysfs: Prefer "compatible" modalias Kai-Heng Feng
  2021-01-22 13:00 ` Mika Westerberg
@ 2021-01-22 13:06 ` Greg Kroah-Hartman
  2021-01-25 16:08   ` Rafael J. Wysocki
  1 sibling, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-01-22 13:06 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: rjw, AceLan Kao, Rafael J. Wysocki, Andy Shevchenko,
	Mika Westerberg, Len Brown, open list:ACPI, open list

On Fri, Jan 22, 2021 at 08:53:02PM +0800, Kai-Heng Feng wrote:
> Commit 8765c5ba1949 ("ACPI / scan: Rework modalias creation when
> "compatible" is present") may create two "MODALIAS=" in uevent file if
> conditions are met.
> 
> This breaks systemd-udevd, which assumes each "key" in uevent file is
> unique. The internal implementation of systemd-udevd overwrites the
> first MODALIAS with the second one, so its kmod rule doesn't load driver
> for the first MODALIAS.
> 
> So if both ACPI modalias and OF modalias are present, use the latter
> one to ensure there's only one MODALIAS.
> 
> Reference: https://github.com/systemd/systemd/pull/18163
> Cc: AceLan Kao <acelan.kao@canonical.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Fixes: 8765c5ba1949 ("ACPI / scan: Rework modalias creation when "compatible" is present")
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  drivers/acpi/device_sysfs.c | 20 ++++++--------------
>  1 file changed, 6 insertions(+), 14 deletions(-)

Thanks for fixing this up!

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ACPI / device_sysfs: Prefer "compatible" modalias
  2021-01-22 13:06 ` Greg Kroah-Hartman
@ 2021-01-25 16:08   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2021-01-25 16:08 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Kai-Heng Feng, Mika Westerberg
  Cc: Rafael J. Wysocki, AceLan Kao, Rafael J. Wysocki,
	Andy Shevchenko, Len Brown, open list:ACPI, open list

On Fri, Jan 22, 2021 at 2:06 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Fri, Jan 22, 2021 at 08:53:02PM +0800, Kai-Heng Feng wrote:
> > Commit 8765c5ba1949 ("ACPI / scan: Rework modalias creation when
> > "compatible" is present") may create two "MODALIAS=" in uevent file if
> > conditions are met.
> >
> > This breaks systemd-udevd, which assumes each "key" in uevent file is
> > unique. The internal implementation of systemd-udevd overwrites the
> > first MODALIAS with the second one, so its kmod rule doesn't load driver
> > for the first MODALIAS.
> >
> > So if both ACPI modalias and OF modalias are present, use the latter
> > one to ensure there's only one MODALIAS.
> >
> > Reference: https://github.com/systemd/systemd/pull/18163
> > Cc: AceLan Kao <acelan.kao@canonical.com>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Fixes: 8765c5ba1949 ("ACPI / scan: Rework modalias creation when "compatible" is present")
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> > ---
> >  drivers/acpi/device_sysfs.c | 20 ++++++--------------
> >  1 file changed, 6 insertions(+), 14 deletions(-)
>
> Thanks for fixing this up!
>
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Applied as 5.11-rc material with some minor edits in the subject and
changelog and with the tags.

Thanks everyone!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-25 16:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 12:53 [PATCH] ACPI / device_sysfs: Prefer "compatible" modalias Kai-Heng Feng
2021-01-22 13:00 ` Mika Westerberg
2021-01-22 13:06 ` Greg Kroah-Hartman
2021-01-25 16:08   ` Rafael J. Wysocki

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).