mailbox: mpfs-mbox: fixes and syscon support
cover mailbox: mpfs-mbox: fixes and syscon support
Hi all,
This series updates the Microchip PolarFire SoC (MPFS) mailbox driver in U-Boot.
The first three patches contain a set of bug fixes and cleanups to the existing driver, fixing MMIO size calculations, and removing invalid mailbox channel and private-data handling. These changes are independent of any devicetree updates and fix issues present in the legacy driver.
The final patch adds support for the corrected, syscon-based devicetree bindings for the MPFS mailbox. Linux has moved to this binding to more accurately model the hardware, and U-Boot already supports the same approach for the MPFS clock controller. This patch updates the mailbox driver accordingly, while retaining support for the legacy binding for backwards compatibility.
The final patch is required ASAP as boot is currently broken on master for MPFS generic boards.
Tested on a PolarFire SoC Icicle Kit ES.
Thanks,
Jamie
Jamie Gibbons (4):
mailbox: mpfs-mbox: fix MMIO mapping calculation
mailbox: mpfs-mbox: fix Driver Model private data handling
mailbox: mpfs-mbox: fix driver bug and cleanup
mailbox: mpfs-mbox: support new syscon based devicetree configuration
drivers/mailbox/Kconfig | 2 + drivers/mailbox/mpfs-mbox.c | 106 ++++++++++++++++++++++++------------ 2 files changed, 74 insertions(+), 34 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/4 mailbox: mpfs-mbox: fix MMIO mapping calculation
Correct the MMIO mapping size calculation, which previously relied on an invalid start/end subtraction.
This change corrects a functional bug and cleans up the driver without altering its behavior.
--- drivers/mailbox/mpfs-mbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mailbox/mpfs-mbox.c +2 -2
@@ -145,7 +145,7 @@ static int mpfs_mbox_probe(struct udevice *dev)return ret; }; - mbox->ctrl_base =devm_ioremap (dev, regs.start, regs.start - regs.end); + mbox->ctrl_base =devm_ioremap (dev, res.start,resource_size (&res)); ret =ofnode_read_resource (node,2 , ®s);if (ret) {
@@ -153,7 +153,7 @@ static int mpfs_mbox_probe(struct udevice *dev)return ret; }; - mbox->mbox_base =devm_ioremap (dev, regs.start, regs.start - regs.end); + mbox->mbox_base =devm_ioremap (dev, res.start,resource_size (&res)); mbox->dev = dev;dev_set_priv (dev, mbox);
Signature · 1 line
2.43.0
PATCH 2/4 mailbox: mpfs-mbox: fix Driver Model private data handling
In reply to Jamie GibbonsThe MPFS mailbox driver declares priv_auto but also allocates a second private data structure in the legacy probe path and overwrites the device’s private pointer using dev_set_priv().
This results in leaking the auto-allocated private data and replacing the driver’s private state mid-probe, which is incorrect usage of the U-Boot Driver Model and can lead to undefined behavior.
Remove the redundant allocation and dev_set_priv() call so that the driver consistently uses the auto-allocated private data provided by U-Boot.
--- drivers/mailbox/mpfs-mbox.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/mailbox/mpfs-mbox.c +0 -5
@@ -135,10 +135,6 @@ static int mpfs_mbox_probe(struct udevice *dev) node =dev_ofnode (dev); - mbox =devm_kzalloc (dev,sizeof (*mbox),GFP_KERNEL ); -if (!mbox) -return -ENOMEM ; - ret =ofnode_read_resource (node,0 , ®s);if (ret) {dev_err (dev,"No reg property for controller base\n" );
@@ -156,7 +152,6 @@ static int mpfs_mbox_probe(struct udevice *dev) mbox->mbox_base =devm_ioremap (dev, res.start,resource_size (&res)); mbox->dev = dev; -dev_set_priv (dev, mbox); mbox->chan->con_priv = mbox;return 0 ;
Signature · 1 line
2.43.0
PATCH 3/4 mailbox: mpfs-mbox: fix driver bug and cleanup
In reply to Jamie GibbonsRemove an unused and invalid struct mbox_chan pointer from the private data and fix incorrect memory handling in the probe path, where the private data structure was allocated.
This change corrects a functional bugs and cleans up the driver without altering its behavior.
--- drivers/mailbox/mpfs-mbox.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mailbox/mpfs-mbox.c +1 -3
@@ -37,13 +37,12 @@ struct mpfs_mbox {struct udevice *dev;void __iomem *ctrl_base;void __iomem *mbox_base; -struct mbox_chan *chan; };static bool mpfs_mbox_busy (struct mbox_chan *chan) {struct mpfs_mbox *mbox =dev_get_priv (chan->dev); -uint16_t status; +u32 status; status =readl (mbox->ctrl_base +SERVICES_SR_OFFSET );
@@ -152,7 +151,6 @@ static int mpfs_mbox_probe(struct udevice *dev) mbox->mbox_base =devm_ioremap (dev, res.start,resource_size (&res)); mbox->dev = dev; - mbox->chan->con_priv = mbox;return 0 ; }
Signature · 1 line
2.43.0
PATCH 4/4 mailbox: mpfs-mbox: support new syscon based devicetree configuration
In reply to Jamie GibbonsThe original PolarFire SoC mailbox devicetree bindings described the control/status and interrupt registers as standalone reg regions of the mailbox device. This was incorrect, as these registers are shared system control blocks and should instead be modeled as syscon devices.
Linux has since corrected this by introducing syscon-based bindings for the MPFS mailbox and updating the mailbox driver to access the control and interrupt registers via syscon/regmap. U-Boot, however, continued to expect the legacy binding, causing mailbox access to fail when using Linux-aligned devicetrees.
Update the U-Boot MPFS mailbox driver to support the new syscon-based bindings by resolving the control and sysreg syscon nodes and accessing the registers through regmap. Support for the legacy mailbox binding is retained for backwards compatibility with existing firmware-provided devicetrees.
This brings the U-Boot mailbox driver in line with the corrected hardware description and matches the behavior of the Linux mailbox driver.
---
Hi Tom,
Should this have the following fix tag?
Thanks,
Jamie.
--- drivers/mailbox/Kconfig | 2 + drivers/mailbox/mpfs-mbox.c | 99 +++++++++++++++++++++++++++---------- 2 files changed, 74 insertions(+), 27 deletions(-)
drivers/mailbox/Kconfig +2 -0
@@ -32,6 +32,8 @@ config MPFS_MBOX bool "Enable MPFS system controller support" depends on DM_MAILBOX && ARCH_RV64I select DEVRES + depends on SYSCON + depends on REGMAP help Enable support for the mailboxes that provide a communication channel with the system controller integrated on PolarFire SoC.
drivers/mailbox/mpfs-mbox.c +72 -27
167 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 22 lines · Jamie Gibbons
Hi all,
This series updates the Microchip PolarFire SoC (MPFS) mailbox driver in U-Boot.
The first three patches contain a set of bug fixes and cleanups to the existing driver, fixing MMIO size calculations, and removing invalid mailbox channel and private-data handling. These changes are independent of any devicetree updates and fix issues present in the legacy driver.
The final patch adds support for the corrected, syscon-based devicetree bindings for the MPFS mailbox. Linux has moved to this binding to more accurately model the hardware, and U-Boot already supports the same approach for the MPFS clock controller. This patch updates the mailbox driver accordingly, while retaining support for the legacy binding for backwards compatibility.
The final patch is required ASAP as boot is currently broken on master for MPFS generic boards.
Tested on a PolarFire SoC Icicle Kit ES.
Quoted 8 lines
Thanks,
JamieJamie Gibbons (4):
mailbox: mpfs-mbox: fix MMIO mapping calculation
mailbox: mpfs-mbox: fix Driver Model private data handling
mailbox: mpfs-mbox: fix driver bug and cleanup
mailbox: mpfs-mbox: support new syscon based devicetree configuration
Cheers,
Conor.
Tom,
Quoted 26 lines · Conor Dooley
Quoted 25 lines · Jamie Gibbons
Hi all,
This series updates the Microchip PolarFire SoC (MPFS) mailbox driver in U-Boot.
The first three patches contain a set of bug fixes and cleanups to the existing driver, fixing MMIO size calculations, and removing invalid mailbox channel and private-data handling. These changes are independent of any devicetree updates and fix issues present in the legacy driver.
The final patch adds support for the corrected, syscon-based devicetree bindings for the MPFS mailbox. Linux has moved to this binding to more accurately model the hardware, and U-Boot already supports the same approach for the MPFS clock controller. This patch updates the mailbox driver accordingly, while retaining support for the legacy binding for backwards compatibility.
The final patch is required ASAP as boot is currently broken on master for MPFS generic boards.
Tested on a PolarFire SoC Icicle Kit ES.
Thanks,
Jamie
Quoted 7 lines
Quoted 5 lines
Jamie Gibbons (4):
mailbox: mpfs-mbox: fix MMIO mapping calculation
mailbox: mpfs-mbox: fix Driver Model private data handling
mailbox: mpfs-mbox: fix driver bug and cleanup
mailbox: mpfs-mbox: support new syscon based devicetree configurationReviewed-by Conor Dooley <[email protected]>
Would you be able to grab this please? Your current mainline branch is failing to boot because the last dt-rebasing version jump brought in a changed dts from linux that requires the syscon-based devicetree setup.
Thanks,
Conor.
Quoted 9 lines · Jamie Gibbons
This series updates the Microchip PolarFire SoC (MPFS) mailbox driver in U-Boot.
The first three patches contain a set of bug fixes and cleanups to the existing driver, fixing MMIO size calculations, and removing invalid mailbox channel and private-data handling. These changes are independent of any devicetree updates and fix issues present in the legacy driver.
[...]
Applied to u-boot/master, thanks!
[1/4] mailbox: mpfs-mbox: fix MMIO mapping calculation
commit: a05adbb9b30115ef7d04668d35650f311458dd2d
[2/4] mailbox: mpfs-mbox: fix Driver Model private data handling
commit: 1173e02c9880d9f7d1bf15308490493332b03a61
[3/4] mailbox: mpfs-mbox: fix driver bug and cleanup
commit: 763435d0e3124539dc36c730c3832a1b4162d3f7
[4/4] mailbox: mpfs-mbox: support new syscon based devicetree configuration
commit: 6c128738240d7e3a6020676501ad382af3359f3eSignature · 1 line
Tom