Skip to contentSkip to conversation

ACPI: video: Don't allow MFD devices to probe

PATCH In review Mario Limonciello (AMD) 3 participants 8 messages Mar 6 – Mar 9 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: video: Don't allow MFD devices to probe

After ACPI video was converted into a platform device in commit 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one") other devices that are MFD children of LNXVIDEO are being probed. This isn't intended.

During probe detect MFD cells and reject them.

Fixes 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one")
---
 drivers/acpi/acpi_video.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/acpi/acpi_video.c +4 -0
index 3fa28f1abca38..2cb526775ac47 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/mfd/core.h>
 #include <linux/mutex.h>
 #include <linux/input.h>
 #include <linux/backlight.h>
@@ -1988,6 +1989,9 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
 	int error;
 	acpi_status status;
 
+	if (mfd_get_cell(pdev))
+		return -ENODEV;
+
 	status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
 				acpi_dev_parent(device)->handle, 1,
 				acpi_video_bus_match, NULL,
Signature · 1 line
2.43.0
Tested-by Pratap Nirujogi on v1 1/1
#1 lore raw

This patch resolves the regression issue observed with AMD ISP device in kernel version 7.0-rc2.

Thanks,
Pratap

Quoted 43 lines · Mario Limonciello (AMD)

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

After ACPI video was converted into a platform device in commit 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one") other devices that are MFD children of LNXVIDEO are being probed. This isn't intended.

During probe detect MFD cells and reject them.

Fixes 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one")
---
  drivers/acpi/acpi_video.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/acpi/acpi_video.c +4 -1
index 3fa28f1abca38..2cb526775ac47 100644
@@ -14,6 +14,7 @@
  #include <linux/init.h>
  #include <linux/types.h>
  #include <linux/list.h>
+#include <linux/mfd/core.h>
  #include <linux/mutex.h>
  #include <linux/input.h>
  #include <linux/backlight.h>
@@ -1988,6 +1989,9 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
         int error;
         acpi_status status;
 
+       if (mfd_get_cell(pdev))
+               return -ENODEV;
+
         status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
                                 acpi_dev_parent(device)->handle, 1,
                                 acpi_video_bus_match, NULL,
--

2.43.0

#2 lore raw
In reply to Mario Limonciello (AMD)
Quoted 11 lines · Mario Limonciello (AMD)

After ACPI video was converted into a platform device in commit 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one") other devices that are MFD children of LNXVIDEO are being probed. This isn't intended.

During probe detect MFD cells and reject them.

Fixes 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one")

The link is broken, so I can't see what is really happening, but my guess is that MFD devices are created under the video bus device and they get the same device ID (confusingly enough).

Quoted 18 lines
---
 drivers/acpi/acpi_video.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/acpi/acpi_video.c +1 -0
index 3fa28f1abca38..2cb526775ac47 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/mfd/core.h>
 #include <linux/mutex.h>
 #include <linux/input.h>
 #include <linux/backlight.h>

drivers/acpi/acpi_video.c static int acpi_video_bus_probe(struct platform_device *pdev) · line 1993

Quoted 5 lines
drivers/acpi/acpi_video.c +2 -0
@@ -1988,6 +1989,9 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
        int error;
        acpi_status status;
 
+       if (mfd_get_cell(pdev))
+               return -ENODEV;

If the above is the case, I'd prefer this check

        if (!device->pnp.type.backlight)

which should also work, but is more general.

Quoted 5 lines
drivers/acpi/acpi_video.c +1 -1
+
        status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
                                acpi_dev_parent(device)->handle, 1,
                                acpi_video_bus_match, NULL,
--
#3 lore raw
Quoted 40 lines · Rafael J. Wysocki
Quoted 11 lines · Mario Limonciello (AMD)

After ACPI video was converted into a platform device in commit 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one") other devices that are MFD children of LNXVIDEO are being probed. This isn't intended.

During probe detect MFD cells and reject them.

Fixes 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one")

The link is broken, so I can't see what is really happening, but my guess is that MFD devices are created under the video bus device and they get the same device ID (confusingly enough).

Quoted 21 lines
---
 drivers/acpi/acpi_video.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/acpi/acpi_video.c +1 -0
index 3fa28f1abca38..2cb526775ac47 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/mfd/core.h>
 #include <linux/mutex.h>
 #include <linux/input.h>
 #include <linux/backlight.h>
@@ -1988,6 +1989,9 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
        int error;
        acpi_status status;
 
Quoted 8 lines

drivers/acpi/acpi_video.c static int acpi_video_bus_probe(struct platform_device *pdev) · line 1993

Quoted 2 lines
drivers/acpi/acpi_video.c +2 -0
+       if (mfd_get_cell(pdev))
+               return -ENODEV;

If the above is the case, I'd prefer this check

        if (!device->pnp.type.backlight)

which should also work, but is more general.

Well, this will not work if the ACPI companion is shared between multiple devices.

However, adding an MFD check here is a "works for me" change rather.

I think what needs to be done is to extend the duplication check (see my patch from yesterday at
https://lore.kernel.org/linux-acpi/[email protected]/)
to detect the cases when another platform device (not necessarily a child of the same parent) sharing the same ACPI companion is probed.

Quoted 5 lines
Quoted 5 lines
drivers/acpi/acpi_video.c +1 -1
+
        status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
                                acpi_dev_parent(device)->handle, 1,
                                acpi_video_bus_match, NULL,
--
#4 lore raw
Quoted 53 lines · CET Rafael J. Wysocki
Quoted 40 lines · Rafael J. Wysocki
Quoted 11 lines · Mario Limonciello (AMD)

After ACPI video was converted into a platform device in commit 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one") other devices that are MFD children of LNXVIDEO are being probed. This isn't intended.

During probe detect MFD cells and reject them.

Fixes 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one")

The link is broken, so I can't see what is really happening, but my guess is that MFD devices are created under the video bus device and they get the same device ID (confusingly enough).

Quoted 21 lines
---
 drivers/acpi/acpi_video.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/acpi/acpi_video.c +1 -0
index 3fa28f1abca38..2cb526775ac47 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/mfd/core.h>
 #include <linux/mutex.h>
 #include <linux/input.h>
 #include <linux/backlight.h>
@@ -1988,6 +1989,9 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
        int error;
        acpi_status status;
 
Quoted 8 lines

drivers/acpi/acpi_video.c static int acpi_video_bus_probe(struct platform_device *pdev) · line 1993

Quoted 2 lines
drivers/acpi/acpi_video.c +2 -0
+       if (mfd_get_cell(pdev))
+               return -ENODEV;

If the above is the case, I'd prefer this check

        if (!device->pnp.type.backlight)

which should also work, but is more general.

Well, this will not work if the ACPI companion is shared between multiple devices.

Quoted 7 lines

However, adding an MFD check here is a "works for me" change rather.

I think what needs to be done is to extend the duplication check (see my patch from yesterday at
https://lore.kernel.org/linux-acpi/[email protected]/)
to detect the cases when another platform device (not necessarily a child of the same parent) sharing the same ACPI companion is probed.

So, Pratap, can you please test the appended patch (untested so far)?

---
 drivers/acpi/acpi_video.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/acpi/acpi_video.c +22 -0
@@ -1978,16 +1978,38 @@ static int acpi_video_bus_put_devices(st
 	return 0;
 }
 
+static bool acpi_video_bus_bound(struct acpi_device *adev)
+{
+	struct acpi_video_bus *video;
+
+	guard(mutex)(&video_list_lock);
+
+	list_for_each_entry(video, &video_bus_head, entry) {
+		if (video->device == adev)
+			return true;
+	}
+
+	return false;
+}
+
 static int instance;
 
 static int acpi_video_bus_probe(struct platform_device *pdev)
 {
 	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+	static DEFINE_MUTEX(probe_lock);
 	struct acpi_video_bus *video;
 	bool auto_detect;
 	int error;
 	acpi_status status;
 
+	/* Probe one video bus device at a time in case there are duplicates. */
+	guard(mutex)(&probe_lock);
+
+	/* Bind only one platform device for the given ACPI companion. */
+	if (acpi_video_bus_bound(device))
+		return -EALREADY;
+
 	status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
 				acpi_dev_parent(device)->handle, 1,
 				acpi_video_bus_match, NULL,
#6 lore raw
In reply to Rafael J. Wysocki
Quoted 12 lines · Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki
Quoted 8 lines · Mario Limonciello (AMD)

After ACPI video was converted into a platform device in commit 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one") other devices that are MFD children of LNXVIDEO are being probed. This isn't intended.

During probe detect MFD cells and reject them.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Fixes 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one")

The link is broken, so I can't see what is really happening, but my guess is that MFD devices are created under the video bus device and they get the same device ID (confusingly enough).

Hmm, I just double checked the link and it worked for me.

But you are on the To: list of that thread also.

Quoted 34 lines
Quoted 22 lines
Quoted 22 lines
---
  drivers/acpi/acpi_video.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/acpi/acpi_video.c +1 -0
index 3fa28f1abca38..2cb526775ac47 100644
@@ -14,6 +14,7 @@
  #include <linux/init.h>
  #include <linux/types.h>
  #include <linux/list.h>
+#include <linux/mfd/core.h>
  #include <linux/mutex.h>
  #include <linux/input.h>
  #include <linux/backlight.h>
@@ -1988,6 +1989,9 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
         int error;
         acpi_status status;
 
Quoted 8 lines

drivers/acpi/acpi_video.c static int acpi_video_bus_probe(struct platform_device *pdev) · line 1993

Quoted 2 lines
drivers/acpi/acpi_video.c +2 -0
+       if (mfd_get_cell(pdev))
+               return -ENODEV;

If the above is the case, I'd prefer this check

         if (!device->pnp.type.backlight)

which should also work, but is more general.

Well, this will not work if the ACPI companion is shared between multiple devices.

Quoted 8 lines

However, adding an MFD check here is a "works for me" change rather.

I think what needs to be done is to extend the duplication check (see my patch from yesterday at
https://lore.kernel.org/linux-acpi/[email protected]/)
to detect the cases when another platform device (not necessarily a child of the same parent) sharing the same ACPI companion is probed.

Generally makes sense to me. But in this particular case it shouldn't be a FW_BUG.

Do you want to roll this in your series? Or would you prefer one of us to send a follow up patch?

#7 lore raw
Quoted 20 lines · Mario Limonciello
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Rafael J. Wysocki
Quoted 11 lines · Mario Limonciello (AMD)

After ACPI video was converted into a platform device in commit 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one") other devices that are MFD children of LNXVIDEO are being probed. This isn't intended.

During probe detect MFD cells and reject them.

Fixes 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one")
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

The link is broken, so I can't see what is really happening, but my guess is that MFD devices are created under the video bus device and they get the same device ID (confusingly enough).

Hmm, I just double checked the link and it worked for me.

It works now for me too. I'm not sure what happened the first time.

Quoted 1 line

But you are on the To: list of that thread also.

Yup, I've found it.

Quoted 43 lines
Quoted 34 lines
Quoted 22 lines
Quoted 22 lines
---
  drivers/acpi/acpi_video.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/acpi/acpi_video.c +1 -0
index 3fa28f1abca38..2cb526775ac47 100644
@@ -14,6 +14,7 @@
  #include <linux/init.h>
  #include <linux/types.h>
  #include <linux/list.h>
+#include <linux/mfd/core.h>
  #include <linux/mutex.h>
  #include <linux/input.h>
  #include <linux/backlight.h>
@@ -1988,6 +1989,9 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
         int error;
         acpi_status status;
 
Quoted 8 lines

drivers/acpi/acpi_video.c static int acpi_video_bus_probe(struct platform_device *pdev) · line 1993

Quoted 2 lines
drivers/acpi/acpi_video.c +2 -0
+       if (mfd_get_cell(pdev))
+               return -ENODEV;

If the above is the case, I'd prefer this check

         if (!device->pnp.type.backlight)

which should also work, but is more general.

Well, this will not work if the ACPI companion is shared between multiple devices.

Quoted 8 lines

However, adding an MFD check here is a "works for me" change rather.

I think what needs to be done is to extend the duplication check (see my patch from yesterday at
https://lore.kernel.org/linux-acpi/[email protected]/)
to detect the cases when another platform device (not necessarily a child of the same parent) sharing the same ACPI companion is probed.

Quoted 5 lines

Generally makes sense to me. But in this particular case it shouldn't be a FW_BUG.

Do you want to roll this in your series? Or would you prefer one of us to send a follow up patch?

I've sent one already, our replies passed each other:

https://lore.kernel.org/linux-acpi/[email protected]/

#5 lore raw
In reply to Rafael J. Wysocki
Quoted 59 lines · Rafael J. Wysocki

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 55 lines · CET Rafael J. Wysocki
Quoted 40 lines · Rafael J. Wysocki
Quoted 11 lines · Mario Limonciello (AMD)

After ACPI video was converted into a platform device in commit 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one") other devices that are MFD children of LNXVIDEO are being probed. This isn't intended.

During probe detect MFD cells and reject them.

Fixes 02c057ddefef5 ("ACPI: video: Convert the driver to a platform one")

The link is broken, so I can't see what is really happening, but my guess is that MFD devices are created under the video bus device and they get the same device ID (confusingly enough).

Quoted 21 lines
---
  drivers/acpi/acpi_video.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/acpi/acpi_video.c +1 -0
index 3fa28f1abca38..2cb526775ac47 100644
@@ -14,6 +14,7 @@
  #include <linux/init.h>
  #include <linux/types.h>
  #include <linux/list.h>
+#include <linux/mfd/core.h>
  #include <linux/mutex.h>
  #include <linux/input.h>
  #include <linux/backlight.h>
@@ -1988,6 +1989,9 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
         int error;
         acpi_status status;
 
Quoted 8 lines

drivers/acpi/acpi_video.c static int acpi_video_bus_probe(struct platform_device *pdev) · line 1993

Quoted 2 lines
drivers/acpi/acpi_video.c +2 -0
+       if (mfd_get_cell(pdev))
+               return -ENODEV;

If the above is the case, I'd prefer this check

         if (!device->pnp.type.backlight)

which should also work, but is more general.

Well, this will not work if the ACPI companion is shared between multiple devices.

However, adding an MFD check here is a "works for me" change rather.

My apologies for not being clear about what works on my end. When I said it works, I meant that the MFD check had fixed the noisy error messages below. However, this does not resolve the automatic probe issue of AMD ISP device.

[    5.337676] acpi device:14: Error installing notify handler
[    5.337682] acpi device:15: Error installing notify handler
[    5.337684] acpi device:16: Error installing notify handler
Quoted 8 lines
Quoted 5 lines

I think what needs to be done is to extend the duplication check (see my patch from yesterday at
https://lore.kernel.org/linux-acpi/[email protected]/)
to detect the cases when another platform device (not necessarily a child of the same parent) sharing the same ACPI companion is probed.

So, Pratap, can you please test the appended patch (untested so far)?

I verified the appended patch and the results are same as the MFD check suggested by Mario. Automatic modprobe of AMD ISP device issue is still observed.

Based on my debugging so far, I can confirm both automatic AMD ISP device probe and camera works only when the MFD child devices do not inherit the parent device ACPI companion. I shall run a git bisect to identify the specific commit that is causing this issue in 7.0.

Quoted 49 lines
---
  drivers/acpi/acpi_video.c |   22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)
drivers/acpi/acpi_video.c +22 -0
@@ -1978,16 +1978,38 @@ static int acpi_video_bus_put_devices(st
         return 0;
  }
 
+static bool acpi_video_bus_bound(struct acpi_device *adev)
+{
+       struct acpi_video_bus *video;
+
+       guard(mutex)(&video_list_lock);
+
+       list_for_each_entry(video, &video_bus_head, entry) {
+               if (video->device == adev)
+                       return true;
+       }
+
+       return false;
+}
+
  static int instance;
 
  static int acpi_video_bus_probe(struct platform_device *pdev)
  {
         struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+       static DEFINE_MUTEX(probe_lock);
         struct acpi_video_bus *video;
         bool auto_detect;
         int error;
         acpi_status status;
 
+       /* Probe one video bus device at a time in case there are duplicates. */
+       guard(mutex)(&probe_lock);
+
+       /* Bind only one platform device for the given ACPI companion. */
+       if (acpi_video_bus_bound(device))
+               return -EALREADY;
+
         status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
                                 acpi_dev_parent(device)->handle, 1,
                                 acpi_video_bus_match, NULL,