From nobody Wed Dec 17 08:54:32 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EA4B191F92 for ; Tue, 18 Mar 2025 17:02:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317357; cv=none; b=HK8wirsZFxrMRXVj3l6NkzkODWB8pKoCC882vM9HYgdIA3/3782hT7kXWAx2MAiXAPMxOlmTyklyR5IpdvBG76dwSxU7klfAwcsE1IuqKkL33V0tI0fZ9aXTX4kQrQGjMwu7pvxJrr5BROOqrlwuQyggmP4lz3xd4MqI3Dz5694= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317357; c=relaxed/simple; bh=3Rfe8x11K1hDNckFVUjLg8e85l+1UVRzlqA4I/qqaKU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I5WV+zebnOEBh27dB0YJQnadZpLGYVH+DfZj0bxYnulxlumCHSpn7BLPHn1fDSylLDVg13spC8M4JqfAZlW2xr57cx9Iz7SwZnJj+vE9S+w88m9r3eoM0qi6yWBZJVYbfdKAd8/Pd8qxF8PDySE5qvGNjzpm/NmbViPcWNGw+/Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 C4917152B; Tue, 18 Mar 2025 10:02:39 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BBA233F673; Tue, 18 Mar 2025 10:02:30 -0700 (PDT) From: Sudeep Holla Date: Tue, 18 Mar 2025 17:01:39 +0000 Subject: [PATCH v2 1/8] driver core: add helper macro for module_faux_driver() boilerplate Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-plat2faux_dev-v2-1-e6cc73f78478@arm.com> References: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> In-Reply-To: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2927; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=3Rfe8x11K1hDNckFVUjLg8e85l+1UVRzlqA4I/qqaKU=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn2acit4KF7FrO7h9Ph/unfFe5tmfL40Vj6F4l9 naD9oG/2HmJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9mnIgAKCRAAQbq8MX7i mN/lD/0XqRFrVRFkPqjLxeN7LtpaLytOPYDPwd2UzrOpQ+qMLu8evCO+xCBKuw4z8IzW5E1wxJz qLFLwlnwBz9NGxJiJZJyqw0vSw1JtJk+cgPbstNgA2RnGI48XyQ1H0t6FU3ZW3xarPIJdLe4hQu dmbpxx3rwBDtS58Uz9zHWGe3scRTfHtLvw6PRRn96CxMR/bmRmhvqtSF1JVs5TSvifC+WyZN0vO 6AY5xedLcmsutOyMGIu+3R2IRg5MPbtnoYIP1oOQr5lnTLN0hp4XubXvnQS2tnt49xt6jlWieDG lGphhpppmNT8jwhrk/xBh6Bc3Cx9PFj3arHDg9B51whGP540AxemPuzKrY2d075gvAVVDa3/j1+ A1lzZfHsBIuFRKyUE5EE0P54++dVaaTXUSk+wAaF5I44WPfpdpOlm5zGMXSEcTjyLDpyPw5Resj FIn46SmSXYavQdppxo4E+x7Y/koBysaBDcgcWeipMaHIsdgWQUDN07GjH3Z8Spd/aiBeMlMZdyL vDoT0Wga6ALUUHJA8gFj38P/0TIEThaoNpGVW12bgpOi9tvZsKZM4jFQKMP7tHyLIa1PSGZLIJm tdWiEvffZvlqLMZjMzOEsr87K2Uff/vDeqw/IA/oF8wKQu/w3lMAqduN0OlzjBYZCLoGGkVfPNi r7xw360aIPu6xRw== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 For simple modules that needs to create a faux device without any additional setup code ends up being a block of duplicated boilerplate. Add a new macro, module_faux_driver(), which help to replaces the those duplicated boilerplate. This macro use the same idea of module_platform_driver() but adds this initial condition to avoid creation of faux device if not necessary. Signed-off-by: Sudeep Holla --- include/linux/device/faux.h | 49 +++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 49 insertions(+) diff --git a/include/linux/device/faux.h b/include/linux/device/faux.h index 9f43c0e46aa45bf492788adcdc081df5cc0c5fc0..4a54736d86595e46c98ac3ab9c4= 5a7e5a344333e 100644 --- a/include/linux/device/faux.h +++ b/include/linux/device/faux.h @@ -15,6 +15,7 @@ =20 #include #include +#include =20 /** * struct faux_device - a "faux" device @@ -66,4 +67,52 @@ static inline void faux_device_set_drvdata(struct faux_d= evice *faux_dev, void *d dev_set_drvdata(&faux_dev->dev, data); } =20 +#define FAUX_DEVICE(__faux_devname) \ +static struct faux_device *__faux_devname##_dev; + +#define FAUX_DEVICE_OPS(__faux_devname, __faux_probe, __faux_remove) \ +static const struct faux_device_ops __faux_devname##_ops =3D { \ + .probe =3D __faux_probe, \ + .remove =3D __faux_remove, \ +}; \ +FAUX_DEVICE(__faux_devname) + +static inline int +__faux_device_register(struct faux_device **faux_dev, const char *name, + const struct faux_device_ops *faux_ops, bool condition) +{ + struct faux_device *fdev; + + if (!condition) + return 0; + + fdev =3D faux_device_create(name, NULL, faux_ops); + if (!fdev) + return -ENODEV; + + *faux_dev =3D fdev; + return 0; +} + +#define faux_device_register(faux_dev, faux_devname, init_condition) \ + __faux_device_register(faux_dev, __stringify(faux_devname), \ + &faux_devname##_ops, init_condition) + +#define faux_device_unregister(faux_dev, ...) \ + faux_device_destroy(*faux_dev) + +/* module_faux_driver() - Helper macro for faux drivers that don't do + * anything special in module init/exit. This eliminates a lot of + * boilerplate. Each module may only use this macro once, and + * calling it replaces module_init() and module_exit(). The module init + * creates a faux device if the init condition is met and module exit + * destroys the created device. FAUX_DEVICE_OPS must be used to declare + * faux device ops and the device pointer. + */ +#define module_faux_driver(__faux_devname, __faux_probe, __faux_remove, \ + __init_condition) \ + FAUX_DEVICE_OPS(__faux_devname, __faux_probe, __faux_remove) \ + module_driver(__faux_devname##_dev, faux_device_register, \ + faux_device_unregister, __faux_devname, __init_condition) + #endif /* _FAUX_DEVICE_H_ */ --=20 2.34.1 From nobody Wed Dec 17 08:54:32 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 908D7211A11; Tue, 18 Mar 2025 17:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317358; cv=none; b=Oj8SDEqPgmGyuVa+q/6sdWVJyULGoBsAYk4uYGjlgI1GrqzQ4xEFznuOHIovm1/7xLs04cbT/l77nFJyW5W5z27GTl1eANSj5MOkBDLvy2ye5462A9PO5Q8idqP8juV++ffA59Re33dKiD72VZb4k6xuJzy8KYs4TvxfFHqLMZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317358; c=relaxed/simple; bh=G9kihMReYnuSblQmsr+d7DA+5UjTgx2Nd7YXDM3E4H0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nw6eFbSwFq/zZ8JtzAy032AGH25ugI/dJAb464FgzL+fK77uVDqeYVKEjSfavbRfasRIj9/12UlHtyUdeUhUX9mw4tQzb8ZKPLtb+1Qen3M7peb6BDEYgbnWAsTmfGZnt4ruqV3CZGceZzjYD1BwPeMmcdihT/Z3hA5CmRNVN6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 4183A16F3; Tue, 18 Mar 2025 10:02:41 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9E1433F673; Tue, 18 Mar 2025 10:02:31 -0700 (PDT) From: Sudeep Holla Date: Tue, 18 Mar 2025 17:01:40 +0000 Subject: [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-plat2faux_dev-v2-2-e6cc73f78478@arm.com> References: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> In-Reply-To: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman , Lorenzo Pieralisi , "Rafael J. Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2646; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=G9kihMReYnuSblQmsr+d7DA+5UjTgx2Nd7YXDM3E4H0=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn2aciBJKtfha22avzC5Tb0MJbrWJtrCcKR73lA zXDzVm2dc6JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9mnIgAKCRAAQbq8MX7i mO1eD/49KrYE5mjwjUXjG2S0M+aANb+/iiS/cIYRvGYXLLQPp1kIWXtPQ/iftzPP+Q3k0KLe/7z fO4Kxg2+/PTc/mRXQdngAhSkkCF/ubc3w+KDtIj5kr1Jsc3NOqzut7UccjX6eY4kSEF6GyGacX0 V17GO5wrgRP+RdE7kHoKV/a4hK+pkq2XhnSMW4ilPKOZOnJ6+9BQ7qC6SuqmgMpnhnUsASgOJP+ gwfbUtnvdFsSzPjhd7iM4+uxdVR+KJjrAzlTQSKIYvHp0rNfzSQkIh0s5gy6OauH5Z93eA2qLYw vwm5YNPuNnWEFFFlbKcmqJd0X9G553fy0VPilq7xX7t9vQem8rQHm2WZf51Wk9Rlr6GFAPyfHk1 MZlvI4+VD1F6qBoAzeGSp0T9Ukq9ilZDQgx/Bvx0updPl8BHRjgaeaQto+Tx/qAHKjd+GtMhFkW 4H+ql2fBGOhT9eeBfJQkipnXTRk7rkcfvcCkiLrdr6+FfiMtIezHW4V70Gmbr+1ERhyXD9PTxy5 ZJChxwrY3fgxxxDTaSjsWV/1oE4Z3WmnuTgYPwi8s+zLL03ObhX8KwCMEc6tJU01WOL9RplRo9o WlmGqDKpUAOOgMaV9vk9VrHI8yGzY0XnAm8hhdnZNFoiSv0r68AwviZ+taXa2XAYrFrpwizqpsV AwvPJ3djSTUp4mQ== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The PSCI cpuidle driver does not require the creation of a platform device. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate the driver to utilize the faux bus, given that the platform device it previously created was not a real one anyway. This will simplify the code, reducing its footprint while maintaining functionality. Cc: Lorenzo Pieralisi Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: linux-pm@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/cpuidle/cpuidle-psci.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 2562dc001fc1de69732ef28f383d2809262a3d96..5d4d6daed36d8540ba2ce3dc54a= 3180731b03d22 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -404,14 +404,14 @@ static int psci_idle_init_cpu(struct device *dev, int= cpu) * to register cpuidle driver then rollback to cancel all CPUs * registration. */ -static int psci_cpuidle_probe(struct platform_device *pdev) +static int psci_cpuidle_probe(struct faux_device *fdev) { int cpu, ret; struct cpuidle_driver *drv; struct cpuidle_device *dev; =20 for_each_possible_cpu(cpu) { - ret =3D psci_idle_init_cpu(&pdev->dev, cpu); + ret =3D psci_idle_init_cpu(&fdev->dev, cpu); if (ret) goto out_fail; } @@ -431,28 +431,4 @@ static int psci_cpuidle_probe(struct platform_device *= pdev) return ret; } =20 -static struct platform_driver psci_cpuidle_driver =3D { - .probe =3D psci_cpuidle_probe, - .driver =3D { - .name =3D "psci-cpuidle", - }, -}; - -static int __init psci_idle_init(void) -{ - struct platform_device *pdev; - int ret; - - ret =3D platform_driver_register(&psci_cpuidle_driver); - if (ret) - return ret; - - pdev =3D platform_device_register_simple("psci-cpuidle", -1, NULL, 0); - if (IS_ERR(pdev)) { - platform_driver_unregister(&psci_cpuidle_driver); - return PTR_ERR(pdev); - } - - return 0; -} -device_initcall(psci_idle_init); +module_faux_driver(psci_cpuidle, psci_cpuidle_probe, NULL, true); --=20 2.34.1 From nobody Wed Dec 17 08:54:32 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC529211A3C; Tue, 18 Mar 2025 17:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317356; cv=none; b=U5BnfFH60WB6KO/HC9h4l+UtK01f5P/OCqCxljGKyMk6i67Z67cQ9VYnYJMJJStk8yJPf7GdUZ+cirDX9aK0/a+OzK1EE3P4jY0hCbwptnXKxgsBvSAQs9a2YoEyq39BAikIi5mV3Cit6eGeH0ELdyG5I7NcPCul6A6fMxpiMys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317356; c=relaxed/simple; bh=ob85jxBOyOzqJOSx4lN4UtyjGcEY7Ygqfx6BmaDo+vY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c9FQ8yNiwYobLSj20czvJYekm+3nymQcm4I6bvPvpa2I4kCXGMBR2CoTDOdiZu/xjALXkR6ofkXxe/Vqf8sf77v+0QvxEFtkOCSI1H6pSI2aenyiFSfr6LCdTGzT2+Z+wbtZIj8vOtqsEh5MwY8VAZ5is3M4LKRYhuQIHOIw+tk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 B302F1A25; Tue, 18 Mar 2025 10:02:42 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1B0EB3F673; Tue, 18 Mar 2025 10:02:32 -0700 (PDT) From: Sudeep Holla Date: Tue, 18 Mar 2025 17:01:41 +0000 Subject: [PATCH v2 3/8] hwrng: arm-smccc-trng - transition to the faux device interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-plat2faux_dev-v2-3-e6cc73f78478@arm.com> References: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> In-Reply-To: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman , Andre Przywara , Herbert Xu , Jeff Johnson , linux-crypto@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3652; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=ob85jxBOyOzqJOSx4lN4UtyjGcEY7Ygqfx6BmaDo+vY=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn2aciwZGAMleW3NcjgDCN5dHz2z6Vsk/HAPqNI A6SJbAiJ6iJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9mnIgAKCRAAQbq8MX7i mLcwD/93elWVanJoCev4Qc0VH+TNl1c45MuHNW9+X7PzawOQgnfbkAbHOmFstIU5JPjBtNUo0Xg CZUUolNCJs0Ci1P0HQPHu7PRkV3pBs9T58EjtT09y+EtCB+Z/2koEpxU67uUu4ssqpi8CRseLUT YXHe1sUz4qLBy/ddnodUMXVRiz9LdWbZ10/ZkDZIvpXLeKZPmGVu3NTZSbNvidTR2zvYxZiZCJ/ 7PSHXl1FIvPHte9ag8Bc3vzwuaezGkSK1GfihqYk5gEKfxKdxrr3m2I+sC31mYDSBvqCQLL/Olp q9DUnDSv2+DU1eobec28QSeRVFhDY7pcFddOuqQP9xGHslBKcBhiA3z1FOBdaMNeZOKNaFK/J/O ZYEaNur9iEXyDSMD++JQPVtqlxTQXK2Ifkh/fIHIyyQ8cJI7RimJtIy1ajkFzDPpeLkCkkaEUib 3Je8v3Y+BQERUQ7JeX1KiufNbQXeWRFsz31mkSyvFE1obFa+hLWkWqRwuc+lCDqvBJ637USxzUo Ok65Nyh/ibICmkDk+YKXcWYlS75aWTDdkfkRhaBhitCJnfUWiQn1ewriR509q5cjZuQHcz39dT9 O45QwjdryMeSCkYdKKJ/GVj/eT2YSmhJdhE2Ep4YfhKd8WIDftVVjjrbbihxJ+KBltjVI1HaM1C OkFPgxDV/bO2G+A== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The Arm SMCCC based true random number generator driver does not require the creation of a platform device/driver. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate the driver to utilize the faux bus, given that the platform device it previously created was not a real one anyway. This will simplify the code, reducing its footprint while maintaining functionality. Cc: Andre Przywara Cc: Herbert Xu Cc: Jeff Johnson Cc: linux-crypto@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/char/hw_random/arm_smccc_trng.c | 19 +++++++------------ drivers/firmware/smccc/smccc.c | 17 ----------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/drivers/char/hw_random/arm_smccc_trng.c b/drivers/char/hw_rand= om/arm_smccc_trng.c index dcb8e7f37f25c6b39f76050369b9f324b7fb2e33..1c70e8bbea956c8e1f07a8083c3= 3a8d011772c26 100644 --- a/drivers/char/hw_random/arm_smccc_trng.c +++ b/drivers/char/hw_random/arm_smccc_trng.c @@ -16,9 +16,11 @@ #include #include #include -#include +#include #include =20 +#include + #ifdef CONFIG_ARM64 #define ARM_SMCCC_TRNG_RND ARM_SMCCC_TRNG_RND64 #define MAX_BITS_PER_CALL (3 * 64UL) @@ -94,29 +96,22 @@ static int smccc_trng_read(struct hwrng *rng, void *dat= a, size_t max, bool wait) return copied; } =20 -static int smccc_trng_probe(struct platform_device *pdev) +static int smccc_trng_probe(struct faux_device *fdev) { struct hwrng *trng; =20 - trng =3D devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL); + trng =3D devm_kzalloc(&fdev->dev, sizeof(*trng), GFP_KERNEL); if (!trng) return -ENOMEM; =20 trng->name =3D "smccc_trng"; trng->read =3D smccc_trng_read; =20 - return devm_hwrng_register(&pdev->dev, trng); + return devm_hwrng_register(&fdev->dev, trng); } =20 -static struct platform_driver smccc_trng_driver =3D { - .driver =3D { - .name =3D "smccc_trng", - }, - .probe =3D smccc_trng_probe, -}; -module_platform_driver(smccc_trng_driver); +module_faux_driver(smccc_trng, smccc_trng_probe, NULL, smccc_trng_availabl= e); =20 -MODULE_ALIAS("platform:smccc_trng"); MODULE_AUTHOR("Andre Przywara"); MODULE_DESCRIPTION("Arm SMCCC TRNG firmware interface support"); MODULE_LICENSE("GPL"); diff --git a/drivers/firmware/smccc/smccc.c b/drivers/firmware/smccc/smccc.c index a74600d9f2d72a5aa0096004f53088c255927a43..cc131894623eff95f906ebf0851= 1c123add7fe88 100644 --- a/drivers/firmware/smccc/smccc.c +++ b/drivers/firmware/smccc/smccc.c @@ -9,7 +9,6 @@ #include #include #include -#include #include =20 static u32 smccc_version =3D ARM_SMCCC_VERSION_1_0; @@ -66,19 +65,3 @@ s32 arm_smccc_get_soc_id_revision(void) return smccc_soc_id_revision; } EXPORT_SYMBOL_GPL(arm_smccc_get_soc_id_revision); - -static int __init smccc_devices_init(void) -{ - struct platform_device *pdev; - - if (smccc_trng_available) { - pdev =3D platform_device_register_simple("smccc_trng", -1, - NULL, 0); - if (IS_ERR(pdev)) - pr_err("smccc_trng: could not register device: %ld\n", - PTR_ERR(pdev)); - } - - return 0; -} -device_initcall(smccc_devices_init); --=20 2.34.1 From nobody Wed Dec 17 08:54:32 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B5F01C84B3; Tue, 18 Mar 2025 17:02:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317357; cv=none; b=j9L8zbRgFhWZHnu9b7JMPeQnpSFnM2easckT0e4lXqO/tL0pmrapU7pMYeup3Q8ppHLLI6dJDvMm9ydq0E4JwPmTk+BgxqIVcLMpR59ey+T7IvFrQNhknncNw5ABciseay524TwbeVty214s1/VeNLYRD0RSDoQx5hCAJ/NbU08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317357; c=relaxed/simple; bh=NxGa/BYNzmW9bOjmp9UiIR5gFv8/hjmQZjBr2tY5hTo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k7ukxEhHg/NWkfec0zd6q8V+355N2wikENEY7iZe6rYtS5n7jWM/P27jz4FCSOxcr19B9UaAIV5ZtBzeu1NOLEqC9qiGaXy0zLuCDns+6E25ZosjxhxzekgKYeVGhvtwOZalK3w9bPHml9cr30cx8Fx2SxYQYTmcmmGs7Vs+FwI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 306561BB2; Tue, 18 Mar 2025 10:02:44 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8CAF43F673; Tue, 18 Mar 2025 10:02:34 -0700 (PDT) From: Sudeep Holla Date: Tue, 18 Mar 2025 17:01:42 +0000 Subject: [PATCH v2 4/8] rtc: efi: Transition to the faux device interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-plat2faux_dev-v2-4-e6cc73f78478@arm.com> References: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> In-Reply-To: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman , Ard Biesheuvel , Alexandre Belloni , linux-rtc@vger.kernel.org, linux-efi@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3019; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=NxGa/BYNzmW9bOjmp9UiIR5gFv8/hjmQZjBr2tY5hTo=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn2aciebbTzQhRmgg/xlGI0w8PqOp31fwsjXo+Z VYP7+JPVHyJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9mnIgAKCRAAQbq8MX7i mOhaD/9vLdO8FgtbCKPTY7or2IRU0owZ2m7r3H583ZV3uKqgaoK41ui4StiX0NpkkGINjAItgd/ UxRr9EbKLD30OIo+8FFRZ6Dhg48nYj8mkxleLPhnbqMW1yVmlLKhb5S+JjV9ynqETuk/USSPeoQ xRh5fJiIHH4O/E64SkLxwR+UGC45sy9w9MT6lh7o52d6vq5Nbu6agZkjpyOHrdSfThMrtBmpOPJ d2ExuvwvXSvFYs6LG03vRra/RF5RtpFBn8oXChDSNE6W9w9eCMxdAxIUo0wJUsWk99mfC4plJvA CI4b1a7SQM95Jn+0ANbRGas3eXOSU7/O/3i82sepeKHh1UaC4RQJ8RUFAe/Jr3eKK1WaexSLy+5 dx6SbEazaAAwRis+75ZOrLrXFPVsYs0/j8NDAPMXZjm/kvxnlyxH/yj2Lbvr+yqjkuUqB0IGLKF +IW9mo1UNVPJgF58xl8ZcuGg/VptP353q3pnt6X5d+0gAMo6BKDPmXEmL9UYqBNg9DydhBaoCL3 zRALszABPuyUwkRvpwNS1NnHdmlv/XOBbRvVzHlm8dqT9/j0/E3I6B642oGQ5DoJ3rZwWfRNod8 9B0PoHX9I82VLmog4AnH8ERM8xrRNC31TJj171k4Mn0x3yTJBEGA5UuTDVPOa9p0GZmWqfG7UIE vHTr43UocxIsIMg== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The EFI RTC driver does not require the creation of a platform device. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate the driver to utilize the faux bus, given that the platform device it previously created was not a real one anyway. This will simplify the code, reducing its footprint while maintaining functionality. Cc: Ard Biesheuvel Cc: Alexandre Belloni Cc: linux-rtc@vger.kernel.org Cc: linux-efi@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/firmware/efi/efi.c | 3 --- drivers/rtc/rtc-efi.c | 16 +++++----------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 7309394b8fc98cf7a3424af209b752f0251c8c89..8aebc747c65bc1b63d514a50fe6= f35a9e3c1af0a 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -427,9 +427,6 @@ static int __init efisubsys_init(void) } } =20 - if (efi_rt_services_supported(EFI_RT_SUPPORTED_TIME_SERVICES)) - platform_device_register_simple("rtc-efi", 0, NULL, 0); - /* We register the efi directory at /sys/firmware/efi */ efi_kobj =3D kobject_create_and_add("efi", firmware_kobj); if (!efi_kobj) { diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c index fa8bf82df9488e7d1c23c058b4a3032dde74bc6e..681d917d541e51b37f2d59b0567= caf6aa8bf05f4 100644 --- a/drivers/rtc/rtc-efi.c +++ b/drivers/rtc/rtc-efi.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include =20 @@ -254,7 +254,7 @@ static const struct rtc_class_ops efi_rtc_ops =3D { .proc =3D efi_procfs, }; =20 -static int __init efi_rtc_probe(struct platform_device *dev) +static int __init efi_rtc_probe(struct faux_device *dev) { struct rtc_device *rtc; efi_time_t eft; @@ -268,7 +268,7 @@ static int __init efi_rtc_probe(struct platform_device = *dev) if (IS_ERR(rtc)) return PTR_ERR(rtc); =20 - platform_set_drvdata(dev, rtc); + faux_device_set_drvdata(dev, rtc); =20 rtc->ops =3D &efi_rtc_ops; clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features); @@ -282,15 +282,9 @@ static int __init efi_rtc_probe(struct platform_device= *dev) return devm_rtc_register_device(rtc); } =20 -static struct platform_driver efi_rtc_driver =3D { - .driver =3D { - .name =3D "rtc-efi", - }, -}; - -module_platform_driver_probe(efi_rtc_driver, efi_rtc_probe); +module_faux_driver(rtc_efi, efi_rtc_probe, NULL, + efi_rt_services_supported(EFI_RT_SUPPORTED_TIME_SERVICES)); =20 MODULE_AUTHOR("dann frazier "); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("EFI RTC driver"); -MODULE_ALIAS("platform:rtc-efi"); --=20 2.34.1 From nobody Wed Dec 17 08:54:32 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1494120FA85; Tue, 18 Mar 2025 17:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317359; cv=none; b=Mq9v7PYxiGNId447+e8IYwEUharR2kivyBIocZUDix+29wWdS8GzPC/UMtoUJCzcMcQgJau+ml1HdEM8nn10VGAEuEm6rwEf2SHjcMBgsVH1guhi9QyLy2dgAlZwR2IWd5Br1X4DYD/Nzt4J4Tan+sMEhhuTGbOHbzLA/R7accE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317359; c=relaxed/simple; bh=k6j3DBsimegxPoU9UiZ9TSkg2hg0aryPCM5hJl5zw4g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qm5mbT+mb2dAzUqdTXTNJjIpFVjAaQez5AWQ2CSlOWcFLdWXiBXRmzrrl6ewnav1A5zcJhkAFL1NRrcDLOUcOLqGTxtULGsJv7dYPq+wmWmEM+4Xur1/oladNseZK08VKnh/T2n28dMD0DtiSp3SKYxiHNkUEBpKjUCMFFqPak8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 5A8001BF7; Tue, 18 Mar 2025 10:02:45 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0A2A53F673; Tue, 18 Mar 2025 10:02:35 -0700 (PDT) From: Sudeep Holla Date: Tue, 18 Mar 2025 17:01:43 +0000 Subject: [PATCH v2 5/8] virt: efi_secret: Transition to the faux device interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-plat2faux_dev-v2-5-e6cc73f78478@arm.com> References: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> In-Reply-To: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman , Ard Biesheuvel , linux-efi@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4350; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=k6j3DBsimegxPoU9UiZ9TSkg2hg0aryPCM5hJl5zw4g=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn2aciefH/zbE9cqyOtTLIfCPlafuR7jl/RVr/f rkxbVS6LgOJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9mnIgAKCRAAQbq8MX7i mJO4D/4wgOELwUSW3aUd98WcEmrln+VhUVv4IND46FmOMaLpLzOPpA4zIA0yrVUMS+iJO8HVy92 nh4r27qvdgXBNORd3jej4FswWHuPHBV07OZrwVCEGDUQVPevirLb1FeT23ZSkCxchWsuWMgKtt9 +GXgXqzI1RhXTyTmw3DRmzbWeSzjnrANxekYJOx1u8Qitn6DMSoYDktuaGiVH50kp4trjhQZo9k TQrAZQsEh30lk+18+uzjivnlpBeJgUN8CG/9m3f0OR9BHSoZbY9EWp0YhkfGmnVxFX10UvQacMq r0oDVhQIZ1xtKZja3tY2jO6omSIH3CxridohV7EMgjDJ3/pFjCN9KYdqeQrI7/+GJnk6eAEygUM wpunQDRO2iyjGmFUGuBj4JV5DN4+IVY5bXdAXQhdpFpxV8RG6N/OA4TxnmoMOABOCcd707gbtUi lm7Mw4e8CH1OZtdn/5Pb4rXUjykcNNtdirM/KKREGJmuT0j69LDcc8x2npo2TSh6HtQkm+W3LPQ 2Z8zQo8BQN6DnFqJcu/7BDLeflK9Rg1yX2kqFRdKhgFZ5uEn7jICyTP5616vTZaORzucJsEtkQN zirUeRcMCC/B6+sJTmbhkq5l5AvQGOPB96Ldy93CcYriykU2xId03YvkziUD0BE+h67Z0B5p/2U 1efnVjM+GiVDahg== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The EFI secret area driver does not require the creation of a platform device. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate the driver to utilize the faux bus, given that the platform device it previously created was not a real one anyway. This will simplify the code, reducing its footprint while maintaining functionality. Cc: Ard Biesheuvel Cc: linux-efi@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/firmware/efi/efi.c | 5 ----- drivers/virt/coco/efi_secret/efi_secret.c | 29 ++++++++-------------------= -- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 8aebc747c65bc1b63d514a50fe6f35a9e3c1af0a..862b7744c28ecc9e5a64bbb3533= c34119f50267f 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -465,11 +465,6 @@ static int __init efisubsys_init(void) if (efi_enabled(EFI_DBG) && efi_enabled(EFI_PRESERVE_BS_REGIONS)) efi_debugfs_init(); =20 -#ifdef CONFIG_EFI_COCO_SECRET - if (efi.coco_secret !=3D EFI_INVALID_TABLE_ADDR) - platform_device_register_simple("efi_secret", 0, NULL, 0); -#endif - return 0; =20 err_remove_group: diff --git a/drivers/virt/coco/efi_secret/efi_secret.c b/drivers/virt/coco/= efi_secret/efi_secret.c index 1864f9f80617e082feb574a15327949972c8cc1e..a60976750bef787c78401bf4569= ee5d0c7d2b5f4 100644 --- a/drivers/virt/coco/efi_secret/efi_secret.c +++ b/drivers/virt/coco/efi_secret/efi_secret.c @@ -16,7 +16,7 @@ * is the GUID of the secret entry, and its content is the secret data. */ =20 -#include +#include #include #include #include @@ -152,17 +152,12 @@ static const struct inode_operations efi_secret_dir_i= node_operations =3D { .unlink =3D efi_secret_unlink, }; =20 -static int efi_secret_map_area(struct platform_device *dev) +static int efi_secret_map_area(struct faux_device *dev) { int ret; struct efi_secret *s =3D efi_secret_get(); struct linux_efi_coco_secret_area *secret_area; =20 - if (efi.coco_secret =3D=3D EFI_INVALID_TABLE_ADDR) { - dev_err(&dev->dev, "Secret area address is not available\n"); - return -EINVAL; - } - secret_area =3D memremap(efi.coco_secret, sizeof(*secret_area), MEMREMAP_= WB); if (secret_area =3D=3D NULL) { dev_err(&dev->dev, "Could not map secret area EFI config entry\n"); @@ -191,7 +186,7 @@ static int efi_secret_map_area(struct platform_device *= dev) return ret; } =20 -static void efi_secret_securityfs_teardown(struct platform_device *dev) +static void efi_secret_securityfs_teardown(struct faux_device *dev) { struct efi_secret *s =3D efi_secret_get(); int i; @@ -210,7 +205,7 @@ static void efi_secret_securityfs_teardown(struct platf= orm_device *dev) dev_dbg(&dev->dev, "Removed securityfs entries\n"); } =20 -static int efi_secret_securityfs_setup(struct platform_device *dev) +static int efi_secret_securityfs_setup(struct faux_device *dev) { struct efi_secret *s =3D efi_secret_get(); int ret =3D 0, i =3D 0, bytes_left; @@ -307,7 +302,7 @@ static void efi_secret_unmap_area(void) } } =20 -static int efi_secret_probe(struct platform_device *dev) +static int efi_secret_probe(struct faux_device *dev) { int ret; =20 @@ -326,23 +321,15 @@ static int efi_secret_probe(struct platform_device *d= ev) return ret; } =20 -static void efi_secret_remove(struct platform_device *dev) +static void efi_secret_remove(struct faux_device *dev) { efi_secret_securityfs_teardown(dev); efi_secret_unmap_area(); } =20 -static struct platform_driver efi_secret_driver =3D { - .probe =3D efi_secret_probe, - .remove =3D efi_secret_remove, - .driver =3D { - .name =3D "efi_secret", - }, -}; - -module_platform_driver(efi_secret_driver); +module_faux_driver(efi_secret, efi_secret_probe, efi_secret_remove, + efi.coco_secret !=3D EFI_INVALID_TABLE_ADDR); =20 MODULE_DESCRIPTION("Confidential computing EFI secret area access"); MODULE_AUTHOR("IBM"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:efi_secret"); --=20 2.34.1 From nobody Wed Dec 17 08:54:32 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4691F212D7B; Tue, 18 Mar 2025 17:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317359; cv=none; b=u8UmCeQwgnf2uuKFQhtmTu5KS5fDkxYGYnoklYskW+DXfxPHHqcr+fvslecUgkRyHk4HQVVagSIbm9x87m2r1BR8wuBGoC/VtrfJniLclZsMpfhIih3UEyC3xeRT/PKLbE7g2aMOZ+bitHTD3KfUGvHGpS012wLTw2Vh153RtAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317359; c=relaxed/simple; bh=gRkb6p8XPCkCChpfA0g/BMq90thBf9o9KpCxbQ5q/L4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iKHVaiDARdkEp+DSvD5/xMP1wMBbGY09y/pAc6MU/VxyzDPNMgIE9w89yp8OrSw9aXEZ2vonhYRu6OfqlHeysdRstLdbdGq56ygb/JaQ1WazBrqz5TJN0QewuggnzesTwzWcKP5oc/HsSXr0jK+GXWuyrOL8xN4hpvZx6QJNC+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 84742152B; Tue, 18 Mar 2025 10:02:46 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3446E3F673; Tue, 18 Mar 2025 10:02:37 -0700 (PDT) From: Sudeep Holla Date: Tue, 18 Mar 2025 17:01:44 +0000 Subject: [PATCH v2 6/8] efi: efivars: Transition to the faux device interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-plat2faux_dev-v2-6-e6cc73f78478@arm.com> References: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> In-Reply-To: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman , Ard Biesheuvel , linux-efi@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2136; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=gRkb6p8XPCkCChpfA0g/BMq90thBf9o9KpCxbQ5q/L4=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn2aciI9VxHIej0aKWzdG0ZStyVb+NQKRpF5n/Q ttdDeVqi9WJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9mnIgAKCRAAQbq8MX7i mIi6D/9h6GsGE8BacOX3uMQGEHySIAN9eHGjqgy+PGAtv4oy2OaTmZYwQS4j1bFA+C5x3wYbQdj VLXS+P/54M8C29XsUOcqyBLy4pZU4CDZKCEw+f8yTeYpLYEcrTE3OfIEi9VrYYXa3QB8p8FSqEI nPz7gI+OsFaHWh9QxBo7m3s6Jnw0Xp4K556IJZpUJ6C78zEHOswBNuL2LuPKkgSdP3GMsp3T5GF B0vVne8Un8M98XCs7QKV+1zq+j4pfVioHIuFVlMObV/RmAJeEqzCu3r3UNm2zgYLn1DDODXARvz j2z3TkNkqE73eSYn8E6O7Pqv2Dzr6SKsir7u6YRBPmXeAy08Mq6jmUunENoxrQwAxR/ZgJd2T3z D0ctTht3d/OyWUI240P807NzA/4ywnmfIJ8cWw1Tlt2e9vZyC9gccsjHTf7iFY2gbI0jGLR0aLz jRf+NC/cPnMBgWkyht/aFLO7PcDoATGoTihU/0WORFUK5FwMXQa9LDERwvcX3YfmROa707easdh jAENC68BaBnUipuIfod6Sqzj6Bdnvel9tMM7noqXMTCSlWct+YmtgyviyC/mm9KcH+E5Zk4iOWC GZ0NJne3WB4m0mySGYC800zg9lfVLmTxI66HaJqVwZ7H1Hm5Ood/bGsScLZ3MmEzq7KSfhxczkg WcsZDBwA21e70ww== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The "efivars" platform device is created just to enable the efi-pstore module to autoload based on it. It doesn't have to be platform device though. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate this efivars device to utilize the faux bus, given that the platform device it previously created was not a real one anyway. The modalias is retained here as efi-pstore module is dependent on it. Cc: Ard Biesheuvel Cc: linux-efi@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/firmware/efi/efi-pstore.c | 2 +- drivers/firmware/efi/efi.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-p= store.c index a253b61449459eca31afc6ca780a20c4557659ba..eed756a59bba3b5a58cd2e23840= 0c3c12fd5edd5 100644 --- a/drivers/firmware/efi/efi-pstore.c +++ b/drivers/firmware/efi/efi-pstore.c @@ -301,4 +301,4 @@ module_exit(efivars_pstore_exit); =20 MODULE_DESCRIPTION("EFI variable backend for pstore"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:efivars"); +MODULE_ALIAS("faux:efivars"); diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 862b7744c28ecc9e5a64bbb3533c34119f50267f..dc5c24a7ca540cac342ceddcdbf= 75b55bf82c889 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -443,7 +443,7 @@ static int __init efisubsys_init(void) error =3D efivar_ssdt_load(); if (error) pr_err("efi: failed to load SSDT, error %d.\n", error); - platform_device_register_simple("efivars", 0, NULL, 0); + faux_device_create("efivars", NULL, NULL); } =20 BLOCKING_INIT_NOTIFIER_HEAD(&efivar_ops_nh); --=20 2.34.1 From nobody Wed Dec 17 08:54:32 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96734213232; Tue, 18 Mar 2025 17:02:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317361; cv=none; b=L7aq1FWMemg8ytgzPphSWU0bfE8YFrHo9UGjXqMz+JxgHmBvZLwuXxXijkzFzzSXD3BlrQ7xMVN6JObjzxGUHcI7WZ7MmXB7+o5Ryh4IqhueMslfmbGFK/0PGOLygQ495ohNG1VA/93/HkShPV103FWk4mKuQhPS81wsd6H17T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317361; c=relaxed/simple; bh=/bAirk6rBlMWq+httm7PTGquFnI6pduDOeCYwyFLe+o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NH/7R0HsAw8lj4KFXR077NhocUkEpBH9h5IDSk6yEDO8YFGZl3/DdF9OUCHNAdbEaN0kk9XjFGPCK7VnUzmtsCKtbMbzxC66guma+EaMZudCyjOh118q4AOsKQltfqc/TsTtFc/os1fPa4HufjwHAC1Dw5lFaxG8U1v84tNMDes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 D293A16F3; Tue, 18 Mar 2025 10:02:47 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5E5BC3F673; Tue, 18 Mar 2025 10:02:38 -0700 (PDT) From: Sudeep Holla Date: Tue, 18 Mar 2025 17:01:45 +0000 Subject: [PATCH v2 7/8] ACPI: APEI: EINJ: Transition to the faux device interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-plat2faux_dev-v2-7-e6cc73f78478@arm.com> References: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> In-Reply-To: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman , "Rafael J. Wysocki" , Borislav Petkov , linux-acpi@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3381; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=/bAirk6rBlMWq+httm7PTGquFnI6pduDOeCYwyFLe+o=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn2aci6wpndPy+2NHMogIGoHzkxDmoWhUU/C4rZ xszYf2K0ZGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9mnIgAKCRAAQbq8MX7i mLRsEAC0afJOZaEhOmva14LMUcOyvGqu9EFoBmReJtr6LdbtgE7iwmLqhF8jhvAmgSOd3R00z+T tLfNTvnytWkGDrfiZTbLcN0mmrqa3ItEkbmZYaSBV6V1d8gnINlM4SEbz2L+gkofPub9FFYdJ/6 ZK4b37Ry54UybijpKkLEkZBqr4otPfuBHUa2yH5paO1wAlqrXvpj+dteOJt/J9nTmV2rOuY/Tlf +io4pUh0KPxNyzxBVHJaKbd3pyKmILIBnl/V0baEdHGMIJsf3tyeEwfJ0qGp41tMLDHdsFTBbWH SmbPzjLDMCCOCgVa6lYeGVHxnLYipq0l0PkeQkxhaZ1UfO3INutwhTNvCrYc8oYGareB1XbfUBJ 9uXibFM5PCVbw9ziRJ6fXZxqgBsVc6rk4j3Yie/Z0er3oQgJZY867tBXYup/APxliWfkMd5uB2x s7PVefCoJ6WgZUa5I5KgMOwx+pTXiylRAYAY2m+BCOE/0T1bdiP4vsNib9D5OAkhi5TNNeTwaWo Lh1HWEY/BhoIBHYMMrp+9Lb+bim+XJDzmWqAque7xAePnuDo/VILviDrVIDTbnrPE3QoW5SZqTA g3qCT6ELO5/AJGvgmqAdNRN5CVVkdDYZPtOZ8SCwVrcWadnDpwrUAEGhnQOisiYW1nj4lLYdj/3 4zxxywqt8RvqiMA== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The APEI error injection driver does not require the creation of a platform device. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate the driver to utilize the faux bus, given that the platform device it previously created was not a real one anyway. This will simplify the code, reducing its footprint while maintaining functionality. Cc: "Rafael J. Wysocki" Cc: Borislav Petkov Cc: linux-acpi@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/acpi/apei/einj-core.c | 51 +++++----------------------------------= ---- 1 file changed, 6 insertions(+), 45 deletions(-) diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c index 04731a5b01faaba534bad853d0acc4c8a873a53b..5fddd01074bafab2f7b23fd7ef9= f863c0856637b 100644 --- a/drivers/acpi/apei/einj-core.c +++ b/drivers/acpi/apei/einj-core.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include =20 #include "apei-internal.h" @@ -749,7 +749,7 @@ static int einj_check_table(struct acpi_table_einj *ein= j_tab) return 0; } =20 -static int __init einj_probe(struct platform_device *pdev) +static int __init einj_probe(struct faux_device *fdev) { int rc; acpi_status status; @@ -838,6 +838,8 @@ static int __init einj_probe(struct platform_device *pd= ev) =20 pr_info("Error INJection is initialized.\n"); =20 + einj_initialized =3D true; + return 0; =20 err_release: @@ -851,7 +853,7 @@ static int __init einj_probe(struct platform_device *pd= ev) return rc; } =20 -static void __exit einj_remove(struct platform_device *pdev) +static void __exit einj_remove(struct faux_device *fdev) { struct apei_exec_context ctx; =20 @@ -872,48 +874,7 @@ static void __exit einj_remove(struct platform_device = *pdev) acpi_put_table((struct acpi_table_header *)einj_tab); } =20 -static struct platform_device *einj_dev; -/* - * einj_remove() lives in .exit.text. For drivers registered via - * platform_driver_probe() this is ok because they cannot get unbound at - * runtime. So mark the driver struct with __refdata to prevent modpost - * triggering a section mismatch warning. - */ -static struct platform_driver einj_driver __refdata =3D { - .remove =3D __exit_p(einj_remove), - .driver =3D { - .name =3D "acpi-einj", - }, -}; - -static int __init einj_init(void) -{ - struct platform_device_info einj_dev_info =3D { - .name =3D "acpi-einj", - .id =3D -1, - }; - int rc; - - einj_dev =3D platform_device_register_full(&einj_dev_info); - if (IS_ERR(einj_dev)) - return PTR_ERR(einj_dev); - - rc =3D platform_driver_probe(&einj_driver, einj_probe); - einj_initialized =3D rc =3D=3D 0; - - return 0; -} - -static void __exit einj_exit(void) -{ - if (einj_initialized) - platform_driver_unregister(&einj_driver); - - platform_device_unregister(einj_dev); -} - -module_init(einj_init); -module_exit(einj_exit); +module_faux_driver(acpi_einj, einj_probe, __exit_p(einj_remove), true); =20 MODULE_AUTHOR("Huang Ying"); MODULE_DESCRIPTION("APEI Error INJection support"); --=20 2.34.1 From nobody Wed Dec 17 08:54:32 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E10672135BD; Tue, 18 Mar 2025 17:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317366; cv=none; b=Edsdbq+GSdivpGhsdI3R1DZEioUvsuZ7CW/0xffivxn8hd6Zbmn/JTd3VA8bqrwp1ulRNbCt1boGdhYcjOxJck9s5/GgIIfScnB7K+UlwyDyJLuAjVImY3yqjYHWFwY4JZhhp8c8VRPT26kEEwe7tQWFguKnW13dEpqVBG/dg1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742317366; c=relaxed/simple; bh=QzJgahSVlSnPEW0+dKHJjQ4euPpwRVaYcROk61G2c0s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FSH5ucDi/F0HoVnxN/7hD3XmjyhnnLDB61447mwdMEp5R01/jCZrV0q9F4I7GJ0Q0/r50QtzPyIpb+mVMHRv6PI5ZOJN21KBvobi33zBV30IN7K5YAO8iFief6tzcH8PGkyVK0KIyD+r5eIfXfK8TNNxXbQ1UpjbwA4vduVbKqY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 2C5481A25; Tue, 18 Mar 2025 10:02:49 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AC3E73F673; Tue, 18 Mar 2025 10:02:39 -0700 (PDT) From: Sudeep Holla Date: Tue, 18 Mar 2025 17:01:46 +0000 Subject: [PATCH v2 8/8] net: phy: fixed_phy: transition to the faux device interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-plat2faux_dev-v2-8-e6cc73f78478@arm.com> References: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> In-Reply-To: <20250318-plat2faux_dev-v2-0-e6cc73f78478@arm.com> To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman , Andrew Lunn , "David S. Miller" , netdev@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2802; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=QzJgahSVlSnPEW0+dKHJjQ4euPpwRVaYcROk61G2c0s=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn2acjJfK9XrY9C04/OxvAgk3YKFLyoo4IjykEo SaJHEUhG3mJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9mnIwAKCRAAQbq8MX7i mChxEACny/i1d7qnxSgF7wA3rTQEEdMhguxpuh/vKoSA4zQbcBvt/+CiNJsRrnPZNYhgEoHxCEe sYpu+xa6jPNXCoGJ5c1LLWicKXaYKW7DP/1/Y36woY8/ZbJk4v1kWprNZGf01LOO9Y4IDCk6Wjd zPh6gW4bGg687TVyc2NiR0OMgpSYu2z/Nj95LoYoC/AuwBoj2UUG8NVYXKprZ3SfiDxPudsLv5n zLvG9MTWQ/EmUsSoZr/2N6FSaZEouaLLXWGfm1kypYl/g0+usc8MDvKQZulQ2PeBc8TfvUR9Si2 A64A2z9s+z5uDKgFdVk7EhhmCHrjsKssBg62tIrxyPb9ypKBenQbKIqJevRz67Rmiwxd9X/hU9M F4omkoHo/Y/E5hV3mE2V6HcsdDMygqgg9NANiDn4K6OtOPgV/RYjQP2NvjHwYXNP4g/oKUrnlRt MSNKkWKyDm4vPmpQ5F9Xi7NLf3aIlG10oZGBH1zCBHKTtj+4HJiBdfxSb9UEUWPKR78tF0bhrDv 3IEqEuxpDuwcVSN57/q8wWMfYKunax/wQKIVwqXstHom8FiI3zoYxulSENx2EvNsbiG5OQy4NiS 5jve8hGCAhRebcC0w8EZY1PtssYBV2NMdCmdAEAdfjgNpc3/bsoL0HuBe2r0WL0tVQNxCQ0Nz1c 5Yxs4sHHoLaS8Uw== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The net fixed phy driver does not require the creation of a platform device. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate the device to utilize the faux bus, given that the platform device it previously created was not a real one anyway. This will get rid of the fake platform device. Cc: Andrew Lunn Cc: "David S. Miller" Cc: netdev@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/net/phy/fixed_phy.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c index aef739c20ac4d5a271465a677a85ef7c18cfce70..ee7831a9849b3728ca9c541da35= d17e089985da2 100644 --- a/drivers/net/phy/fixed_phy.c +++ b/drivers/net/phy/fixed_phy.c @@ -10,7 +10,7 @@ =20 #include #include -#include +#include #include #include #include @@ -40,7 +40,7 @@ struct fixed_phy { struct gpio_desc *link_gpiod; }; =20 -static struct platform_device *pdev; +static struct faux_device *fdev; static struct fixed_mdio_bus platform_fmb =3D { .phys =3D LIST_HEAD_INIT(platform_fmb.phys), }; @@ -337,9 +337,9 @@ static int __init fixed_mdio_bus_init(void) struct fixed_mdio_bus *fmb =3D &platform_fmb; int ret; =20 - pdev =3D platform_device_register_simple("Fixed MDIO bus", 0, NULL, 0); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); + fdev =3D faux_device_create("Fixed MDIO bus", NULL, NULL); + if (!fdev) + return -ENODEV; =20 fmb->mii_bus =3D mdiobus_alloc(); if (fmb->mii_bus =3D=3D NULL) { @@ -350,7 +350,7 @@ static int __init fixed_mdio_bus_init(void) snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "fixed-0"); fmb->mii_bus->name =3D "Fixed MDIO Bus"; fmb->mii_bus->priv =3D fmb; - fmb->mii_bus->parent =3D &pdev->dev; + fmb->mii_bus->parent =3D &fdev->dev; fmb->mii_bus->read =3D &fixed_mdio_read; fmb->mii_bus->write =3D &fixed_mdio_write; fmb->mii_bus->phy_mask =3D ~0; @@ -364,7 +364,7 @@ static int __init fixed_mdio_bus_init(void) err_mdiobus_alloc: mdiobus_free(fmb->mii_bus); err_mdiobus_reg: - platform_device_unregister(pdev); + faux_device_destroy(fdev); return ret; } module_init(fixed_mdio_bus_init); @@ -376,7 +376,7 @@ static void __exit fixed_mdio_bus_exit(void) =20 mdiobus_unregister(fmb->mii_bus); mdiobus_free(fmb->mii_bus); - platform_device_unregister(pdev); + faux_device_destroy(fdev); =20 list_for_each_entry_safe(fp, tmp, &fmb->phys, node) { list_del(&fp->node); --=20 2.34.1