* [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root()
[not found] <20230313182918.1312597-1-gregkh@linuxfoundation.org>
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
2023-03-13 18:43 ` Rafael J. Wysocki
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman, Len Brown, linux-acpi
Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
drivers/acpi/acpi_lpit.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
index 3843d2576d3f..73b5c4800150 100644
--- a/drivers/acpi/acpi_lpit.c
+++ b/drivers/acpi/acpi_lpit.c
@@ -98,6 +98,8 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
static void lpit_update_residency(struct lpit_residency_info *info,
struct acpi_lpit_native *lpit_native)
{
+ struct device *dev_root = bus_get_dev_root(&cpu_subsys);
+
info->frequency = lpit_native->counter_frequency ?
lpit_native->counter_frequency : tsc_khz * 1000;
if (!info->frequency)
@@ -111,15 +113,18 @@ static void lpit_update_residency(struct lpit_residency_info *info,
return;
/* Silently fail, if cpuidle attribute group is not present */
- sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
- &dev_attr_low_power_idle_system_residency_us.attr,
- "cpuidle");
+ if (dev_root)
+ sysfs_add_file_to_group(&dev_root->kobj,
+ &dev_attr_low_power_idle_system_residency_us.attr,
+ "cpuidle");
} else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
/* Silently fail, if cpuidle attribute group is not present */
- sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
- &dev_attr_low_power_idle_cpu_residency_us.attr,
- "cpuidle");
+ if (dev_root)
+ sysfs_add_file_to_group(&dev_root->kobj,
+ &dev_attr_low_power_idle_cpu_residency_us.attr,
+ "cpuidle");
}
+ put_device(dev_root);
}
static void lpit_process(u64 begin, u64 end)
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root()
2023-03-13 18:28 ` [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:43 ` Rafael J. Wysocki
2023-03-17 14:50 ` Greg Kroah-Hartman
2023-03-22 8:36 ` [PATCH v2 02/19] " Greg Kroah-Hartman
0 siblings, 2 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2023-03-13 18:43 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, rafael, Len Brown, linux-acpi
On Mon, Mar 13, 2023 at 7:29 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> Direct access to the struct bus_type dev_root pointer is going away soon
> so replace that with a call to bus_get_dev_root() instead, which is what
> it is there for.
>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> drivers/acpi/acpi_lpit.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> index 3843d2576d3f..73b5c4800150 100644
> --- a/drivers/acpi/acpi_lpit.c
> +++ b/drivers/acpi/acpi_lpit.c
> @@ -98,6 +98,8 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
> static void lpit_update_residency(struct lpit_residency_info *info,
> struct acpi_lpit_native *lpit_native)
> {
> + struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> +
This can return here right away if dev_root is NULL, because it will
not do anything useful in that case anyway.
> info->frequency = lpit_native->counter_frequency ?
> lpit_native->counter_frequency : tsc_khz * 1000;
> if (!info->frequency)
> @@ -111,15 +113,18 @@ static void lpit_update_residency(struct lpit_residency_info *info,
> return;
>
> /* Silently fail, if cpuidle attribute group is not present */
> - sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> - &dev_attr_low_power_idle_system_residency_us.attr,
> - "cpuidle");
> + if (dev_root)
> + sysfs_add_file_to_group(&dev_root->kobj,
> + &dev_attr_low_power_idle_system_residency_us.attr,
> + "cpuidle");
> } else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
> /* Silently fail, if cpuidle attribute group is not present */
> - sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> - &dev_attr_low_power_idle_cpu_residency_us.attr,
> - "cpuidle");
> + if (dev_root)
> + sysfs_add_file_to_group(&dev_root->kobj,
> + &dev_attr_low_power_idle_cpu_residency_us.attr,
> + "cpuidle");
> }
> + put_device(dev_root);
> }
>
> static void lpit_process(u64 begin, u64 end)
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root()
2023-03-13 18:43 ` Rafael J. Wysocki
@ 2023-03-17 14:50 ` Greg Kroah-Hartman
2023-03-22 8:36 ` [PATCH v2 02/19] " Greg Kroah-Hartman
1 sibling, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-17 14:50 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: linux-kernel, Len Brown, linux-acpi
On Mon, Mar 13, 2023 at 07:43:22PM +0100, Rafael J. Wysocki wrote:
> On Mon, Mar 13, 2023 at 7:29 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > Direct access to the struct bus_type dev_root pointer is going away soon
> > so replace that with a call to bus_get_dev_root() instead, which is what
> > it is there for.
> >
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Len Brown <lenb@kernel.org>
> > Cc: linux-acpi@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > Note, this is a patch that is a prepatory cleanup as part of a larger
> > series of patches that is working on resolving some old driver core
> > design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> > its own, but I'd prefer if I could take it through my driver-core tree
> > so that the driver core changes can be taken through there for 6.4-rc1.
> >
> > drivers/acpi/acpi_lpit.c | 17 +++++++++++------
> > 1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> > index 3843d2576d3f..73b5c4800150 100644
> > --- a/drivers/acpi/acpi_lpit.c
> > +++ b/drivers/acpi/acpi_lpit.c
> > @@ -98,6 +98,8 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
> > static void lpit_update_residency(struct lpit_residency_info *info,
> > struct acpi_lpit_native *lpit_native)
> > {
> > + struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> > +
>
> This can return here right away if dev_root is NULL, because it will
> not do anything useful in that case anyway.
Thanks for the review of these, I'll redo some of them and send out a
v2 of them next week.
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 02/19] ACPI: LPIT: move to use bus_get_dev_root()
2023-03-13 18:43 ` Rafael J. Wysocki
2023-03-17 14:50 ` Greg Kroah-Hartman
@ 2023-03-22 8:36 ` Greg Kroah-Hartman
2023-03-22 14:15 ` Rafael J. Wysocki
1 sibling, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-22 8:36 UTC (permalink / raw)
To: linux-kernel; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Len Brown, linux-acpi
Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v2: - change logic to test for dev_root at the beginning of the function
and error out then based on review comments from Rafael.
- fix error handling for ioremap() call to properly drop the
reference on dev_root if it failed.
drivers/acpi/acpi_lpit.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
index 3843d2576d3f..c5598b6d5db8 100644
--- a/drivers/acpi/acpi_lpit.c
+++ b/drivers/acpi/acpi_lpit.c
@@ -98,6 +98,12 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
static void lpit_update_residency(struct lpit_residency_info *info,
struct acpi_lpit_native *lpit_native)
{
+ struct device *dev_root = bus_get_dev_root(&cpu_subsys);
+
+ /* Silently fail, if cpuidle attribute group is not present */
+ if (!dev_root)
+ return;
+
info->frequency = lpit_native->counter_frequency ?
lpit_native->counter_frequency : tsc_khz * 1000;
if (!info->frequency)
@@ -108,18 +114,18 @@ static void lpit_update_residency(struct lpit_residency_info *info,
info->iomem_addr = ioremap(info->gaddr.address,
info->gaddr.bit_width / 8);
if (!info->iomem_addr)
- return;
+ goto exit;
- /* Silently fail, if cpuidle attribute group is not present */
- sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
+ sysfs_add_file_to_group(&dev_root->kobj,
&dev_attr_low_power_idle_system_residency_us.attr,
"cpuidle");
} else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
- /* Silently fail, if cpuidle attribute group is not present */
- sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
+ sysfs_add_file_to_group(&dev_root->kobj,
&dev_attr_low_power_idle_cpu_residency_us.attr,
"cpuidle");
}
+exit:
+ put_device(dev_root);
}
static void lpit_process(u64 begin, u64 end)
--
2.40.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 02/19] ACPI: LPIT: move to use bus_get_dev_root()
2023-03-22 8:36 ` [PATCH v2 02/19] " Greg Kroah-Hartman
@ 2023-03-22 14:15 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2023-03-22 14:15 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, Rafael J. Wysocki, Len Brown, linux-acpi
On Wed, Mar 22, 2023 at 9:36 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> Direct access to the struct bus_type dev_root pointer is going away soon
> so replace that with a call to bus_get_dev_root() instead, which is what
> it is there for.
>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> v2: - change logic to test for dev_root at the beginning of the function
> and error out then based on review comments from Rafael.
> - fix error handling for ioremap() call to properly drop the
> reference on dev_root if it failed.
>
> drivers/acpi/acpi_lpit.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> index 3843d2576d3f..c5598b6d5db8 100644
> --- a/drivers/acpi/acpi_lpit.c
> +++ b/drivers/acpi/acpi_lpit.c
> @@ -98,6 +98,12 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
> static void lpit_update_residency(struct lpit_residency_info *info,
> struct acpi_lpit_native *lpit_native)
> {
> + struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> +
> + /* Silently fail, if cpuidle attribute group is not present */
> + if (!dev_root)
> + return;
> +
> info->frequency = lpit_native->counter_frequency ?
> lpit_native->counter_frequency : tsc_khz * 1000;
> if (!info->frequency)
> @@ -108,18 +114,18 @@ static void lpit_update_residency(struct lpit_residency_info *info,
> info->iomem_addr = ioremap(info->gaddr.address,
> info->gaddr.bit_width / 8);
> if (!info->iomem_addr)
> - return;
> + goto exit;
>
> - /* Silently fail, if cpuidle attribute group is not present */
> - sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> + sysfs_add_file_to_group(&dev_root->kobj,
> &dev_attr_low_power_idle_system_residency_us.attr,
> "cpuidle");
> } else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
> - /* Silently fail, if cpuidle attribute group is not present */
> - sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> + sysfs_add_file_to_group(&dev_root->kobj,
> &dev_attr_low_power_idle_cpu_residency_us.attr,
> "cpuidle");
> }
> +exit:
> + put_device(dev_root);
> }
>
> static void lpit_process(u64 begin, u64 end)
> --
> 2.40.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-22 14:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20230313182918.1312597-1-gregkh@linuxfoundation.org>
2023-03-13 18:28 ` [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root() Greg Kroah-Hartman
2023-03-13 18:43 ` Rafael J. Wysocki
2023-03-17 14:50 ` Greg Kroah-Hartman
2023-03-22 8:36 ` [PATCH v2 02/19] " Greg Kroah-Hartman
2023-03-22 14:15 ` 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).