LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 10/20] net: bcmgenet: use platform_device_set_of_node()
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski
In-Reply-To: <20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com>

Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/net/ethernet/broadcom/genet/bcmmii.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index a4e0d5a682687533a1b034ccf56cdb363d6b7786..0f0dbabfaabbce3469de79af91d7731b8476709f 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -490,8 +490,9 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv)
 	/* Retain this platform_device pointer for later cleanup */
 	priv->mii_pdev = ppdev;
 	ppdev->dev.parent = &pdev->dev;
+
 	if (dn)
-		ppdev->dev.of_node = bcmgenet_mii_of_find_mdio(priv);
+		platform_device_set_of_node(ppdev, bcmgenet_mii_of_find_mdio(priv));
 	else
 		ppd.phy_mask = ~0;
 

-- 
2.47.3



^ permalink raw reply related

* [PATCH v3 08/20] i2c: pxa-pci: use platform_device_set_of_node()
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski, Wolfram Sang
In-Reply-To: <20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com>

Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.

Acked-by: Andi Shyti <andi.shyti@kernel.org>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> # for I2C
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/i2c/busses/i2c-pxa-pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c
index dbd542300f80043c6bc65a69fa27ca7b3d5fe787..92a0647f08c69f841ca99caca757c1728b3f6fce 100644
--- a/drivers/i2c/busses/i2c-pxa-pci.c
+++ b/drivers/i2c/busses/i2c-pxa-pci.c
@@ -76,7 +76,8 @@ static struct platform_device *add_i2c_device(struct pci_dev *dev, int bar)
 		goto out;
 	}
 	pdev->dev.parent = &dev->dev;
-	pdev->dev.of_node = child;
+
+	platform_device_set_of_node(pdev, child);
 
 	ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
 	if (ret)

-- 
2.47.3



^ permalink raw reply related

* [PATCH v3 07/20] powerpc/powermac: use platform_device_set_of_node()
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski
In-Reply-To: <20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com>

Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 arch/powerpc/platforms/powermac/low_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index 973f58771d9636605ed5d3e91b45008543b584d3..a175a32a222bab4cc7400f6ab6071f5630db2cb8 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -1471,7 +1471,7 @@ static int __init pmac_i2c_create_platform_devices(void)
 		if (bus->platform_dev == NULL)
 			return -ENOMEM;
 		bus->platform_dev->dev.platform_data = bus;
-		bus->platform_dev->dev.of_node = of_node_get(bus->busnode);
+		platform_device_set_of_node(bus->platform_dev, bus->busnode);
 		platform_device_add(bus->platform_dev);
 	}
 

-- 
2.47.3



^ permalink raw reply related

* [PATCH v3 06/20] of: platform: use platform_device_set_of_node()
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski
In-Reply-To: <20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com>

Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.

Acked-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/of/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 53bca8c6f7810ce2235b4d084a361626b1d2da33..8b1e7640778253492c080085b4015e1423389d83 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -126,7 +126,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 	}
 
 	/* setup generic device info */
-	device_set_node(&dev->dev, of_fwnode_handle(of_node_get(np)));
+	platform_device_set_of_node(dev, np);
 	dev->dev.parent = parent ? : &platform_bus;
 
 	if (bus_id)

-- 
2.47.3



^ permalink raw reply related

* [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc()
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski, Manuel Ebner
In-Reply-To: <20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com>

Users of platform_device_alloc() + platform_device_add() must not modify
certain fields of the dynamically created platform device object. Update
the kernel doc to say which fields are affected and which functions to
use.

Suggested-by: Manuel Ebner <manuelebner@mailbox.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/platform.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f24a5f406746b53ca9eaab9472f6dd1345e04ad6..9357942d0c79b032645035879b2bed3d53305b9f 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -619,6 +619,13 @@ static void platform_device_release_full(struct device *dev)
  *
  * Create a platform device object which can have other objects attached
  * to it, and which will have attached objects freed when it is released.
+ *
+ * The following fields of the dynamically allocated platform device must not
+ * be modified manually: resource, num_resources, dev.platform_data,
+ * dev.of_node and dev.fwnode. Users wishing to do the split platform device
+ * registration with platform_device_alloc() + platform_device_add() are
+ * required to use dedicated helpers for adding resources, platform data or
+ * assigning firmware nodes.
  */
 struct platform_device *platform_device_alloc(const char *name, int id)
 {

-- 
2.47.3



^ permalink raw reply related

* [PATCH v3 04/20] driver core: platform: provide platform_device_set_of_node_from_dev()
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski
In-Reply-To: <20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com>

Provide a platform-specific variant of device_set_of_node_from_dev(). In
addition to bumping the reference count of the OF node being assigned,
it also assigns the fwnode of the platform device.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/platform.c         | 16 ++++++++++++++++
 include/linux/platform_device.h |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 6520b70cf3052d683a2ecb1a0dd7227575546ba0..f24a5f406746b53ca9eaab9472f6dd1345e04ad6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -730,6 +730,22 @@ void platform_device_set_fwnode(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_GPL(platform_device_set_fwnode);
 
+/**
+ * platform_device_set_of_node_from_dev - reuse OF node of another device
+ * @pdev: platform device to set the node for
+ * @dev2: device whose OF node to reuse
+ *
+ * Reuses the OF node of another device in this platform device while
+ * internally keeping track of reference counting.
+ */
+void platform_device_set_of_node_from_dev(struct platform_device *pdev,
+					  const struct device *dev2)
+{
+	device_set_of_node_from_dev(&pdev->dev, dev2);
+	pdev->dev.fwnode = of_fwnode_handle(pdev->dev.of_node);
+}
+EXPORT_SYMBOL_GPL(platform_device_set_of_node_from_dev);
+
 /**
  * platform_device_add - add a platform device to device hierarchy
  * @pdev: platform device we're adding
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index f037e4101c41dfdbf628d013348d7149ac519721..5333237ec58f30aecb05a3e160c7704fa07a0490 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -269,6 +269,8 @@ void platform_device_set_of_node(struct platform_device *pdev,
 				 struct device_node *np);
 void platform_device_set_fwnode(struct platform_device *pdev,
 				struct fwnode_handle *fwnode);
+void platform_device_set_of_node_from_dev(struct platform_device *pdev,
+					  const struct device *dev2);
 extern int platform_device_add(struct platform_device *pdev);
 extern void platform_device_del(struct platform_device *pdev);
 extern void platform_device_put(struct platform_device *pdev);

-- 
2.47.3



^ permalink raw reply related

* [PATCH v3 03/20] driver core: platform: provide platform_device_set_fwnode()
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski
In-Reply-To: <20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com>

Provide a helper function encapsulating the logic of assigning firmware
nodes to platform devices created with platform_device_alloc(). Make the
kerneldoc state that this is the proper interface for assigning firmware
nodes to dynamically allocated platform devices. This will allow us to
switch to counting the references of the device's firmware nodes in the
future, not only the OF nodes.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/platform.c         | 19 +++++++++++++++++++
 include/linux/platform_device.h |  3 +++
 2 files changed, 22 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 3188d5aba5f90622f821c695049cacda030204fb..6520b70cf3052d683a2ecb1a0dd7227575546ba0 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -711,6 +711,25 @@ void platform_device_set_of_node(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_GPL(platform_device_set_of_node);
 
+/**
+ * platform_device_set_fwnode - assign a firmware node to device
+ * @pdev: platform device to set the node for
+ * @fwnode: new firmware node
+ *
+ * Assign a firmware node to this platform device. Internally keep track of the
+ * reference count. Devices created with platform_device_alloc() must use this
+ * function instead of assigning the node manually.
+ */
+void platform_device_set_fwnode(struct platform_device *pdev,
+				struct fwnode_handle *fwnode)
+{
+	if (is_of_node(fwnode))
+		platform_device_set_of_node(pdev, to_of_node(fwnode));
+	else
+		pdev->dev.fwnode = fwnode;
+}
+EXPORT_SYMBOL_GPL(platform_device_set_fwnode);
+
 /**
  * platform_device_add - add a platform device to device hierarchy
  * @pdev: platform device we're adding
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index e9f7baceeb4c8269dbc0143c4d8fc9d73ba024ca..f037e4101c41dfdbf628d013348d7149ac519721 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -21,6 +21,7 @@ struct mfd_cell;
 struct property_entry;
 struct platform_device_id;
 struct device_node;
+struct fwnode_handle;
 
 struct platform_device {
 	const char	*name;
@@ -266,6 +267,8 @@ extern int platform_device_add_data(struct platform_device *pdev,
 				    const void *data, size_t size);
 void platform_device_set_of_node(struct platform_device *pdev,
 				 struct device_node *np);
+void platform_device_set_fwnode(struct platform_device *pdev,
+				struct fwnode_handle *fwnode);
 extern int platform_device_add(struct platform_device *pdev);
 extern void platform_device_del(struct platform_device *pdev);
 extern void platform_device_put(struct platform_device *pdev);

-- 
2.47.3



^ permalink raw reply related

* [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node()
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski, Manuel Ebner
In-Reply-To: <20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com>

Encapsulate the reference counting logic for OF nodes assigned to
platform devices created with platform_device_alloc() in a helper
function. Make the kerneldoc state that this is the proper interface for
assigning OF nodes to dynamically allocated platform devices. This will
allow us to switch to counting the references of the device's firmware
nodes, not only the OF nodes.

Reviewed-by: Manuel Ebner <manuelebner@mailbox.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/platform.c         | 18 ++++++++++++++++++
 include/linux/platform_device.h |  4 ++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index fb9120b0bcfe0e7dd9dfc0d29b91e0ad40a01440..3188d5aba5f90622f821c695049cacda030204fb 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -693,6 +693,24 @@ int platform_device_add_data(struct platform_device *pdev, const void *data,
 }
 EXPORT_SYMBOL_GPL(platform_device_add_data);
 
+/**
+ * platform_device_set_of_node - assign an OF node to device
+ * @pdev: platform device to add the node for
+ * @np: new device node
+ *
+ * Assign an OF node to this platform device. Internally keep track of the
+ * reference count. Devices created with platform_device_alloc() must use this
+ * function instead of assigning the node manually.
+ */
+void platform_device_set_of_node(struct platform_device *pdev,
+				 struct device_node *np)
+{
+	of_node_put(pdev->dev.of_node);
+	pdev->dev.of_node = of_node_get(np);
+	pdev->dev.fwnode = of_fwnode_handle(np);
+}
+EXPORT_SYMBOL_GPL(platform_device_set_of_node);
+
 /**
  * platform_device_add - add a platform device to device hierarchy
  * @pdev: platform device we're adding
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 8c566f09d04efe420d85ffa046f92c44c6d08526..e9f7baceeb4c8269dbc0143c4d8fc9d73ba024ca 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -19,6 +19,8 @@
 struct irq_affinity;
 struct mfd_cell;
 struct property_entry;
+struct platform_device_id;
+struct device_node;
 
 struct platform_device {
 	const char	*name;
@@ -262,6 +264,8 @@ extern int platform_device_add_resources(struct platform_device *pdev,
 					 unsigned int num);
 extern int platform_device_add_data(struct platform_device *pdev,
 				    const void *data, size_t size);
+void platform_device_set_of_node(struct platform_device *pdev,
+				 struct device_node *np);
 extern int platform_device_add(struct platform_device *pdev);
 extern void platform_device_del(struct platform_device *pdev);
 extern void platform_device_put(struct platform_device *pdev);

-- 
2.47.3



^ permalink raw reply related

* [PATCH v3 01/20] powerpc/powermac: fix OF node refcount
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski, stable
In-Reply-To: <20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com>

Platform devices created with platform_device_alloc() call
platform_device_release() when the last reference to the device's
kobject is dropped. This function calls of_node_put() unconditionally.
This works fine for devices created with platform_device_register_full()
but users of the split approach (platform_device_alloc() +
platform_device_add()) must bump the reference of the of_node they
assign manually. Add the missing call to of_node_get().

Cc: stable@vger.kernel.org
Fixes: 81e5d8646ff6 ("i2c/powermac: Register i2c devices from device-tree")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 arch/powerpc/platforms/powermac/low_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index da72a30ab8657e6dc7e6f3437af612155783d8f9..973f58771d9636605ed5d3e91b45008543b584d3 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -1471,7 +1471,7 @@ static int __init pmac_i2c_create_platform_devices(void)
 		if (bus->platform_dev == NULL)
 			return -ENOMEM;
 		bus->platform_dev->dev.platform_data = bus;
-		bus->platform_dev->dev.of_node = bus->busnode;
+		bus->platform_dev->dev.of_node = of_node_get(bus->busnode);
 		platform_device_add(bus->platform_dev);
 	}
 

-- 
2.47.3



^ permalink raw reply related

* [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
  To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
	Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
	Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
	David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
	Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
	Krzysztof Kozlowski, Benjamin Herrenschmidt
  Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
	driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
	imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
	platform-driver-x86, mfd, Bartosz Golaszewski, stable,
	Manuel Ebner, Wolfram Sang, Konrad Dybcio

Platform device core provides helper interfaces for dealing with
dynamically created platform devices. Most users should use
platform_device_register_full() which encapsulates most of the
operations but some modules will want to use the split approach of
calling platform_device_alloc() + platform_device_add() separately for
various reasons.

With many platform devices now using dynamic software nodes as their
primary firmware nodes and with the platform device interface being
extended to also better cover the use-cases of secondary software nodes,
I believe it makes sense to switch to counting the references of all
kinds of firmware nodes.

To that end, I identified all users of platform_device_alloc() that also
assign dev.of_node or dev.fwnode manually. I noticed five cases where
the references are not increased as they should (patches 1-5 fix these
users) and provided three new functions in platform_device.h that now
become the preferred interfaces for assigning firmware nodes to dynamic
platform devices (in line with platform_device_add_data(),
platform_device_add_resources(), etc.). The bulk of the patches in this
series are small driver conversions to port all users to going through
the new functions that now encapsulate the refcount logic. With that
done, the final patch seamlessly switches to counting the references of
all firmware node types.

This effort is prerequisite of removing platform_device_release_full()
and unifying the release path for dynamic platform devices using
unmanaged software nodes.

Merging strategy: The entire series should go through the driver core
tree, possibly with an immutable branch provided to solve any potential
conflicts though these are rather unlikely.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v3:
- Use device_set_node() where applicable
- Use __free(device_node) in fsl iommu driver
- Don't use __free() where not really required
- Add a patch updating the kerneldoc for platform_device_alloc()
- Collect more tags
- Link to v2: https://patch.msgid.link/20260629-pdev-fwnode-ref-v2-0-8abe2513f96e@oss.qualcomm.com

Changes in v2:
- Rebased on top of v7.2-rc1, dropped applied patches, collected tags
- Link to v1: https://patch.msgid.link/20260521-pdev-fwnode-ref-v1-0-88c324a1b8d2@oss.qualcomm.com

---
Bartosz Golaszewski (20):
      powerpc/powermac: fix OF node refcount
      driver core: platform: provide platform_device_set_of_node()
      driver core: platform: provide platform_device_set_fwnode()
      driver core: platform: provide platform_device_set_of_node_from_dev()
      driver core: update kerneldoc for platform_device_alloc()
      of: platform: use platform_device_set_of_node()
      powerpc/powermac: use platform_device_set_of_node()
      i2c: pxa-pci: use platform_device_set_of_node()
      iommu/fsl: use platform_device_set_of_node()
      net: bcmgenet: use platform_device_set_of_node()
      pmdomain: imx: use platform_device_set_of_node()
      mfd: tps6586: use platform_device_set_of_node()
      slimbus: qcom-ngd-ctrl: use platform_device_set_of_node()
      net: mv643xx: use platform_device_set_of_node()
      drm/xe/i2c: use platform_device_set_fwnode()
      platform/surface: gpe: use platform_device_set_fwnode()
      usb: chipidea: use platform_device_set_of_node_from_dev()
      usb: musb: use platform_device_set_of_node_from_dev()
      reset: rzg2l: use platform_device_set_of_node_from_dev()
      driver core: platform: count references to all kinds of firmware nodes

 arch/powerpc/platforms/powermac/low_i2c.c    |  2 +-
 drivers/base/platform.c                      | 61 ++++++++++++++++++++++++++--
 drivers/gpu/drm/xe/xe_i2c.c                  |  2 +-
 drivers/i2c/busses/i2c-pxa-pci.c             |  3 +-
 drivers/iommu/fsl_pamu.c                     | 16 +++-----
 drivers/mfd/tps6586x.c                       |  2 +-
 drivers/net/ethernet/broadcom/genet/bcmmii.c |  3 +-
 drivers/net/ethernet/marvell/mv643xx_eth.c   |  2 +-
 drivers/of/platform.c                        |  2 +-
 drivers/platform/surface/surface_gpe.c       |  2 +-
 drivers/pmdomain/imx/gpc.c                   |  3 +-
 drivers/reset/reset-rzg2l-usbphy-ctrl.c      |  2 +-
 drivers/slimbus/qcom-ngd-ctrl.c              |  2 +-
 drivers/usb/chipidea/core.c                  |  2 +-
 drivers/usb/musb/jz4740.c                    |  2 +-
 include/linux/platform_device.h              |  9 ++++
 16 files changed, 88 insertions(+), 27 deletions(-)
---
base-commit: 8cdeaa50eae8dad34885515f62559ee83e7e8dda
change-id: 20260520-pdev-fwnode-ref-d867836971eb

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>



^ permalink raw reply

* Re: [PATCH 31/42] ASoC: cix-ipbloq: Use devm_of_reserved_mem_device_init()
From: Mark Brown @ 2026-07-06 12:20 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Bjorn Andersson, Konrad Dybcio, Liviu Dudau, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Joel Stanley, Andrew Jeffery, Paul Cercueil, Anitha Chrisanthus,
	Paul Kocialkowski, Linus Walleij, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Alexey Brodkin, Laurent Pinchart, Tomi Valkeinen,
	Michal Simek, Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab,
	Eddie James, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
	Minghsiu Tsai, Houlong Wei, Matthias Brugger,
	AngeloGioacchino Del Regno, Joseph Liu, Marvin Lin,
	Dmitry Osipenko, Krzysztof Kozlowski, Thierry Reding,
	Jonathan Hunter, Srinivas Kandagatla, Arnd Bergmann,
	Greg Kroah-Hartman, Ge Gordon, Adrian Hunter, Ulf Hansson,
	Rob Herring, Saravana Kannan, Mathieu Poirier, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Liam Girdwood, Frank Li,
	Sascha Hauer, Peter Ujfalusi, Bard Liao, Daniel Baluta,
	Orson Zhai, Baolin Wang, Peter Chen, Fugang Duan, Ekansh Gupta,
	BST Linux Kernel Upstream Group, Fabio Estevam, Nicolin Chen,
	Pengutronix Kernel Team, Kai Vehmanen, Pierre-Louis Bossart,
	Vijendar Mukunda, Chunyan Zhang, CIX Linux Kernel Upstream Group,
	linux-arm-msm, linux-kernel, dri-devel, linux-aspeed,
	linux-arm-kernel, linux-mips, linux-sunxi, linux-media, openbmc,
	linux-mediatek, kernel, linux-tegra, linux-mmc, devicetree,
	linux-remoteproc, linux-staging, linux-sound, linuxppc-dev, imx,
	sound-open-firmware
In-Reply-To: <20260703193855.110619-32-mukesh.ojha@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

On Sat, Jul 04, 2026 at 01:08:44AM +0530, Mukesh Ojha wrote:
> Use the devres-managed devm_of_reserved_mem_device_init() to ensure
> the reserved memory region is released on device removal, fixing a
> missing cleanup in the original code.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH 29/42] ASoC: SOF: imx: Use devm_of_reserved_mem_device_init_by_name()
From: Mark Brown @ 2026-07-06 12:19 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Bjorn Andersson, Konrad Dybcio, Liviu Dudau, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Joel Stanley, Andrew Jeffery, Paul Cercueil, Anitha Chrisanthus,
	Paul Kocialkowski, Linus Walleij, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Alexey Brodkin, Laurent Pinchart, Tomi Valkeinen,
	Michal Simek, Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab,
	Eddie James, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
	Minghsiu Tsai, Houlong Wei, Matthias Brugger,
	AngeloGioacchino Del Regno, Joseph Liu, Marvin Lin,
	Dmitry Osipenko, Krzysztof Kozlowski, Thierry Reding,
	Jonathan Hunter, Srinivas Kandagatla, Arnd Bergmann,
	Greg Kroah-Hartman, Ge Gordon, Adrian Hunter, Ulf Hansson,
	Rob Herring, Saravana Kannan, Mathieu Poirier, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Liam Girdwood, Frank Li,
	Sascha Hauer, Peter Ujfalusi, Bard Liao, Daniel Baluta,
	Orson Zhai, Baolin Wang, Peter Chen, Fugang Duan, Ekansh Gupta,
	BST Linux Kernel Upstream Group, Fabio Estevam, Nicolin Chen,
	Pengutronix Kernel Team, Kai Vehmanen, Pierre-Louis Bossart,
	Vijendar Mukunda, Chunyan Zhang, CIX Linux Kernel Upstream Group,
	linux-arm-msm, linux-kernel, dri-devel, linux-aspeed,
	linux-arm-kernel, linux-mips, linux-sunxi, linux-media, openbmc,
	linux-mediatek, kernel, linux-tegra, linux-mmc, devicetree,
	linux-remoteproc, linux-staging, linux-sound, linuxppc-dev, imx,
	sound-open-firmware
In-Reply-To: <20260703193855.110619-30-mukesh.ojha@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

On Sat, Jul 04, 2026 at 01:08:42AM +0530, Mukesh Ojha wrote:
> Use the devres-managed devm_of_reserved_mem_device_init_by_name()
> instead of the manual of_reserved_mem_device_init_by_name()/
> of_reserved_mem_device_release() pair, letting the device resource
> manager handle cleanup automatically.

Acked-by: Mark Brown <Broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH 28/42] ASoC: mediatek: mt8189: Use devm_of_reserved_mem_device_init()
From: Mark Brown @ 2026-07-06 12:18 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Bjorn Andersson, Konrad Dybcio, Liviu Dudau, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Joel Stanley, Andrew Jeffery, Paul Cercueil, Anitha Chrisanthus,
	Paul Kocialkowski, Linus Walleij, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Alexey Brodkin, Laurent Pinchart, Tomi Valkeinen,
	Michal Simek, Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab,
	Eddie James, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
	Minghsiu Tsai, Houlong Wei, Matthias Brugger,
	AngeloGioacchino Del Regno, Joseph Liu, Marvin Lin,
	Dmitry Osipenko, Krzysztof Kozlowski, Thierry Reding,
	Jonathan Hunter, Srinivas Kandagatla, Arnd Bergmann,
	Greg Kroah-Hartman, Ge Gordon, Adrian Hunter, Ulf Hansson,
	Rob Herring, Saravana Kannan, Mathieu Poirier, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Liam Girdwood, Frank Li,
	Sascha Hauer, Peter Ujfalusi, Bard Liao, Daniel Baluta,
	Orson Zhai, Baolin Wang, Peter Chen, Fugang Duan, Ekansh Gupta,
	BST Linux Kernel Upstream Group, Fabio Estevam, Nicolin Chen,
	Pengutronix Kernel Team, Kai Vehmanen, Pierre-Louis Bossart,
	Vijendar Mukunda, Chunyan Zhang, CIX Linux Kernel Upstream Group,
	linux-arm-msm, linux-kernel, dri-devel, linux-aspeed,
	linux-arm-kernel, linux-mips, linux-sunxi, linux-media, openbmc,
	linux-mediatek, kernel, linux-tegra, linux-mmc, devicetree,
	linux-remoteproc, linux-staging, linux-sound, linuxppc-dev, imx,
	sound-open-firmware
In-Reply-To: <20260703193855.110619-29-mukesh.ojha@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

On Sat, Jul 04, 2026 at 01:08:41AM +0530, Mukesh Ojha wrote:
> Replace the hand-rolled devm wrapper (mt8189_afe_release_reserved_mem +
> devm_add_action_or_reset) with the standard
> devm_of_reserved_mem_device_init(), letting the device resource manager
> handle cleanup automatically.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH 27/42] ASoC: mediatek: mt8183: Use devm_of_reserved_mem_device_init()
From: Mark Brown @ 2026-07-06 12:17 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Bjorn Andersson, Konrad Dybcio, Liviu Dudau, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Joel Stanley, Andrew Jeffery, Paul Cercueil, Anitha Chrisanthus,
	Paul Kocialkowski, Linus Walleij, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Alexey Brodkin, Laurent Pinchart, Tomi Valkeinen,
	Michal Simek, Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab,
	Eddie James, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
	Minghsiu Tsai, Houlong Wei, Matthias Brugger,
	AngeloGioacchino Del Regno, Joseph Liu, Marvin Lin,
	Dmitry Osipenko, Krzysztof Kozlowski, Thierry Reding,
	Jonathan Hunter, Srinivas Kandagatla, Arnd Bergmann,
	Greg Kroah-Hartman, Ge Gordon, Adrian Hunter, Ulf Hansson,
	Rob Herring, Saravana Kannan, Mathieu Poirier, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Liam Girdwood, Frank Li,
	Sascha Hauer, Peter Ujfalusi, Bard Liao, Daniel Baluta,
	Orson Zhai, Baolin Wang, Peter Chen, Fugang Duan, Ekansh Gupta,
	BST Linux Kernel Upstream Group, Fabio Estevam, Nicolin Chen,
	Pengutronix Kernel Team, Kai Vehmanen, Pierre-Louis Bossart,
	Vijendar Mukunda, Chunyan Zhang, CIX Linux Kernel Upstream Group,
	linux-arm-msm, linux-kernel, dri-devel, linux-aspeed,
	linux-arm-kernel, linux-mips, linux-sunxi, linux-media, openbmc,
	linux-mediatek, kernel, linux-tegra, linux-mmc, devicetree,
	linux-remoteproc, linux-staging, linux-sound, linuxppc-dev, imx,
	sound-open-firmware
In-Reply-To: <20260703193855.110619-28-mukesh.ojha@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

On Sat, Jul 04, 2026 at 01:08:40AM +0530, Mukesh Ojha wrote:
> Replace the hand-rolled devm wrapper (mt8183_afe_release_reserved_mem +
> devm_add_action_or_reset) with the standard
> devm_of_reserved_mem_device_init(), letting the device resource manager
> handle cleanup automatically.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH 26/42] ASoC: mediatek: mt8196: Use devm_of_reserved_mem_device_init()
From: Mark Brown @ 2026-07-06 12:16 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Bjorn Andersson, Konrad Dybcio, Liviu Dudau, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Joel Stanley, Andrew Jeffery, Paul Cercueil, Anitha Chrisanthus,
	Paul Kocialkowski, Linus Walleij, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Alexey Brodkin, Laurent Pinchart, Tomi Valkeinen,
	Michal Simek, Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab,
	Eddie James, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
	Minghsiu Tsai, Houlong Wei, Matthias Brugger,
	AngeloGioacchino Del Regno, Joseph Liu, Marvin Lin,
	Dmitry Osipenko, Krzysztof Kozlowski, Thierry Reding,
	Jonathan Hunter, Srinivas Kandagatla, Arnd Bergmann,
	Greg Kroah-Hartman, Ge Gordon, Adrian Hunter, Ulf Hansson,
	Rob Herring, Saravana Kannan, Mathieu Poirier, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Liam Girdwood, Frank Li,
	Sascha Hauer, Peter Ujfalusi, Bard Liao, Daniel Baluta,
	Orson Zhai, Baolin Wang, Peter Chen, Fugang Duan, Ekansh Gupta,
	BST Linux Kernel Upstream Group, Fabio Estevam, Nicolin Chen,
	Pengutronix Kernel Team, Kai Vehmanen, Pierre-Louis Bossart,
	Vijendar Mukunda, Chunyan Zhang, CIX Linux Kernel Upstream Group,
	linux-arm-msm, linux-kernel, dri-devel, linux-aspeed,
	linux-arm-kernel, linux-mips, linux-sunxi, linux-media, openbmc,
	linux-mediatek, kernel, linux-tegra, linux-mmc, devicetree,
	linux-remoteproc, linux-staging, linux-sound, linuxppc-dev, imx,
	sound-open-firmware
In-Reply-To: <20260703193855.110619-27-mukesh.ojha@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

On Sat, Jul 04, 2026 at 01:08:39AM +0530, Mukesh Ojha wrote:
> Replace the hand-rolled devm wrapper (mt8196_afe_release_reserved_mem +
> devm_add_action_or_reset) with the standard
> devm_of_reserved_mem_device_init(), letting the device resource manager
> handle cleanup automatically.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH 25/42] ASoC: mediatek: mt8192: Use devm_of_reserved_mem_device_init()
From: Mark Brown @ 2026-07-06 12:16 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Bjorn Andersson, Konrad Dybcio, Liviu Dudau, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Joel Stanley, Andrew Jeffery, Paul Cercueil, Anitha Chrisanthus,
	Paul Kocialkowski, Linus Walleij, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Alexey Brodkin, Laurent Pinchart, Tomi Valkeinen,
	Michal Simek, Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab,
	Eddie James, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
	Minghsiu Tsai, Houlong Wei, Matthias Brugger,
	AngeloGioacchino Del Regno, Joseph Liu, Marvin Lin,
	Dmitry Osipenko, Krzysztof Kozlowski, Thierry Reding,
	Jonathan Hunter, Srinivas Kandagatla, Arnd Bergmann,
	Greg Kroah-Hartman, Ge Gordon, Adrian Hunter, Ulf Hansson,
	Rob Herring, Saravana Kannan, Mathieu Poirier, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Liam Girdwood, Frank Li,
	Sascha Hauer, Peter Ujfalusi, Bard Liao, Daniel Baluta,
	Orson Zhai, Baolin Wang, Peter Chen, Fugang Duan, Ekansh Gupta,
	BST Linux Kernel Upstream Group, Fabio Estevam, Nicolin Chen,
	Pengutronix Kernel Team, Kai Vehmanen, Pierre-Louis Bossart,
	Vijendar Mukunda, Chunyan Zhang, CIX Linux Kernel Upstream Group,
	linux-arm-msm, linux-kernel, dri-devel, linux-aspeed,
	linux-arm-kernel, linux-mips, linux-sunxi, linux-media, openbmc,
	linux-mediatek, kernel, linux-tegra, linux-mmc, devicetree,
	linux-remoteproc, linux-staging, linux-sound, linuxppc-dev, imx,
	sound-open-firmware
In-Reply-To: <20260703193855.110619-26-mukesh.ojha@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

On Sat, Jul 04, 2026 at 01:08:38AM +0530, Mukesh Ojha wrote:
> Replace the hand-rolled devm wrapper (mt8192_afe_release_reserved_mem +
> devm_add_action_or_reset) with the standard
> devm_of_reserved_mem_device_init(), letting the device resource manager
> handle cleanup automatically.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH 00/42] of: reserved_mem: Introduce devres helpers and convert drivers
From: Mark Brown @ 2026-07-06 12:14 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Bjorn Andersson, Konrad Dybcio, Liviu Dudau, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Joel Stanley, Andrew Jeffery, Paul Cercueil, Anitha Chrisanthus,
	Paul Kocialkowski, Linus Walleij, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Alexey Brodkin, Laurent Pinchart, Tomi Valkeinen,
	Michal Simek, Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab,
	Eddie James, Tiffany Lin, Andrew-CT Chen, Yunfei Dong,
	Minghsiu Tsai, Houlong Wei, Matthias Brugger,
	AngeloGioacchino Del Regno, Joseph Liu, Marvin Lin,
	Dmitry Osipenko, Krzysztof Kozlowski, Thierry Reding,
	Jonathan Hunter, Srinivas Kandagatla, Arnd Bergmann,
	Greg Kroah-Hartman, Ge Gordon, Adrian Hunter, Ulf Hansson,
	Rob Herring, Saravana Kannan, Mathieu Poirier, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Liam Girdwood, Frank Li,
	Sascha Hauer, Peter Ujfalusi, Bard Liao, Daniel Baluta,
	Orson Zhai, Baolin Wang, Peter Chen, Fugang Duan, Ekansh Gupta,
	BST Linux Kernel Upstream Group, Fabio Estevam, Nicolin Chen,
	Pengutronix Kernel Team, Kai Vehmanen, Pierre-Louis Bossart,
	Vijendar Mukunda, Chunyan Zhang, CIX Linux Kernel Upstream Group,
	linux-arm-msm, linux-kernel, dri-devel, linux-aspeed,
	linux-arm-kernel, linux-mips, linux-sunxi, linux-media, openbmc,
	linux-mediatek, kernel, linux-tegra, linux-mmc, devicetree,
	linux-remoteproc, linux-staging, linux-sound, linuxppc-dev, imx,
	sound-open-firmware
In-Reply-To: <20260703193855.110619-1-mukesh.ojha@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

On Sat, Jul 04, 2026 at 01:08:13AM +0530, Mukesh Ojha wrote:
> Drivers using of_reserved_mem_device_init() and its variants must
> manually call of_reserved_mem_device_release() in their remove and
> error-unwind paths. This is repetitive boilerplate that is easy to
> get wrong, and several drivers have open-coded the teardown
> inconsistently or skipped it entirely, leading to dangling reserved
> memory references.

Just as a general thing, rather than sending a huge cross subsystem
series for something like this it's probably better to just send a
couple of examples, then once the new API is introduced and either has a
pullable tag or has made it to mainline go and do the conversion.  This
avoids clogging everyone's inbox with very big serieses.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH v4 01/19] mm/hugetlb: Fix boot panic with CONFIG_DEBUG_VM and HVO bootmem pages
From: Muchun Song @ 2026-07-06 11:04 UTC (permalink / raw)
  To: Michał Cłapiński
  Cc: Muchun Song, Oscar Salvador, David Hildenbrand, Andrew Morton,
	Madhavan Srinivasan, Michael Ellerman, Mike Rapoport,
	Lorenzo Stoakes, Liam R . Howlett, Vlastimil Babka, linux-mm,
	linux-kernel, Nicholas Piggin, Christophe Leroy, Ritesh Harjani,
	Aneesh Kumar K . V, linuxppc-dev, Mike Kravetz
In-Reply-To: <b4b200da-f510-4fe2-95ac-c63e4467c4bd@google.com>



> On Jul 6, 2026, at 18:07, Michał Cłapiński <mclapinski@google.com> wrote:
> 
> On 6/12/26 5:58 AM, Muchun Song wrote:
>> Commit 622026e87c40 ("mm/hugetlb: remove fake head pages") switched
>> HVO to reuse per-zone shared tail pages from zone->vmemmap_tails[].
>> Those shared tail pages were initialized in hugetlb_vmemmap_init(), but
>> bootmem HugeTLB folios are prepared earlier from gather_bootmem_prealloc().
>> With hugetlb_free_vmemmap=on, prep_and_add_bootmem_folios() can access
>> pageblock flags on bootmem HugeTLB pages whose mirrored tail struct pages
>> already point to the shared tail page. On CONFIG_DEBUG_VM kernels,
>> get_pfnblock_bitmap_bitidx() then dereferences the still-uninitialized
>> shared tail page and can panic during boot.
>> Initialize zone->vmemmap_tails[] from gather_bootmem_prealloc(), before
>> bootmem HugeTLB folios are processed, and drop the later initialization
>> from hugetlb_vmemmap_init().
>> This bug only affects CONFIG_DEBUG_VM kernels, where the relevant
>> assertion is evaluated.
>> Fixes: 622026e87c40 ("mm/hugetlb: remove fake head pages")
>> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
>> Acked-by: Oscar Salvador <osalvador@suse.de>
>> ---
>>  mm/hugetlb.c         | 25 +++++++++++++++++++++++++
>>  mm/hugetlb_vmemmap.c | 17 -----------------
>>  mm/sparse-vmemmap.c  |  2 +-
>>  3 files changed, 26 insertions(+), 18 deletions(-)
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index 571212b80835..cd55524c7e30 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -3365,6 +3365,31 @@ static void __init gather_bootmem_prealloc(void)
>>   .max_threads = num_node_state(N_MEMORY),
>>   .numa_aware = true,
>>   };
>> +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
>> + struct zone *zone;
>> +
>> + for_each_zone(zone) {
>> + for (int i = 0; i < NR_VMEMMAP_TAILS; i++) {
>> + struct page *tail, *p;
>> + unsigned int order;
>> +
>> + tail = zone->vmemmap_tails[i];
>> + if (!tail)
>> + continue;
>> +
>> + order = i + VMEMMAP_TAIL_MIN_ORDER;
>> + p = page_to_virt(tail);
>> + /*
>> + * prep_and_add_bootmem_folios() can access pageblock
>> + * flags on bootmem HugeTLB pages, so initialize the
>> + * shared tail struct pages here before bootmem folios
>> + * start using them.
>> + */
>> + for (int j = 0; j < PAGE_SIZE / sizeof(struct page); j++)
>> + init_compound_tail(p + j, NULL, order, zone);
>> + }
>> + }
>> +#endif
> 
> I think it would be better if this was located in mm/hugetlb_vmemmap.c as a separate function.

This is actually just temporary. I already have another patch [1] that
completely removes this code later on. So, to avoid having to update
the entire patchset unnecessarily, I figured it's best to just leave
it as is for now, as it's not a major issue..

[1] https://lore.kernel.org/all/20260702093821.2740183-10-songmuchun@bytedance.com/

> 
>>     padata_do_multithreaded(&job);
>>  }
>> diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
>> index 133b46dfb09f..c713c0d2593a 100644
>> --- a/mm/hugetlb_vmemmap.c
>> +++ b/mm/hugetlb_vmemmap.c
>> @@ -870,27 +870,10 @@ static const struct ctl_table hugetlb_vmemmap_sysctls[] = {
>>  static int __init hugetlb_vmemmap_init(void)
>>  {
>>   const struct hstate *h;
>> - struct zone *zone;
>>     /* HUGETLB_VMEMMAP_RESERVE_SIZE should cover all used struct pages */
>>   BUILD_BUG_ON(__NR_USED_SUBPAGE > HUGETLB_VMEMMAP_RESERVE_PAGES);
>>  - for_each_zone(zone) {
>> - for (int i = 0; i < NR_VMEMMAP_TAILS; i++) {
>> - struct page *tail, *p;
>> - unsigned int order;
>> -
>> - tail = zone->vmemmap_tails[i];
>> - if (!tail)
>> - continue;
>> -
>> - order = i + VMEMMAP_TAIL_MIN_ORDER;
>> - p = page_to_virt(tail);
>> - for (int j = 0; j < PAGE_SIZE / sizeof(struct page); j++)
>> - init_compound_tail(p + j, NULL, order, zone);
>> - }
>> - }
>> -
>>   for_each_hstate(h) {
>>   if (hugetlb_vmemmap_optimizable(h)) {
>>   register_sysctl_init("vm", hugetlb_vmemmap_sysctls);
>> diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
>> index 99e2be39671b..bb23fb3077a3 100644
>> --- a/mm/sparse-vmemmap.c
>> +++ b/mm/sparse-vmemmap.c
>> @@ -342,7 +342,7 @@ static __meminit struct page *vmemmap_get_tail(unsigned int order, struct zone *
>>   *
>>   * Any initialization done here will be overwritten by memmap_init().
>>   *
>> - * hugetlb_vmemmap_init() will take care of initialization after
>> + * gather_bootmem_prealloc() will take care of initialization after
>>   * memmap_init().
>>   */
>>  
> 
> It gets the job done.
> 
> Tested-by: Michal Clapinski <mclapinski@google.com>
> Reviewed-by: Michal Clapinski <mclapinski@google.com>

Really thanks for your test.

Muchun,
Thanks.



^ permalink raw reply

* [PATCH v2 2/2] soc: fsl: dpio: Use scope-based resource management in dpaa2_io_create()
From: Markus Elfring @ 2026-07-06 10:40 UTC (permalink / raw)
  To: linux-arm-kernel, linuxppc-dev, Christophe Leroy, Roy Pledge
  Cc: LKML, kernel-janitors
In-Reply-To: <d2e5df25-c8b7-4ee6-8ebf-1725542baabd@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Jul 2026 11:18:39 +0200

Scope-based resource management became supported for some
programming interfaces by contributions of Peter Zijlstra on 2023-05-26.
See also the commit 54da6a0924311c7cf5015533991e44fb8eb12773 ("locking:
Introduce __cleanup() based infrastructure").

* Thus use the attribute “__free(kfree)”.

* Omit two kfree() calls accordingly.

* Reduce the scopes for the local variables “obj”
  and “qman_256_cycles_per_ns”.

* Use the macro call “return_ptr(obj)” at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/soc/fsl/dpio/dpio-service.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c
index b252c3c7fa65..80fb11206160 100644
--- a/drivers/soc/fsl/dpio/dpio-service.c
+++ b/drivers/soc/fsl/dpio/dpio-service.c
@@ -133,17 +133,14 @@ static void dpaa2_io_dim_work(struct work_struct *w)
 struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc,
 				 struct device *dev)
 {
-	struct dpaa2_io *obj = kmalloc_obj(*obj);
-	u32 qman_256_cycles_per_ns;
-
-	if (!obj)
+	/* check if CPU is out of range (-1 means any cpu) */
+	if (desc->cpu != DPAA2_IO_ANY_CPU && desc->cpu >= num_possible_cpus())
 		return NULL;
 
-	/* check if CPU is out of range (-1 means any cpu) */
-	if (desc->cpu != DPAA2_IO_ANY_CPU && desc->cpu >= num_possible_cpus()) {
-		kfree(obj);
+	struct dpaa2_io *obj __free(kfree) = kmalloc_obj(*obj);
+
+	if (!obj)
 		return NULL;
-	}
 
 	obj->dpio_desc = *desc;
 	obj->swp_desc.cena_bar = obj->dpio_desc.regs_cena;
@@ -155,14 +152,11 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc,
 	 * the interrupt timeout period register needs to be specified in QBMAN
 	 * clock cycles in increments of 256.
 	 */
-	qman_256_cycles_per_ns = 256000 / (obj->swp_desc.qman_clk / 1000000);
+	u32 qman_256_cycles_per_ns = 256000 / (obj->swp_desc.qman_clk / 1000000);
 	obj->swp_desc.qman_256_cycles_per_ns = qman_256_cycles_per_ns;
 	obj->swp = qbman_swp_init(&obj->swp_desc);
-
-	if (!obj->swp) {
-		kfree(obj);
+	if (!obj->swp)
 		return NULL;
-	}
 
 	INIT_LIST_HEAD(&obj->node);
 	spin_lock_init(&obj->lock_mgmt_cmd);
@@ -191,7 +185,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc,
 	obj->bytes = 0;
 	obj->frames = 0;
 
-	return obj;
+	return_ptr(obj);
 }
 
 /**
-- 
2.54.0



^ permalink raw reply related

* [PATCH v2 1/2] soc: fsl: dpio: Use scope-based resource management in dpaa2_io_store_create()
From: Markus Elfring @ 2026-07-06 10:38 UTC (permalink / raw)
  To: linux-arm-kernel, linuxppc-dev, Christophe Leroy, Roy Pledge
  Cc: LKML, kernel-janitors
In-Reply-To: <d2e5df25-c8b7-4ee6-8ebf-1725542baabd@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Jul 2026 10:34:43 +0200

Scope-based resource management became supported for some
programming interfaces by contributions of Peter Zijlstra on 2023-05-26.
See also the commit 54da6a0924311c7cf5015533991e44fb8eb12773 ("locking:
Introduce __cleanup() based infrastructure").

* Thus use the attribute “__free(kfree)”.

* Reduce the scope for the local variable “ret”.

* Omit two kfree() calls accordingly.

* Omit the local variable “size” (for another memory allocation).

* Use the macro call “return_ptr(ret)” at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/soc/fsl/dpio/dpio-service.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c
index 317ca50b0c2b..b252c3c7fa65 100644
--- a/drivers/soc/fsl/dpio/dpio-service.c
+++ b/drivers/soc/fsl/dpio/dpio-service.c
@@ -652,23 +652,17 @@ EXPORT_SYMBOL_GPL(dpaa2_io_service_acquire);
 struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames,
 					     struct device *dev)
 {
-	struct dpaa2_io_store *ret;
-	size_t size;
-
 	if (!max_frames || (max_frames > 32))
 		return NULL;
 
-	ret = kmalloc_obj(*ret);
+	struct dpaa2_io_store *ret __free(kfree) = kmalloc_obj(*ret);
 	if (!ret)
 		return NULL;
 
 	ret->max = max_frames;
-	size = max_frames * sizeof(struct dpaa2_dq) + 64;
-	ret->alloced_addr = kzalloc(size, GFP_KERNEL);
-	if (!ret->alloced_addr) {
-		kfree(ret);
+	ret->alloced_addr = kzalloc(max_frames * sizeof(struct dpaa2_dq) + 64, GFP_KERNEL);
+	if (!ret->alloced_addr)
 		return NULL;
-	}
 
 	ret->vaddr = PTR_ALIGN(ret->alloced_addr, 64);
 	ret->paddr = dma_map_single(dev, ret->vaddr,
@@ -676,14 +670,13 @@ struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames,
 				    DMA_FROM_DEVICE);
 	if (dma_mapping_error(dev, ret->paddr)) {
 		kfree(ret->alloced_addr);
-		kfree(ret);
 		return NULL;
 	}
 
 	ret->idx = 0;
 	ret->dev = dev;
 
-	return ret;
+	return_ptr(ret);
 }
 EXPORT_SYMBOL_GPL(dpaa2_io_store_create);
 
-- 
2.54.0



^ permalink raw reply related

* [PATCH v2 0/2] soc: fsl: dpio: Use scope-based resource management in two functions
From: Markus Elfring @ 2026-07-06 10:36 UTC (permalink / raw)
  To: linux-arm-kernel, linuxppc-dev, Christophe Leroy, Roy Pledge
  Cc: LKML, kernel-janitors
In-Reply-To: <d95d2f4c-f3cf-44eb-b61b-79ba7891674d@kernel.org>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Jul 2026 11:42:10 +0200

Some adjustment opportunities were picked up.

Markus Elfring (2):
  Use scope-based resource management in dpaa2_io_store_create()
  Use scope-based resource management in dpaa2_io_create()


v2:
Christophe Leroy requested to apply the attribute “__free(kfree)”.


 drivers/soc/fsl/dpio/dpio-service.c | 37 ++++++++++-------------------
 1 file changed, 12 insertions(+), 25 deletions(-)

-- 
2.54.0



^ permalink raw reply

* Re: [kvm-unit-tests RFC PATCH 2/6] configure: Make arch_libdir a first-class entity
From: Thomas Huth @ 2026-07-06 10:36 UTC (permalink / raw)
  To: Chinmay Rath
  Cc: npiggin, harshpb, lvivier, linuxppc-dev, kvm, andrew.jones, sbhat
In-Reply-To: <efbbe11b-9e02-4878-b61a-f804b491ab4c@linux.ibm.com>

On 03/07/2026 08.46, Chinmay Rath wrote:
> 
> On 6/10/26 17:00, Thomas Huth wrote:
>> On 02/06/2026 08.48, Chinmay Rath wrote:
>>> From: Nicholas Piggin <npiggin@gmail.com>
>>>
>>> arch_libdir was brought in to improve the heuristic determination of
>>> the lib/ directory based on arch and testdir names, but it did not
>>> entirely clean that mess up.
>>>
>>> Remove the arch_libdir->arch->testdir heuristic and just require
>>> everybody sets arch_libdir correctly. Fail if the lib/arch or
>>> lib/arch/asm directories can not be found.
>>>
>>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>>> Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
>>> ---
>>>   Makefile  |  2 +-
>>>   configure | 20 ++++++++++++--------
>>>   2 files changed, 13 insertions(+), 9 deletions(-)
>>
>> FYI, this patch seems to trigger yet another issue with Clang (I used v21):
>>
>> clang -no-integrated-as -std=gnu99 -ffreestanding -O2 -msoft-float -mno- 
>> altivec  -I /root/kvm-unit-tests/lib -I /root/kvm-unit-tests/lib/libfdt -I 
>> lib -Wa,-mregnames -fverbose-asm -S -o lib/powerpc/asm-offsets.s lib/ 
>> powerpc/asm-offsets.c
>> lib/powerpc/asm-offsets.c:10:10: error: 'asm/smp.h' file not found with 
>> <angled> include; use
>>       "quotes" instead
>>    10 | #include <asm/smp.h>
>>       |          ^~~~~~~~~~~
>>       |          "asm/smp.h"
>> In file included from lib/powerpc/asm-offsets.c:10:
>> lib/powerpc/asm/smp.h:5:10: fatal error: 'asm/processor.h' file not found
>>     5 | #include <asm/processor.h>
>>       |          ^~~~~~~~~~~~~~~~~
>> 2 errors generated.
>>
>> Could you please have a look?
> 
> Hi Thomas, back from traveling and looked into this.
> I am using Clang v21 as well :
> # clang --version
> clang version 21.1.8 (Fedora 21.1.8-4.fc43)
> Target: ppc64le-redhat-linux-gnu
> Thread model: posix
> InstalledDir: /usr/bin
> Configuration file: /etc/clang/ppc64le-redhat-linux-gnu-clang.cfg
> 
> I see the above file, asm-offsets.s being generated properly without any 
> error during the make process (used the extra flags for make that I have 
> mentioned in my other reply).
> Snippet from make :
> cat powerpc/boot_rom.bin.tmp >> powerpc/boot_rom.bin
> rm -f powerpc/boot_rom.bin.tmp
> clang -no-integrated-as -Wa,-mpower10 -std=gnu99 -ffreestanding -O2 -msoft- 
> float -mno-altivec  -I /root/chins/git/kvm-unit-tests/lib -I /root/chins/ 
> git/kvm-unit-tests/lib/libfdt -I lib -Wa,-mregnames -fverbose-asm -S -o lib/ 
> powerpc/asm-offsets.s /root/chins/git/kvm-unit-tests/lib/powerpc/asm-offsets.c
> (set -e; echo "#ifndef __ASM_OFFSETS_H__"; echo "#define __ASM_OFFSETS_H__"; 
> echo "/*"; echo " * Generated file. DO NOT MODIFY."; echo " *"; echo " */"; 
> echo ""; sed -ne  's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; /^->/ 
> {s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([-0-9]*\) \(.*\):#define \1 
> \2 /* \3 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; 
> s:->::; p;}' lib/powerpc/asm-offsets.s; echo ""; echo "#endif" ) > lib/ 
> powerpc/asm-offsets.h
> cp -f lib/powerpc/asm-offsets.h lib/generated/
> clang -no-integrated-as -Wa,-mpower10 -std=gnu99 -ffreestanding -O2 -msoft- 
> float -mno-altivec  -I /root/chins/git/kvm-unit-tests/lib -I /root/chins/ 
> git/kvm-unit-tests/lib/libfdt -I lib -Wa,-mregnames -g -MMD -MP -MF 
> powerpc/.selftest.d -fno-strict-aliasing -fno-common -Wall -Wwrite-strings - 
> Wempty-body -Wuninitialized -Wignored-qualifiers -Wno-missing-braces -Werror 
> -fomit-frame-pointer  -fno-stack-protector   -Wno-frame-address  -fno-pic    
> -Wunused-but-set-parameter -Wno-override-init  -Wmissing-prototypes - 
> Wstrict-prototypes -mlittle-endian   -c -o powerpc/selftest.o /root/chins/ 
> git/kvm-unit-tests/powerpc/selftest.c
> 
> Infact, if I just execute that single command independently to build asm- 
> offsets.s, it works as well.

Ok, I finally got access to a POWER system again and tried to reproduce the 
issue, but I also cannot reproduce it anymore. No clue how I managed to get 
into that situation, but looks like it was rather due to a messed up build 
tree than due to your patch. So sorry for the trouble, and please go ahead 
and simply ignore my objection here.

  Thanks,
   Thomas




^ permalink raw reply

* Re: [PATCH 03/12] dt-bindings: soc: fsl: qe: Convert QE GPIO to DT schema
From: Paul Louvel @ 2026-07-06  9:03 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Paul Louvel
  Cc: Qiang Zhao, Christophe Leroy (CS GROUP), Thomas Gleixner,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij,
	Bartosz Golaszewski, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, linuxppc-dev, linux-arm-kernel, linux-kernel,
	devicetree, linux-gpio, Thomas Petazzoni
In-Reply-To: <20260706-piquant-arboreal-panda-b810f2@quoll>

Hi Krzysztof,

On Mon Jul 6, 2026 at 8:48 AM CEST, Krzysztof Kozlowski wrote:
> On Fri, Jul 03, 2026 at 03:30:11PM +0200, Paul Louvel wrote:
>> diff --git a/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml b/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml
>> new file mode 100644
>> index 000000000000..1af99339ff40
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml
>> @@ -0,0 +1,45 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/gpio/fsl,mpc8323-qe-pario-bank.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Freescale QUICC Engine Parallel I/O (QE PARIO) GPIO Bank
>> +
>> +maintainers:
>> +  - Christophe Leroy <christophe.leroy@csgroup.eu>
>> +
>> +properties:
>> +  compatible:
>> +    oneOf:
>> +      - items:
>> +          - enum:
>> +              - fsl,mpc8360-qe-pario-bank
>> +              - fsl,mpc8569-qe-pario-bank
>
> None of these were in the old binding. You need to mention and
> explain (WHY) the changes you are doing to the binding during the
> conversion.

Ok.

>
>> +          - const: fsl,mpc8323-qe-pario-bank
>> +      - const: fsl,mpc8323-qe-pario-bank
>
> Best regards,
> Krzysztof

Thanks,
Paul.


-- 
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply

* Re: [PATCH 08/12] soc: fsl: qe: Convert to generic IRQ chip
From: Paul Louvel @ 2026-07-06  8:56 UTC (permalink / raw)
  To: Christophe Leroy (CS GROUP), Paul Louvel, Qiang Zhao,
	Thomas Gleixner, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Linus Walleij, Bartosz Golaszewski, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin
  Cc: linuxppc-dev, linux-arm-kernel, linux-kernel, devicetree,
	linux-gpio, Thomas Petazzoni
In-Reply-To: <34946670-2a76-47fa-af82-3d70cdc9d8f0@kernel.org>

On Mon Jul 6, 2026 at 9:29 AM CEST, Christophe Leroy (CS GROUP) wrote:
> Hi Paul,
>
> Le 03/07/2026 à 15:30, Paul Louvel a écrit :
>> The generic IRQ chip framework is available to handle IRQ chips. Using
>> this framework for the QE interrupt controller allows to simplify the
>> driver. Indeed, the framework internally handles operations coded
>> directly in the driver.
>> 
>> Add a select dependency to GENERIC_IRQ_CHIP in the PPC platform Kconfig.
>> 
>> Signed-off-by: Paul Louvel <paul.louvel@bootlin.com>
>> ---
>>   arch/powerpc/platforms/Kconfig   |   1 +
>>   drivers/soc/fsl/qe/qe_ports_ic.c | 103 ++++++++++++++++++++++++++-------------
>>   2 files changed, 70 insertions(+), 34 deletions(-)
>> 
>> diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
>> index c4e61843d9d9..b0b3a80f8cde 100644
>> --- a/arch/powerpc/platforms/Kconfig
>> +++ b/arch/powerpc/platforms/Kconfig
>> @@ -232,6 +232,7 @@ config QE_GPIO
>>   	bool "QE GPIO support"
>>   	depends on QUICC_ENGINE
>>   	select GPIOLIB
>> +	select GENERIC_IRQ_CHIP
>>   	help
>>   	  Say Y here if you're going to use hardware that connects to the
>>   	  QE GPIOs.
>> diff --git a/drivers/soc/fsl/qe/qe_ports_ic.c b/drivers/soc/fsl/qe/qe_ports_ic.c
>> index c8b73b0aa233..d022aa224f6d 100644
>> --- a/drivers/soc/fsl/qe/qe_ports_ic.c
>> +++ b/drivers/soc/fsl/qe/qe_ports_ic.c
>> @@ -20,63 +20,65 @@ struct qepic_data {
>>   	void __iomem *reg;
>>   	struct irq_domain *host;
>>   	int irq;
>> +	struct irq_chip_generic *gc;
>>   };
>>   
>>   static void qepic_mask(struct irq_data *d)
>>   {
>> -	struct qepic_data *data = irq_data_get_irq_chip_data(d);
>> +	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
>> +	struct irq_chip_type *ct = irq_data_get_chip_type(d);
>>   
>> -	clrbits32(data->reg + CEPIMR, 1 << (31 - irqd_to_hwirq(d)));
>> +	clrbits32(gc->reg_base + ct->regs.mask, d->mask);
>
> Is there a real added value with this change ?
>
> Previously we had:
>
> 00000000 <qepic_mask>:
>     0:	81 03 00 18 	lwz     r8,24(r3)
>     4:	81 28 00 00 	lwz     r9,0(r8)
>     8:	7c 00 04 ac 	hwsync
>     c:	81 29 00 10 	lwz     r9,16(r9)
>    10:	0c 09 00 00 	twi     0,r9,0
>    14:	4c 00 01 2c 	isync
>    18:	80 e3 00 08 	lwz     r7,8(r3)
>    1c:	3d 40 80 00 	lis     r10,-32768
>    20:	81 08 00 00 	lwz     r8,0(r8)
>    24:	7d 4a 3c 30 	srw     r10,r10,r7
>    28:	7d 29 50 78 	andc    r9,r9,r10
>    2c:	7c 00 04 ac 	hwsync
>    30:	91 28 00 10 	stw     r9,16(r8)
>    34:	4e 80 00 20 	blr
>
> Now we have:
>
> 00000000 <qepic_mask>:
>     0:	80 e3 00 18 	lwz     r7,24(r3)
>     4:	81 03 00 10 	lwz     r8,16(r3)
>     8:	81 27 00 00 	lwz     r9,0(r7)
>     c:	81 48 00 94 	lwz     r10,148(r8)
>    10:	7d 29 52 14 	add     r9,r9,r10
>    14:	7c 00 04 ac 	hwsync
>    18:	81 49 00 00 	lwz     r10,0(r9)
>    1c:	0c 0a 00 00 	twi     0,r10,0
>    20:	4c 00 01 2c 	isync
>    24:	80 c3 00 00 	lwz     r6,0(r3)
>    28:	81 27 00 00 	lwz     r9,0(r7)
>    2c:	81 08 00 94 	lwz     r8,148(r8)
>    30:	7d 4a 30 78 	andc    r10,r10,r6
>    34:	7d 29 42 14 	add     r9,r9,r8
>    38:	7c 00 04 ac 	hwsync
>    3c:	91 49 00 00 	stw     r10,0(r9)
>    40:	4e 80 00 20 	blr
>
> We now have three more indirect loads (8x lwz instead of 5x), for 
> loading some value which is already known at compile time.
>
>
>>   }
>>   
>>   static void qepic_unmask(struct irq_data *d)
>>   {
>> -	struct qepic_data *data = irq_data_get_irq_chip_data(d);
>> +	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
>> +	struct irq_chip_type *ct = irq_data_get_chip_type(d);
>>   
>> -	setbits32(data->reg + CEPIMR, 1 << (31 - irqd_to_hwirq(d)));
>> +	setbits32(gc->reg_base + ct->regs.mask, d->mask);
>>   }
>>   
>>   static void qepic_end(struct irq_data *d)
>>   {
>> -	struct qepic_data *data = irq_data_get_irq_chip_data(d);
>> +	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
>> +	struct irq_chip_type *ct = irq_data_get_chip_type(d);
>>   
>> -	out_be32(data->reg + CEPIER, 1 << (31 - irqd_to_hwirq(d)));
>> +	out_be32(gc->reg_base + ct->regs.eoi, d->mask);
>> +}
>> +
>> +static void qepic_calc_mask(struct irq_data *d)
>> +{
>> +	d->mask = 1 << (31 - irqd_to_hwirq(d));
>>   }
>>   
>>   static int qepic_set_type(struct irq_data *d, unsigned int flow_type)
>>   {
>> -	struct qepic_data *data = irq_data_get_irq_chip_data(d);
>> -	unsigned int vec = (unsigned int)irqd_to_hwirq(d);
>> +	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
>> +	struct irq_chip_type *ct = irq_data_get_chip_type(d);
>>   
>>   	switch (flow_type & IRQ_TYPE_SENSE_MASK) {
>>   	case IRQ_TYPE_EDGE_FALLING:
>> -		setbits32(data->reg + CEPICR, 1 << (31 - vec));
>> +		setbits32(gc->reg_base + ct->regs.type, d->mask);
>>   		return 0;
>>   	case IRQ_TYPE_EDGE_BOTH:
>>   	case IRQ_TYPE_NONE:
>> -		clrbits32(data->reg + CEPICR, 1 << (31 - vec));
>> +		clrbits32(gc->reg_base + ct->regs.type, d->mask);
>>   		return 0;
>>   	}
>>   	return -EINVAL;
>>   }
>>   
>> -static struct irq_chip qepic = {
>> -	.name = "QEPIC",
>> -	.irq_mask = qepic_mask,
>> -	.irq_unmask = qepic_unmask,
>> -	.irq_eoi = qepic_end,
>> -	.irq_set_type = qepic_set_type,
>> -};
>> -
>>   static void qepic_cascade(struct irq_desc *desc)
>>   {
>>   	struct qepic_data *data = irq_desc_get_handler_data(desc);
>> +	struct irq_chip_type *ct = data->gc->chip_types;
>>   	struct irq_chip *chip = irq_desc_get_chip(desc);
>>   	unsigned long event, bit;
>>   
>>   	chained_irq_enter(chip, desc);
>>   
>> -	event = in_be32(data->reg + CEPIER);
>> +	event = in_be32(data->gc->reg_base + ct->regs.eoi);
>>   	if (!event) {
>>   		handle_bad_irq(desc);
>>   		goto out;
>> @@ -89,33 +91,64 @@ static void qepic_cascade(struct irq_desc *desc)
>>   	chained_irq_exit(chip, desc);
>>   }
>>   
>> -static int qepic_host_map(struct irq_domain *h, unsigned int virq, irq_hw_number_t hw)
>> +static int qepic_chip_init(struct irq_chip_generic *gc)
>>   {
>> -	irq_set_chip_data(virq, h->host_data);
>> -	irq_set_chip_and_handler(virq, &qepic, handle_fasteoi_irq);
>> +	struct irq_chip_type *ct = gc->chip_types;
>> +
>> +	ct->regs.mask = CEPIMR;
>> +	ct->chip.irq_mask = qepic_mask;
>> +	ct->chip.irq_unmask = qepic_unmask;
>> +	ct->regs.eoi = CEPIER;
>> +	ct->chip.irq_eoi = qepic_end;
>> +	ct->regs.type = CEPICR;
>> +	ct->chip.irq_set_type = qepic_set_type;
>> +	ct->chip.irq_calc_mask = qepic_calc_mask;
>
> Are ct->regs.mask, ct->regs.eoi and ct->regs.type used anywhere else 
> than locally in qepic_{mask/unmask/end/set_type} ?

No they are not.
The main purpose of these registers is that they are used in the generic irq
chip framework functions like irq_gc_mask_set_bit(), which we dropped earlier in
favor of using our own hooks.
At this stage, if you consider that the instructions overhead of the functions
above is already too much, it is better to get rid of the framework completly
then.

>
> Christophe
>
>> +
>>   	return 0;
>>   }
>>   
>> -static const struct irq_domain_ops qepic_host_ops = {
>> -	.map = qepic_host_map,
>> -};
>> +static int qepic_domain_init(struct irq_domain *d)
>> +{
>> +	struct qepic_data *data = d->host_data;
>>   
>> -static void qepic_remove(void *res)
>> +	irq_set_chained_handler_and_data(data->irq, qepic_cascade, data);
>> +
>> +	return 0;
>> +}
>> +
>> +static void qepic_domain_exit(struct irq_domain *d)
>>   {
>> -	struct qepic_data *data = res;
>> +	struct qepic_data *data = d->host_data;
>>   
>>   	irq_set_chained_handler_and_data(data->irq, NULL, NULL);
>> -	irq_domain_remove(data->host);
>>   }
>>   
>>   static int qepic_probe(struct platform_device *pdev)
>>   {
>> +	struct irq_domain_chip_generic_info dgc_info = {
>> +		.name		= "QEPIC",
>> +		.handler	= handle_fasteoi_irq,
>> +		.irqs_per_chip	= 32,
>> +		.num_ct		= 1,
>> +		.init		= qepic_chip_init,
>> +	};
>> +	struct irq_domain_info d_info = {
>> +		.fwnode		= of_fwnode_handle(pdev->dev.of_node),
>> +		.domain_flags	= IRQ_DOMAIN_FLAG_DESTROY_GC,
>> +		.size		= 32,
>> +		.hwirq_max	= 32,
>> +		.ops		= &irq_generic_chip_ops,
>> +		.dgc_info	= &dgc_info,
>> +		.init		= qepic_domain_init,
>> +		.exit		= qepic_domain_exit,
>> +	};
>>   	struct device *dev = &pdev->dev;
>>   	struct qepic_data *data;
>>   
>>   	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
>>   	if (!data)
>>   		return -ENOMEM;
>> +	d_info.host_data = data;
>>   
>>   	data->reg = devm_platform_ioremap_resource(pdev, 0);
>>   	if (IS_ERR(data->reg))
>> @@ -125,14 +158,16 @@ static int qepic_probe(struct platform_device *pdev)
>>   	if (data->irq < 0)
>>   		return data->irq;
>>   
>> -	data->host = irq_domain_create_linear(dev_fwnode(dev), 32, &qepic_host_ops, data);
>> -	if (!data->host)
>> -		return -ENODEV;
>> +	data->host = devm_irq_domain_instantiate(dev, &d_info);
>> +	if (IS_ERR(data->host))
>> +		return PTR_ERR(data->host);
>>   
>> -	irq_set_chained_handler_and_data(data->irq, qepic_cascade, data);
>> -
>> -	return devm_add_action_or_reset(dev, qepic_remove, data);
>> +	data->gc = irq_get_domain_generic_chip(data->host, 0);
>> +	if (!data->gc)
>> +		return -ENODEV;
>> +	data->gc->reg_base = data->reg;
>>   
>> +	return 0;
>>   }
>>   
>>   static const struct of_device_id qepic_match[] = {
>> 

Thanks,
Paul.



-- 
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply

* Re: [PATCH 04/12] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
From: Paul Louvel @ 2026-07-06  8:48 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Paul Louvel
  Cc: Qiang Zhao, Christophe Leroy (CS GROUP), Thomas Gleixner,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij,
	Bartosz Golaszewski, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, linuxppc-dev, linux-arm-kernel, linux-kernel,
	devicetree, linux-gpio, Thomas Petazzoni
In-Reply-To: <20260706-elfish-cornflower-bullfinch-604e0a@quoll>

On Mon Jul 6, 2026 at 8:52 AM CEST, Krzysztof Kozlowski wrote:
> On Fri, Jul 03, 2026 at 03:30:12PM +0200, Paul Louvel wrote:
>> Some QE GPIO pins have an associated interrupt line in the QE PIC to
>> signal state changes on the pin.  Add the corresponding
>> interrupt-controller / nexus properties to the QE GPIO binding.
>> 
>> Because the GPIO controller does not perform any interrupt handling
>> itself, a nexus node (interrupt-map) is used to map each GPIO line
>> supporting IRQ to the parent QE PIC interrupt domain.
>> 
>> As the QE PIC can be configured to generate an interrupt on either a
>> high-to-low transition or any change in signal state, three
>> interrupt-map entries are needed per GPIO pin that can yield an
>> interrupt (falling, both, and the "none" case which defaults to both in
>> QE PIC).  This overhead is necessary because the interrupt-map-pass-thru
>> property is not part of the DT specification.
>> 
>> The interrupt-map property is optional: it is not required for GPIO
>> banks that have no interrupt capable GPIO line (e.g. port D on MPC8323),
>> or when interrupt functionality is not used.
>> 
>> Update the example to show a scenario where each bank supports a
>> different numbers of IRQs, or no IRQs at all.
>> 
>> Signed-off-by: Paul Louvel <paul.louvel@bootlin.com>
>> ---
>>  .../bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml   | 69 +++++++++++++++++++++-
>>  1 file changed, 66 insertions(+), 3 deletions(-)
>> 
>> diff --git a/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml b/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml
>> index 1af99339ff40..0c849a5698f4 100644
>> --- a/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml
>> +++ b/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml
>> @@ -27,6 +27,17 @@ properties:
>>    "#gpio-cells":
>>      const: 2
>>  
>> +  "#address-cells":
>> +    const: 0
>> +
>> +  "#interrupt-cells":
>> +    const: 2
>> +
>
> If this has interrupt-cells, then it is a nexus, thus why isn't this
> also a "interrupt-controller"?

Because these these banks are not interrupt controllers.
Interrupts are handled by the QE PIC, and the GPIO controller does not do any
interrupt handling itself.
In this setup, does it really needs an "interrupt-controller" property?

>
>> +  interrupt-map:
>> +    description: |
>> +      Specifies the mapping of GPIO lines to the parent interrupt controller, as the
>> +      GPIO controller does not do interrupt handling itself.
>> +
>>  required:
>>    - compatible
>>    - reg
>> @@ -37,9 +48,61 @@ additionalProperties: false
>>  
>>  examples:
>>    - |
>> -    gpio-controller@1400 {
>> -        compatible = "fsl,mpc8360-qe-pario-bank", "fsl,mpc8323-qe-pario-bank";
>> -        reg = <0x1400 0x18>;
>
> I don't get why you rewrite existing example instead of adding new one.

I could yes.

>
>> +    #include <dt-bindings/interrupt-controller/irq.h>
>> +
>> +    pic: interrupt-controller {
>> +      interrupt-controller;
>> +      #address-cells = <0>;
>> +      #interrupt-cells = <2>;
>> +    };
>
> Drop node, irrelevant.
>
>> +
>> +    gpio-controller@1418 {
>> +        #gpio-cells = <2>;
>> +        #address-cells = <0>;
>> +        #interrupt-cells = <2>;
>> +        compatible = "fsl,mpc8323-qe-pario-bank";
>> +        reg = <0x1418 0x18>;
>
> And now you are not following DTS coding style.
>
>>          gpio-controller;
>> +        interrupt-map = <
>> +          7 IRQ_TYPE_EDGE_FALLING  &pic 4 IRQ_TYPE_EDGE_FALLING
>> +          7 IRQ_TYPE_EDGE_BOTH     &pic 4 IRQ_TYPE_EDGE_BOTH
>> +          7 0                      &pic 4 IRQ_TYPE_NONE
>> +
>> +          9 IRQ_TYPE_EDGE_FALLING  &pic 5 IRQ_TYPE_EDGE_FALLING
>> +          9 IRQ_TYPE_EDGE_BOTH     &pic 5 IRQ_TYPE_EDGE_BOTH
>> +          9 0                      &pic 5 IRQ_TYPE_NONE
>> +
>> +          25 IRQ_TYPE_EDGE_FALLING &pic 6 IRQ_TYPE_EDGE_FALLING
>> +          25 IRQ_TYPE_EDGE_BOTH    &pic 6 IRQ_TYPE_EDGE_BOTH
>> +          25 0                     &pic 6 IRQ_TYPE_NONE
>> +
>> +          27 IRQ_TYPE_EDGE_FALLING &pic 7 IRQ_TYPE_EDGE_FALLING
>> +          27 IRQ_TYPE_EDGE_BOTH    &pic 7 IRQ_TYPE_EDGE_BOTH
>> +          27 0                     &pic 7 IRQ_TYPE_NONE
>> +        >;
>> +    };
>> +
>> +    gpio-controller@1430 {
>>          #gpio-cells = <2>;
>
> So two new examples? But old one was wrong?
>
>> +        #address-cells = <0>;
>> +        #interrupt-cells = <2>;
>> +        compatible = "fsl,mpc8323-qe-pario-bank";
>> +        reg = <0x1430 0x18>;
>> +        gpio-controller;
>> +        interrupt-map = <
>> +          24 IRQ_TYPE_EDGE_FALLING &pic 8 IRQ_TYPE_EDGE_FALLING
>> +          24 IRQ_TYPE_EDGE_BOTH    &pic 8 IRQ_TYPE_EDGE_BOTH
>> +          24 0                     &pic 8 IRQ_TYPE_NONE
>> +
>> +          29 IRQ_TYPE_EDGE_FALLING &pic 9 IRQ_TYPE_EDGE_FALLING
>> +          29 IRQ_TYPE_EDGE_BOTH    &pic 9 IRQ_TYPE_EDGE_BOTH
>> +          29 0                     &pic 9 IRQ_TYPE_NONE
>> +        >;
>> +    };
>> +
>> +    gpio-controller@1448 {
>> +        #gpio-cells = <2>;
>> +        compatible = "fsl,mpc8323-qe-pario-bank";
>
> Wait, three examples? But isn't this the same as previous one?

I wanted to outline that each bank do not have the same number of GPIO lines
that support interrupts.

>
>> +        reg = <0x1448 0x18>;
>> +        gpio-controller;
>>      };
>> 
>> -- 
>> 2.55.0
>> 

Thanks,
Paul.




-- 
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox