From patchwork Tue Jan 19 09:23:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 12029909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CAD1C43381 for ; Tue, 19 Jan 2021 14:17:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22E7323133 for ; Tue, 19 Jan 2021 14:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732173AbhASOP6 (ORCPT ); Tue, 19 Jan 2021 09:15:58 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52886 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732772AbhASJYQ (ORCPT ); Tue, 19 Jan 2021 04:24:16 -0500 Received: from 1-171-232-235.dynamic-ip.hinet.net ([1.171.232.235] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l1nEb-0002wx-9q; Tue, 19 Jan 2021 09:23:33 +0000 From: Kai-Heng Feng To: rjw@rjwysocki.net Cc: Kai-Heng Feng , Len Brown , linux-acpi@vger.kernel.org (open list:ACPI), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] ACPI / device_sysfs: Use OF_MODALIAS for "compatible" modalias Date: Tue, 19 Jan 2021 17:23:27 +0800 Message-Id: <20210119092327.310934-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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. Right now it doesn't seem to have any user relies on the second MODALIAS, so change it to OF_MODALIAS to workaround the issue. Reference: https://github.com/systemd/systemd/pull/18163 Fixes: 8765c5ba1949 ("ACPI / scan: Rework modalias creation when "compatible" is present") Signed-off-by: Kai-Heng Feng --- v2: Add a comment to document why it's changed. drivers/acpi/device_sysfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c index 96869f1538b9..17483c40deeb 100644 --- a/drivers/acpi/device_sysfs.c +++ b/drivers/acpi/device_sysfs.c @@ -260,7 +260,11 @@ int __acpi_device_uevent_modalias(struct acpi_device *adev, if (!adev->data.of_compatible) return 0; - if (len > 0 && add_uevent_var(env, "MODALIAS=")) + /* Two "MODALIAS=" breaks how systemd-udevd handles uevent file. + * As userspace may not be able to handle duplicated keys, add prefix + * "OF_" to avoid the key collision. + */ + if (len > 0 && add_uevent_var(env, "OF_MODALIAS=")) return -ENOMEM; len = create_of_modalias(adev, &env->buf[env->buflen - 1],