* [PATCH v1 0/4] ACPI: Add and use acpi_dev_get_pci_dev()
@ 2026-07-15 15:13 Rafael J. Wysocki
2026-07-15 15:15 ` [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev() Rafael J. Wysocki
` (3 more replies)
0 siblings, 4 replies; 15+ messages in thread
From: Rafael J. Wysocki @ 2026-07-15 15:13 UTC (permalink / raw)
To: Linux ACPI; +Cc: Linux PCI, LKML, Bjorn Helgaas, Andy Shevchenko, Hans de Goede
Hi All,
This series is based on the observation that the majority of acpi_get_pci_dev()
callers already know the ACPI device they want to look up the PCI device for
and so they don't need to look up the ACPI device. Accordingly, a function for
PCI device lookup based on an ACPI device is introduced and used.
The first patch is a simplification utilizing a mutex guard.
The second patch introduces acpi_dev_get_pci_dev() and redefines
acpi_get_pci_dev() as a static inline helper.
The third patch moves a device_put() call in the ACPI video bus driver to
a place after the device in question has been used.
The last patch updates the ACPI video bus driver, which is the heaviest user
of acpi_get_pci_dev(), to use acpi_dev_get_pci_dev() instead of it.
Thanks!
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev()
2026-07-15 15:13 [PATCH v1 0/4] ACPI: Add and use acpi_dev_get_pci_dev() Rafael J. Wysocki
@ 2026-07-15 15:15 ` Rafael J. Wysocki
2026-07-15 15:24 ` sashiko-bot
2026-07-15 15:52 ` Andy Shevchenko
2026-07-15 15:16 ` [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev() Rafael J. Wysocki
` (2 subsequent siblings)
3 siblings, 2 replies; 15+ messages in thread
From: Rafael J. Wysocki @ 2026-07-15 15:15 UTC (permalink / raw)
To: Linux ACPI; +Cc: Linux PCI, LKML, Bjorn Helgaas, Andy Shevchenko, Hans de Goede
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Use a mutex guard in acpi_get_pci_dev() for the physical_node_lock
locking and drop local variable pci_dev that becomes redundant after
that change.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/pci_root.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -307,24 +307,20 @@ struct pci_dev *acpi_get_pci_dev(acpi_ha
{
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
struct acpi_device_physical_node *pn;
- struct pci_dev *pci_dev = NULL;
if (!adev)
return NULL;
- mutex_lock(&adev->physical_node_lock);
+ guard(mutex)(&adev->physical_node_lock);
list_for_each_entry(pn, &adev->physical_node_list, node) {
if (dev_is_pci(pn->dev)) {
get_device(pn->dev);
- pci_dev = to_pci_dev(pn->dev);
- break;
+ return to_pci_dev(pn->dev);
}
}
- mutex_unlock(&adev->physical_node_lock);
-
- return pci_dev;
+ return NULL;
}
EXPORT_SYMBOL_GPL(acpi_get_pci_dev);
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev()
2026-07-15 15:13 [PATCH v1 0/4] ACPI: Add and use acpi_dev_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:15 ` [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev() Rafael J. Wysocki
@ 2026-07-15 15:16 ` Rafael J. Wysocki
2026-07-15 15:27 ` sashiko-bot
2026-07-15 15:56 ` Andy Shevchenko
2026-07-15 15:19 ` [PATCH v1 3/4] ACPI: video: Drop backlight parent device reference later Rafael J. Wysocki
2026-07-15 15:21 ` [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev() Rafael J. Wysocki
3 siblings, 2 replies; 15+ messages in thread
From: Rafael J. Wysocki @ 2026-07-15 15:16 UTC (permalink / raw)
To: Linux ACPI; +Cc: Linux PCI, LKML, Bjorn Helgaas, Andy Shevchenko, Hans de Goede
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Some acpi_get_pci_dev() callers already have a struct ACPI device for
which they want to get the struct pci_dev pointer of the associated
PCI device, so they don't need to look for one.
For this reason, add acpi_dev_get_pci_dev() that will get a PCI device
for a given ACPI one (if possible) and turn acpi_get_pci_dev() into
a static inline helper passing the acpi_fetch_acpi_dev() return value
directly to acpi_dev_get_pci_dev().
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/pci_root.c | 22 +++++++++++-----------
include/acpi/acpi_drivers.h | 9 +++++++--
2 files changed, 18 insertions(+), 13 deletions(-)
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -292,20 +292,20 @@ struct acpi_pci_root *acpi_pci_find_root
EXPORT_SYMBOL_GPL(acpi_pci_find_root);
/**
- * acpi_get_pci_dev - convert ACPI CA handle to struct pci_dev
- * @handle: the handle in question
+ * acpi_dev_get_pci_dev - Get a struct pci_dev for a given ACPI device
+ * @adev: Target ACPI device.
*
- * Given an ACPI CA handle, the desired PCI device is located in the
- * list of PCI devices.
+ * Get the first PCI device associated with @adev, if present, and bump up its
+ * reference counter.
*
- * If the device is found, its reference count is increased and this
- * function returns a pointer to its data structure. The caller must
- * decrement the reference count by calling pci_dev_put().
- * If no device is found, %NULL is returned.
+ * Callers are responsible for dropping the PCI device reference obtained by
+ * this function.
+ *
+ * Return: The struct pci_dev pointer of a reference-counted PCI device on
+ * success or NULL on failure.
*/
-struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
+struct pci_dev *acpi_dev_get_pci_dev(struct acpi_device *adev)
{
- struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
struct acpi_device_physical_node *pn;
if (!adev)
@@ -322,7 +322,7 @@ struct pci_dev *acpi_get_pci_dev(acpi_ha
return NULL;
}
-EXPORT_SYMBOL_GPL(acpi_get_pci_dev);
+EXPORT_SYMBOL_GPL(acpi_dev_get_pci_dev);
/**
* acpi_pci_osc_control_set - Request control of PCI root _OSC features.
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -59,14 +59,19 @@ int acpi_pci_link_free_irq(acpi_handle h
struct pci_bus;
#ifdef CONFIG_PCI
-struct pci_dev *acpi_get_pci_dev(acpi_handle);
+struct pci_dev *acpi_dev_get_pci_dev(struct acpi_device *adev);
#else
-static inline struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
+static inline struct pci_dev *acpi_dev_get_pci_dev(struct acpi_device *adev)
{
return NULL;
}
#endif
+static inline struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
+{
+ return acpi_dev_get_pci_dev(acpi_fetch_acpi_dev(handle));
+}
+
/* Arch-defined function to add a bus to the system */
struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root);
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v1 3/4] ACPI: video: Drop backlight parent device reference later
2026-07-15 15:13 [PATCH v1 0/4] ACPI: Add and use acpi_dev_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:15 ` [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:16 ` [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev() Rafael J. Wysocki
@ 2026-07-15 15:19 ` Rafael J. Wysocki
2026-07-15 15:29 ` sashiko-bot
2026-07-15 15:57 ` Andy Shevchenko
2026-07-15 15:21 ` [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev() Rafael J. Wysocki
3 siblings, 2 replies; 15+ messages in thread
From: Rafael J. Wysocki @ 2026-07-15 15:19 UTC (permalink / raw)
To: Linux ACPI; +Cc: Linux PCI, LKML, Bjorn Helgaas, Andy Shevchenko, Hans de Goede
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Update acpi_video_dev_register_backlight() to put the parent device after
registering the backlight class device under it instead of attempting to
register the backlight class device under a parent that (theoretically)
may be gone at that point.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_video.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1719,10 +1719,8 @@ static void acpi_video_dev_register_back
if (ACPI_SUCCESS(acpi_get_parent(device->dev->handle, &acpi_parent))) {
pdev = acpi_get_pci_dev(acpi_parent);
- if (pdev) {
+ if (pdev)
parent = &pdev->dev;
- pci_dev_put(pdev);
- }
}
memset(&props, 0, sizeof(struct backlight_properties));
@@ -1734,6 +1732,7 @@ static void acpi_video_dev_register_back
device,
&acpi_backlight_ops,
&props);
+ put_device(parent);
kfree(name);
if (IS_ERR(device->backlight)) {
device->backlight = NULL;
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev()
2026-07-15 15:13 [PATCH v1 0/4] ACPI: Add and use acpi_dev_get_pci_dev() Rafael J. Wysocki
` (2 preceding siblings ...)
2026-07-15 15:19 ` [PATCH v1 3/4] ACPI: video: Drop backlight parent device reference later Rafael J. Wysocki
@ 2026-07-15 15:21 ` Rafael J. Wysocki
2026-07-15 15:35 ` sashiko-bot
2026-07-15 15:59 ` Andy Shevchenko
3 siblings, 2 replies; 15+ messages in thread
From: Rafael J. Wysocki @ 2026-07-15 15:21 UTC (permalink / raw)
To: Linux ACPI; +Cc: Linux PCI, LKML, Bjorn Helgaas, Andy Shevchenko, Hans de Goede
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
In acpi_video_bus_check() and find_video(), simply replace
acpi_get_pci_dev() with acpi_dev_get_pci_dev() that can be used
in both places because the ACPI device needed to do the lookup is
available.
In acpi_video_dev_register_backlight(), instead of doing a parent ACPI
handle lookup based on the handle of an ACPI device that is already
available, pass that ACPI device to acpi_dev_parent() which is much
more straightforward and pass the return value of the latter directly
to acpi_dev_get_pci_dev() to get the PCI device associated with it.
That allows local variable acpi_parent to be eliminated.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_video.c | 11 ++++-------
drivers/acpi/video_detect.c | 2 +-
2 files changed, 5 insertions(+), 8 deletions(-)
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1048,7 +1048,7 @@ static int acpi_video_bus_check(struct a
if (!video)
return -EINVAL;
- dev = acpi_get_pci_dev(video->device->handle);
+ dev = acpi_dev_get_pci_dev(video->device);
if (!dev)
return -ENODEV;
pci_dev_put(dev);
@@ -1702,7 +1702,6 @@ static void acpi_video_dev_register_back
{
struct backlight_properties props;
struct pci_dev *pdev;
- acpi_handle acpi_parent;
struct device *parent = NULL;
int result;
static int count;
@@ -1717,11 +1716,9 @@ static void acpi_video_dev_register_back
return;
count++;
- if (ACPI_SUCCESS(acpi_get_parent(device->dev->handle, &acpi_parent))) {
- pdev = acpi_get_pci_dev(acpi_parent);
- if (pdev)
- parent = &pdev->dev;
- }
+ pdev = acpi_dev_get_pci_dev(acpi_dev_parent(device->dev));
+ if (pdev)
+ parent = &pdev->dev;
memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_FIRMWARE;
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -73,7 +73,7 @@ find_video(acpi_handle handle, u32 lvl,
};
if (acpi_dev && !acpi_match_device_ids(acpi_dev, video_ids)) {
- dev = acpi_get_pci_dev(handle);
+ dev = acpi_dev_get_pci_dev(acpi_dev);
if (!dev)
return AE_OK;
pci_dev_put(dev);
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev()
2026-07-15 15:15 ` [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev() Rafael J. Wysocki
@ 2026-07-15 15:24 ` sashiko-bot
2026-07-15 15:52 ` Andy Shevchenko
1 sibling, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-07-15 15:24 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: linux-pci
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> Use a mutex guard in acpi_get_pci_dev() for the physical_node_lock
> locking and drop local variable pci_dev that becomes redundant after
> that change.
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/5115219.31r3eYUQgx@rafael.j.wysocki?part=1
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev()
2026-07-15 15:16 ` [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev() Rafael J. Wysocki
@ 2026-07-15 15:27 ` sashiko-bot
2026-07-15 15:56 ` Andy Shevchenko
1 sibling, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-07-15 15:27 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: linux-pci
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> Some acpi_get_pci_dev() callers already have a struct ACPI device for
> which they want to get the struct pci_dev pointer of the associated
> PCI device, so they don't need to look for one.
>
> For this reason, add acpi_dev_get_pci_dev() that will get a PCI device
> for a given ACPI one (if possible) and turn acpi_get_pci_dev() into
> a static inline helper passing the acpi_fetch_acpi_dev() return value
> directly to acpi_dev_get_pci_dev().
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/5115219.31r3eYUQgx@rafael.j.wysocki?part=2
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 3/4] ACPI: video: Drop backlight parent device reference later
2026-07-15 15:19 ` [PATCH v1 3/4] ACPI: video: Drop backlight parent device reference later Rafael J. Wysocki
@ 2026-07-15 15:29 ` sashiko-bot
2026-07-15 15:57 ` Andy Shevchenko
1 sibling, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-07-15 15:29 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: linux-pci
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> Update acpi_video_dev_register_backlight() to put the parent device after
> registering the backlight class device under it instead of attempting to
> register the backlight class device under a parent that (theoretically)
> may be gone at that point.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/5115219.31r3eYUQgx@rafael.j.wysocki?part=3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev()
2026-07-15 15:21 ` [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev() Rafael J. Wysocki
@ 2026-07-15 15:35 ` sashiko-bot
2026-07-15 15:59 ` Andy Shevchenko
1 sibling, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-07-15 15:35 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: linux-pci
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> In acpi_video_bus_check() and find_video(), simply replace
> acpi_get_pci_dev() with acpi_dev_get_pci_dev() that can be used
> in both places because the ACPI device needed to do the lookup is
> available.
>
> In acpi_video_dev_register_backlight(), instead of doing a parent ACPI
> handle lookup based on the handle of an ACPI device that is already
> available, pass that ACPI device to acpi_dev_parent() which is much
> more straightforward and pass the return value of the latter directly
> to acpi_dev_get_pci_dev() to get the PCI device associated with it.
> That allows local variable acpi_parent to be eliminated.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/5115219.31r3eYUQgx@rafael.j.wysocki?part=4
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev()
2026-07-15 15:15 ` [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:24 ` sashiko-bot
@ 2026-07-15 15:52 ` Andy Shevchenko
1 sibling, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2026-07-15 15:52 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, Linux PCI, LKML, Bjorn Helgaas, Hans de Goede
On Wed, Jul 15, 2026 at 05:15:02PM +0200, Rafael J. Wysocki wrote:
> Use a mutex guard in acpi_get_pci_dev() for the physical_node_lock
> locking and drop local variable pci_dev that becomes redundant after
> that change.
>
> No intentional functional impact.
...
> - mutex_lock(&adev->physical_node_lock);
> + guard(mutex)(&adev->physical_node_lock);
This needs a cleanup.h to be included (yes, I see the current inclusion block
and it's a mess :-( ).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev()
2026-07-15 15:16 ` [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:27 ` sashiko-bot
@ 2026-07-15 15:56 ` Andy Shevchenko
2026-07-15 16:33 ` Rafael J. Wysocki (Intel)
1 sibling, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2026-07-15 15:56 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, Linux PCI, LKML, Bjorn Helgaas, Hans de Goede
On Wed, Jul 15, 2026 at 05:16:19PM +0200, Rafael J. Wysocki wrote:
> Some acpi_get_pci_dev() callers already have a struct ACPI device for
> which they want to get the struct pci_dev pointer of the associated
> PCI device, so they don't need to look for one.
>
> For this reason, add acpi_dev_get_pci_dev() that will get a PCI device
> for a given ACPI one (if possible) and turn acpi_get_pci_dev() into
> a static inline helper passing the acpi_fetch_acpi_dev() return value
> directly to acpi_dev_get_pci_dev().
...
> /**
> - * acpi_get_pci_dev - convert ACPI CA handle to struct pci_dev
> - * @handle: the handle in question
> + * acpi_dev_get_pci_dev - Get a struct pci_dev for a given ACPI device
> + * @adev: Target ACPI device.
> *
> - * Given an ACPI CA handle, the desired PCI device is located in the
> - * list of PCI devices.
> + * Get the first PCI device associated with @adev, if present, and bump up its
What is the meaning of the "first PCI device" in terms of ACPI specification (and
implementation in the Linux kernel)? I think it's impossible case to have more
than one object to be a companion to a PCI device. Am I wrong?
> + * reference counter.
> *
> - * If the device is found, its reference count is increased and this
> - * function returns a pointer to its data structure. The caller must
> - * decrement the reference count by calling pci_dev_put().
> - * If no device is found, %NULL is returned.
> + * Callers are responsible for dropping the PCI device reference obtained by
> + * this function.
> + *
> + * Return: The struct pci_dev pointer of a reference-counted PCI device on
> + * success or NULL on failure.
> */
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 3/4] ACPI: video: Drop backlight parent device reference later
2026-07-15 15:19 ` [PATCH v1 3/4] ACPI: video: Drop backlight parent device reference later Rafael J. Wysocki
2026-07-15 15:29 ` sashiko-bot
@ 2026-07-15 15:57 ` Andy Shevchenko
1 sibling, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2026-07-15 15:57 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, Linux PCI, LKML, Bjorn Helgaas, Hans de Goede
On Wed, Jul 15, 2026 at 05:19:08PM +0200, Rafael J. Wysocki wrote:
> Update acpi_video_dev_register_backlight() to put the parent device after
> registering the backlight class device under it instead of attempting to
> register the backlight class device under a parent that (theoretically)
> may be gone at that point.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev()
2026-07-15 15:21 ` [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:35 ` sashiko-bot
@ 2026-07-15 15:59 ` Andy Shevchenko
2026-07-15 16:34 ` Rafael J. Wysocki (Intel)
1 sibling, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2026-07-15 15:59 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, Linux PCI, LKML, Bjorn Helgaas, Hans de Goede
On Wed, Jul 15, 2026 at 05:21:23PM +0200, Rafael J. Wysocki wrote:
> In acpi_video_bus_check() and find_video(), simply replace
> acpi_get_pci_dev() with acpi_dev_get_pci_dev() that can be used
> in both places because the ACPI device needed to do the lookup is
> available.
>
> In acpi_video_dev_register_backlight(), instead of doing a parent ACPI
> handle lookup based on the handle of an ACPI device that is already
> available, pass that ACPI device to acpi_dev_parent() which is much
> more straightforward and pass the return value of the latter directly
> to acpi_dev_get_pci_dev() to get the PCI device associated with it.
> That allows local variable acpi_parent to be eliminated.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
...
> +++ b/drivers/acpi/video_detect.c
> if (acpi_dev && !acpi_match_device_ids(acpi_dev, video_ids)) {
> - dev = acpi_get_pci_dev(handle);
> + dev = acpi_dev_get_pci_dev(acpi_dev);
This likely needs to be rebased on top of the series I sent?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev()
2026-07-15 15:56 ` Andy Shevchenko
@ 2026-07-15 16:33 ` Rafael J. Wysocki (Intel)
0 siblings, 0 replies; 15+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-07-15 16:33 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rafael J. Wysocki, Linux ACPI, Linux PCI, LKML, Bjorn Helgaas,
Hans de Goede
On Wed, Jul 15, 2026 at 5:56 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Jul 15, 2026 at 05:16:19PM +0200, Rafael J. Wysocki wrote:
>
> > Some acpi_get_pci_dev() callers already have a struct ACPI device for
> > which they want to get the struct pci_dev pointer of the associated
> > PCI device, so they don't need to look for one.
> >
> > For this reason, add acpi_dev_get_pci_dev() that will get a PCI device
> > for a given ACPI one (if possible) and turn acpi_get_pci_dev() into
> > a static inline helper passing the acpi_fetch_acpi_dev() return value
> > directly to acpi_dev_get_pci_dev().
>
> ...
>
> > /**
> > - * acpi_get_pci_dev - convert ACPI CA handle to struct pci_dev
> > - * @handle: the handle in question
> > + * acpi_dev_get_pci_dev - Get a struct pci_dev for a given ACPI device
> > + * @adev: Target ACPI device.
> > *
> > - * Given an ACPI CA handle, the desired PCI device is located in the
> > - * list of PCI devices.
> > + * Get the first PCI device associated with @adev, if present, and bump up its
>
> What is the meaning of the "first PCI device" in terms of ACPI specification (and
> implementation in the Linux kernel)? I think it's impossible case to have more
> than one object to be a companion to a PCI device. Am I wrong?
The ACPI specification is kind of agnostic to that.
In the kernel, there can be multiple physical devices associated with
one ACPI device object, but I agree that every PCI device has at most
one ACPI companion.
I'll drop the word "first" from this comment.
> > + * reference counter.
> > *
> > - * If the device is found, its reference count is increased and this
> > - * function returns a pointer to its data structure. The caller must
> > - * decrement the reference count by calling pci_dev_put().
> > - * If no device is found, %NULL is returned.
> > + * Callers are responsible for dropping the PCI device reference obtained by
> > + * this function.
> > + *
> > + * Return: The struct pci_dev pointer of a reference-counted PCI device on
> > + * success or NULL on failure.
> > */
>
> --
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev()
2026-07-15 15:59 ` Andy Shevchenko
@ 2026-07-15 16:34 ` Rafael J. Wysocki (Intel)
0 siblings, 0 replies; 15+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-07-15 16:34 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rafael J. Wysocki, Linux ACPI, Linux PCI, LKML, Bjorn Helgaas,
Hans de Goede
On Wed, Jul 15, 2026 at 5:59 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Jul 15, 2026 at 05:21:23PM +0200, Rafael J. Wysocki wrote:
>
> > In acpi_video_bus_check() and find_video(), simply replace
> > acpi_get_pci_dev() with acpi_dev_get_pci_dev() that can be used
> > in both places because the ACPI device needed to do the lookup is
> > available.
> >
> > In acpi_video_dev_register_backlight(), instead of doing a parent ACPI
> > handle lookup based on the handle of an ACPI device that is already
> > available, pass that ACPI device to acpi_dev_parent() which is much
> > more straightforward and pass the return value of the latter directly
> > to acpi_dev_get_pci_dev() to get the PCI device associated with it.
> > That allows local variable acpi_parent to be eliminated.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks!
> ...
>
> > +++ b/drivers/acpi/video_detect.c
>
> > if (acpi_dev && !acpi_match_device_ids(acpi_dev, video_ids)) {
> > - dev = acpi_get_pci_dev(handle);
> > + dev = acpi_dev_get_pci_dev(acpi_dev);
>
> This likely needs to be rebased on top of the series I sent?
Probably.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-07-15 16:34 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15 15:13 [PATCH v1 0/4] ACPI: Add and use acpi_dev_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:15 ` [PATCH v1 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:24 ` sashiko-bot
2026-07-15 15:52 ` Andy Shevchenko
2026-07-15 15:16 ` [PATCH v1 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:27 ` sashiko-bot
2026-07-15 15:56 ` Andy Shevchenko
2026-07-15 16:33 ` Rafael J. Wysocki (Intel)
2026-07-15 15:19 ` [PATCH v1 3/4] ACPI: video: Drop backlight parent device reference later Rafael J. Wysocki
2026-07-15 15:29 ` sashiko-bot
2026-07-15 15:57 ` Andy Shevchenko
2026-07-15 15:21 ` [PATCH v1 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev() Rafael J. Wysocki
2026-07-15 15:35 ` sashiko-bot
2026-07-15 15:59 ` Andy Shevchenko
2026-07-15 16:34 ` Rafael J. Wysocki (Intel)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.