Re: [PATCH v2 2/6] remoteproc: amd_mbv_bram: Restore reset GPIO direction after PL reconfig
From: Ben Levinsky
Date: Thu Nov 19 2026 - 13:14:02 EST
On 11/19/26 8:44 AM, Mathieu Poirier wrote:
> On Wed, Nov 04, 2026 at 09:18:58PM -0800, Ben Levinsky wrote:
>> Partial reconfiguration of the programmable logic restores the AXI GPIO
>> that drives the soft-core reset to its hardware default direction, but
>> gpiolib keeps its cached output direction. gpiod_set_value_cansleep()
>> then only updates the data register, so the processor never sees a
>> reset transition: remoteproc reports it as running while the newly
>> loaded firmware never starts.
>>
>
> Where does the "partial reconfiguration of the programmable logic" happens?
> What makes it partial? Shouldn't that be fixed instead?
Hi Mathieu,
"Partial" was the wrong word. The PL is loaded through the FPGA manager
when the device tree overlay for the design is applied, and the same
overlay adds the AXI GPIO, mailbox and remoteproc nodes.
In that flow the AXI GPIO driver probes after the PL has been loaded and
programs the line direction from the device tree, so gpiolib and the
hardware agree. The problem I described only happens if the PL is
reloaded while the overlay is still applied, behind the back of every
driver for the IP in the PL. You're right, that is what needs fixing,
not this driver.
I checked this on hardware without this patch: with the PL loaded
before the devices are created, start and stop work as expected over
repeated cycles.
>
>> Use gpiod_direction_output() for every reset transition so the output
>> direction is re-established, and assert reset briefly before releasing
>> it so each start produces a clean reset pulse after the firmware has
>> been loaded.
>>
>> Fixes: f87b4998994e ("remoteproc: Add AMD MicroBlaze/V BRAM-based remote processor driver")
>> Assisted-by: Claude:claude-opus-5.5
>> Signed-off-by: Ben Levinsky <ben.levinsky@xxxxxxx>
>> ---
>> drivers/remoteproc/amd_mbv_bram_rproc.c | 23 ++++++++++++++++++++---
>> 1 file changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/remoteproc/amd_mbv_bram_rproc.c b/drivers/remoteproc/amd_mbv_bram_rproc.c
>> index 6cf33c7b7e64..da621f62f7df 100644
>> --- a/drivers/remoteproc/amd_mbv_bram_rproc.c
>> +++ b/drivers/remoteproc/amd_mbv_bram_rproc.c
>> @@ -16,6 +16,7 @@
>> */
>>
>> #include <linux/clk.h>
>> +#include <linux/delay.h>
>> #include <linux/dma-mapping.h>
>> #include <linux/gpio/consumer.h>
>> #include <linux/module.h>
>> @@ -94,8 +95,24 @@ static int amd_bram_rproc_start(struct rproc *rproc)
>> return ret;
>> }
>>
>> + /*
>> + * Partial reconfiguration restores the PL GPIO hardware defaults but
>> + * leaves gpiolib's cached direction unchanged. Re-establish the output
>> + * direction and generate a reset pulse after firmware has been loaded.
>> + * gpiod_set_value_cansleep() is insufficient here because it changes the
>> + * value without restoring an output direction lost during DFX.
>> + */
>> + ret = gpiod_direction_output(priv->reset, 1);
>> + if (ret) {
>> + dev_err(priv->dev, "failed to assert reset: %d\n", ret);
>> + clk_disable_unprepare(priv->clk);
>> + return ret;
>> + }
>
> Why is this needed now rather than when this driver was introduced?
It isn't needed, for the reason above.
>
>> + /* Hold reset asserted long enough to provide a clean reset pulse. */
>> + usleep_range(10, 20);
>> +
>
> I really don't like random wait times, please find another way like polling the
> GPIO line for an expected value. I also thougth the GPIO subsystem was already
> dealing with de-bouncing. And the question from above still stands, i.e what
> changed to required sleeping that wasn't there when this driver was first
> submitted?
Nothing changed. Reset is asserted when the GPIO is requested at probe
time and again in stop(), so start() doesn't need to generate a pulse
of its own.
I'll drop this patch in v3.
Thanks,
Ben
>
>> /* Deassert reset and let the processor run. */
>> - ret = gpiod_set_value_cansleep(priv->reset, 0);
>> + ret = gpiod_direction_output(priv->reset, 0);
>> if (ret) {
>> dev_err(priv->dev, "failed to deassert reset: %d\n", ret);
>> clk_disable_unprepare(priv->clk);
>> @@ -110,8 +127,8 @@ static int amd_bram_rproc_stop(struct rproc *rproc)
>> struct amd_bram_rproc *priv = rproc->priv;
>> int ret;
>>
>> - /* Assert reset before disabling the processor clock. */
>> - ret = gpiod_set_value_cansleep(priv->reset, 1);
>> + /* Restore the output direction after DFX and assert reset. */
>> + ret = gpiod_direction_output(priv->reset, 1);
>> if (ret) {
>> dev_err(priv->dev, "failed to assert reset: %d\n", ret);
>> return ret;
>> --
>> 2.34.1
>>
>