From patchwork Fri Jan 31 14:18:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955434 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04FECC0218F for ; Fri, 31 Jan 2025 14:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=2+BBMmuMs6DodF3kciTXRQFKNSr3peOQ9HaYYYj3gNQ=; b=i1ZdQD1I6vQlMV+CQUoCEj/5WA NUJLA5ts3nAVGl79GOXzrOHouXPr7gaHZOz98afncOhhIk2n6xGPQnq6rfQKiTO1ZTvOp40XKiqwB KhsFgPOBFwVAwL4EV25odLEVHMdGD+w7Xtduv8XvRnpC4yDyi2K6hpat5ylUeq09ei70wBZObnmd5 QXUuLkn892Jr3QVy/IyCMnbToYwOT4pE8lENCV1jUS5f6ftEUYgsyN3RCO0PjacD2ZRwvpFuVWCw3 fmaQrqS4nnxseuaDDvyUALVpKBcXF27O/bNXie1SC4Y5tIc2VdJ75LZHrt7GWGc0xFaxx3HaODyMc aeCF4nKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdrs8-0000000Al64-49CI; Fri, 31 Jan 2025 14:19:52 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdrqp-0000000Al0n-31kh for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 14:18:32 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0832D497; Fri, 31 Jan 2025 06:18:56 -0800 (PST) Received: from usa.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 515163F63F; Fri, 31 Jan 2025 06:18:29 -0800 (PST) From: Sudeep Holla To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Cristian Marussi , Xinqi Zhang , Peng Fan , Guomin Chen Subject: [PATCH 1/3] firmware: arm_scmi: Relax duplicate name constraint across protocol ids Date: Fri, 31 Jan 2025 14:18:20 +0000 Message-Id: <20250131141822.514342-1-sudeep.holla@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250131_061831_810359_3E56DD96 X-CRM114-Status: GOOD ( 12.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently in scmi_protocol_device_request(), no duplicate scmi device name is allowed across any protocol. However scmi_dev_match_id() first matches the protocol id and then the name. So, there is no strict requirement to keep this scmi device name unique across all the protocols. Relax the constraint on the duplicate name across the protocols and inhibit only within the same protocol id. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index a3386bf36de5..8acf33ccfd21 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -42,7 +42,7 @@ static atomic_t scmi_syspower_registered = ATOMIC_INIT(0); * This helper let an SCMI driver request specific devices identified by the * @id_table to be created for each active SCMI instance. * - * The requested device name MUST NOT be already existent for any protocol; + * The requested device name MUST NOT be already existent for this protocol; * at first the freshly requested @id_table is annotated in the IDR table * @scmi_requested_devices and then the requested device is advertised to any * registered party via the @scmi_requested_devices_nh notification chain. @@ -52,7 +52,6 @@ static atomic_t scmi_syspower_registered = ATOMIC_INIT(0); static int scmi_protocol_device_request(const struct scmi_device_id *id_table) { int ret = 0; - unsigned int id = 0; struct list_head *head, *phead = NULL; struct scmi_requested_dev *rdev; @@ -67,19 +66,13 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table) } /* - * Search for the matching protocol rdev list and then search - * of any existent equally named device...fails if any duplicate found. + * Find the matching protocol rdev list and then search of any + * existent equally named device...fails if any duplicate found. */ mutex_lock(&scmi_requested_devices_mtx); - idr_for_each_entry(&scmi_requested_devices, head, id) { - if (!phead) { - /* A list found registered in the IDR is never empty */ - rdev = list_first_entry(head, struct scmi_requested_dev, - node); - if (rdev->id_table->protocol_id == - id_table->protocol_id) - phead = head; - } + phead = idr_find(&scmi_requested_devices, id_table->protocol_id); + if (phead) { + head = phead; list_for_each_entry(rdev, head, node) { if (!strcmp(rdev->id_table->name, id_table->name)) { pr_err("Ignoring duplicate request [%d] %s\n", From patchwork Fri Jan 31 14:18:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96A1CC0218F for ; Fri, 31 Jan 2025 14:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OSstOMUWc4GoyUjdBMZ7pO7yxSRI6p+YmDrYBqNfASg=; b=CD5/rj3sqlPbKhZeeGHe+p2iMu aBz6EpRtQVfu9Fuh3uwVYQBXKkIwrkbaOvHdLP3NuPV8h92NiV9VenKSdimmQVMwNewxEf4ZsXCPW aATJAm2CjcE+9PIEfA0NgJCCmuEUDtfPuytUfOWz+UK4PZi1/JDA79ZrHKJDlxADrQBplTcr5kWLZ WIJVXWx5ijZT+tl7WGJoM55Cde+Pbnk+5m8kM0BjgXEw4LHiV2b3FgW0u8X1GbP/DDJ382LwYG75m UscHiSlTYdZD4gILuW6X/O6lvZRYgO4t0tgt/0Gba2MuV9/J1FXHbZ69Dop7kj/1CaRV4WK/542s+ 6s17YcRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdrtQ-0000000AlJ5-2VUF; Fri, 31 Jan 2025 14:21:12 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdrqq-0000000Al14-3C3i for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 14:18:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9D2E5FEC; Fri, 31 Jan 2025 06:18:57 -0800 (PST) Received: from usa.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E7A8B3F63F; Fri, 31 Jan 2025 06:18:30 -0800 (PST) From: Sudeep Holla To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Cristian Marussi , Xinqi Zhang , Peng Fan , Guomin Chen Subject: [PATCH 2/3] firmware: arm_scmi: Add name and protocol id attributes Date: Fri, 31 Jan 2025 14:18:21 +0000 Message-Id: <20250131141822.514342-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250131141822.514342-1-sudeep.holla@arm.com> References: <20250131141822.514342-1-sudeep.holla@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250131_061832_842543_BC79FED2 X-CRM114-Status: GOOD ( 10.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add the name and the protocol id attributes to the SCMI devices on the bus so that they are exposed to the user-space via the sysfs. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index 8acf33ccfd21..862dd34eca62 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -17,6 +17,8 @@ #include "common.h" +#define SCMI_UEVENT_MODALIAS_FMT "%s:%02x:%s" + BLOCKING_NOTIFIER_HEAD(scmi_requested_devices_nh); EXPORT_SYMBOL_GPL(scmi_requested_devices_nh); @@ -276,11 +278,47 @@ static void scmi_dev_remove(struct device *dev) scmi_drv->remove(scmi_dev); } +static int scmi_device_uevent(const struct device *dev, struct kobj_uevent_env *env) +{ + const struct scmi_device *scmi_dev = to_scmi_dev(dev); + + return add_uevent_var(env, "MODALIAS=" SCMI_UEVENT_MODALIAS_FMT, + dev_name(&scmi_dev->dev), scmi_dev->protocol_id, + scmi_dev->name); +} + +static ssize_t protocol_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct scmi_device *scmi_dev = to_scmi_dev(dev); + + return sprintf(buf, "0x%02x\n", scmi_dev->protocol_id); +} +static DEVICE_ATTR_RO(protocol_id); + +static ssize_t name_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct scmi_device *scmi_dev = to_scmi_dev(dev); + + return sprintf(buf, "%s\n", scmi_dev->name); +} +static DEVICE_ATTR_RO(name); + +static struct attribute *scmi_device_attributes_attrs[] = { + &dev_attr_protocol_id.attr, + &dev_attr_name.attr, + NULL, +}; +ATTRIBUTE_GROUPS(scmi_device_attributes); + const struct bus_type scmi_bus_type = { .name = "scmi_protocol", .match = scmi_dev_match, .probe = scmi_dev_probe, .remove = scmi_dev_remove, + .uevent = scmi_device_uevent, + .dev_groups = scmi_device_attributes_groups, }; EXPORT_SYMBOL_GPL(scmi_bus_type); From patchwork Fri Jan 31 14:18:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67538C0218F for ; Fri, 31 Jan 2025 14:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QOORdYjCVffL6BqXTG3jjm5QCdbD3d6xHdBFxE8U06U=; b=09OSPHnXQUQe/YTnhGhYjwZ4Yq I6ANZGzOAA8WPZE+9Q0pP2puBZv0YERsc6HpuuM2X1QkcvHaF5wNEF7zKZvB2fByRS89aUngMaCmE KkyAv2Q/WTjyI1gC6kPZlYx0duEj0MPA0hOJdgTFSPYPqQeT3cLGmBc9J5F4h6g8bbP3ExoHHRgrK ry6E8NUntGAu0AwEvcdCaEgj/HNTNvjRZrsxLQaMZ2bN/cSbaK1p+jiAyjy9VkPovELH5JV1slvdH imZ8S9MblnKLq1yyX5isFtmqjNfHjSIRW6R2oJTa6QWrKiDX9WCHRcZOw/DNxlymqIlhQot2bBHpZ XzQkwrpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdrui-0000000AlWS-1Dd4; Fri, 31 Jan 2025 14:22:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdrqs-0000000Al1Y-2066 for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 14:18:35 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1D5A8150C; Fri, 31 Jan 2025 06:18:59 -0800 (PST) Received: from usa.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 89A773F63F; Fri, 31 Jan 2025 06:18:32 -0800 (PST) From: Sudeep Holla To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Cristian Marussi , Xinqi Zhang , Peng Fan , Guomin Chen Subject: [PATCH 3/3] firmware: arm_scmi: Emit modalias for SCMI devices Date: Fri, 31 Jan 2025 14:18:22 +0000 Message-Id: <20250131141822.514342-3-sudeep.holla@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250131141822.514342-1-sudeep.holla@arm.com> References: <20250131141822.514342-1-sudeep.holla@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250131_061834_557229_FDB1E5F1 X-CRM114-Status: UNSURE ( 8.29 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to enable libkmod lookups for SCMI device objects to their corresponding module, add 'modalias' to the base attribute of SCMI devices. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index 862dd34eca62..7af01664ce7e 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -287,6 +287,17 @@ static int scmi_device_uevent(const struct device *dev, struct kobj_uevent_env * scmi_dev->name); } +static ssize_t modalias_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct scmi_device *scmi_dev = to_scmi_dev(dev); + + return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT, + dev_name(&scmi_dev->dev), scmi_dev->protocol_id, + scmi_dev->name); +} +static DEVICE_ATTR_RO(modalias); + static ssize_t protocol_id_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -308,6 +319,7 @@ static DEVICE_ATTR_RO(name); static struct attribute *scmi_device_attributes_attrs[] = { &dev_attr_protocol_id.attr, &dev_attr_name.attr, + &dev_attr_modalias.attr, NULL, }; ATTRIBUTE_GROUPS(scmi_device_attributes);