2023-03-07 20:23:44

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v3 0/8] Hey Jassi, all,

From: Conor Dooley <[email protected]>

Here are some fixes for the system controller on PolarFire SoC that I
ran into while implementing support for using the system controller to
re-program the FPGA. A few are just minor bits that I fixed in passing,
but the bulk of the patchset is changes to how the mailbox figures out
if a "service" has completed.

Prior to implementing this particular functionality, the services
requested from the system controller, via its mailbox interface, always
triggered an interrupt when the system controller was finished with
the service.

Unfortunately some of the services used to validate the FPGA images
before programming them do not trigger an interrupt if they fail.
For example, the service that checks whether an FPGA image is actually
a newer version than what is already programmed, does not trigger an
interrupt, unless the image is actually newer than the one currently
programmed. If it has an earlier version, no interrupt is triggered
and a status is set in the system controller's status register to
signify the reason for the failure.

In order to differentiate between the service succeeding & the system
controller being inoperative or otherwise unable to function, I had to
switch the controller to poll a busy bit in the system controller's
registers to see if it has completed a service.
This makes sense anyway, as the interrupt corresponds to "data ready"
rather than "tx done", so I have changed the mailbox controller driver
to do that & left the interrupt solely for signalling data ready.
It just so happened that all of the services that I had worked with and
tested up to this point were "infallible" & did not set a status, so the
particular code paths were never tested.

Jassi, the mailbox and soc patches depend on each other, as the change
in what the interrupt is used for requires changing the client driver's
behaviour too, as mbox_send_message() will now return when the system
controller is no longer busy rather than when the data is ready.
I'm happy to send the lot via the soc tree with your Ack and/or reivew,
if that also works you?
I've got some other bits that I'd like to change in the client driver,
so via the soc tree would suit me better.

Thanks,
Conor.

Changes in v3:
- check the service status in the .tx_done() callback rather than
mpfs_mbox_rx_data()
- re-order the if/else bits in mpfs_blocking_transaction() to please my
eyes a bit more
- expand on the comment in same

Changes in v2:
- up the timeout to 30 seconds, as required for services like image
validation, which may vary significantly in execution time
- fixed a typo!

CC: Conor Dooley <[email protected]>
CC: Daire McNamara <[email protected]>
CC: Jassi Brar <[email protected]>
CC: [email protected]
CC: [email protected]

Conor Dooley (8):
mailbox: mpfs: fix an incorrect mask width
mailbox: mpfs: switch to txdone_poll
mailbox: mpfs: ditch a useless busy check
mailbox: mpfs: check the service status in .tx_done()
soc: microchip: mpfs: fix some horrible alignment
soc: microchip: mpfs: use a consistent completion timeout
soc: microchip: mpfs: simplify error handling in
mpfs_blocking_transaction()
soc: microchip: mpfs: handle timeouts and failed services differently

drivers/mailbox/mailbox-mpfs.c | 55 ++++++++++++---------
drivers/soc/microchip/mpfs-sys-controller.c | 52 +++++++++++++------
2 files changed, 67 insertions(+), 40 deletions(-)

--
2.39.2



2023-03-07 20:23:50

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v3 1/8] mailbox: mpfs: fix an incorrect mask width

From: Conor Dooley <[email protected]>

The system controller registers on PolarFire SoC are 32 bits wide, so
16 + 16 as the first input to GENMASK_ULL() gives a 33 bit wide mask.
It probably should have been immediately obvious when it was pointed
out during review that the width required using GENMASK_ULL() - but I
scarcely knew what I was doing at the time and missed it.
The mistake ends up being moot as it is a mask after all, but it is
incorrect and should be fixed.

No functional change intended.

Signed-off-by: Conor Dooley <[email protected]>
---
drivers/mailbox/mailbox-mpfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c
index 853901acaeec..d37560e91116 100644
--- a/drivers/mailbox/mailbox-mpfs.c
+++ b/drivers/mailbox/mailbox-mpfs.c
@@ -39,7 +39,7 @@
#define SCB_CTRL_NOTIFY_MASK BIT(SCB_CTRL_NOTIFY)

#define SCB_CTRL_POS (16)
-#define SCB_CTRL_MASK GENMASK_ULL(SCB_CTRL_POS + SCB_MASK_WIDTH, SCB_CTRL_POS)
+#define SCB_CTRL_MASK GENMASK(SCB_CTRL_POS + SCB_MASK_WIDTH - 1, SCB_CTRL_POS)

/* SCBCTRL service status register */

@@ -118,6 +118,7 @@ static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data)
}

opt_sel = ((msg->mbox_offset << 7u) | (msg->cmd_opcode & 0x7fu));
+
tx_trigger = (opt_sel << SCB_CTRL_POS) & SCB_CTRL_MASK;
tx_trigger |= SCB_CTRL_REQ_MASK | SCB_STATUS_NOTIFY_MASK;
writel_relaxed(tx_trigger, mbox->ctrl_base + SERVICES_CR_OFFSET);
--
2.39.2


2023-03-07 20:23:55

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v3 3/8] mailbox: mpfs: ditch a useless busy check

From: Conor Dooley <[email protected]>

mpfs_mbox_rx_data() already checks if the system controller is busy
before attempting to do anything, so drop the second check before
reading any data.

No functional change intended.

Signed-off-by: Conor Dooley <[email protected]>
---
drivers/mailbox/mailbox-mpfs.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c
index e0e825bdbad9..0d176aba3462 100644
--- a/drivers/mailbox/mailbox-mpfs.c
+++ b/drivers/mailbox/mailbox-mpfs.c
@@ -170,12 +170,10 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan)
if (response->resp_status)
return;

- if (!mpfs_mbox_busy(mbox)) {
- for (i = 0; i < num_words; i++) {
- response->resp_msg[i] =
- readl_relaxed(mbox->mbox_base
- + mbox->resp_offset + i * 0x4);
- }
+ for (i = 0; i < num_words; i++) {
+ response->resp_msg[i] =
+ readl_relaxed(mbox->mbox_base
+ + mbox->resp_offset + i * 0x4);
}

mbox_chan_received_data(chan, response);
--
2.39.2


2023-03-07 20:24:01

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v3 2/8] mailbox: mpfs: switch to txdone_poll

From: Conor Dooley <[email protected]>

The system controller on PolarFire SoC has no interrupt to signify that
the TX has been completed. The interrupt instead signals that a service
requested by the mailbox client has succeeded. If a service fails, there
will be no interrupt delivered.

Switch to polling the busy register to determine whether transmission
has completed.

Fixes: 83d7b1560810 ("mbox: add polarfire soc system controller mailbox")
Signed-off-by: Conor Dooley <[email protected]>
---
drivers/mailbox/mailbox-mpfs.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c
index d37560e91116..e0e825bdbad9 100644
--- a/drivers/mailbox/mailbox-mpfs.c
+++ b/drivers/mailbox/mailbox-mpfs.c
@@ -79,6 +79,13 @@ static bool mpfs_mbox_busy(struct mpfs_mbox *mbox)
return status & SCB_STATUS_BUSY_MASK;
}

+static bool mpfs_mbox_last_tx_done(struct mbox_chan *chan)
+{
+ struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv;
+
+ return !mpfs_mbox_busy(mbox);
+}
+
static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data)
{
struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv;
@@ -183,7 +190,6 @@ static irqreturn_t mpfs_mbox_inbox_isr(int irq, void *data)

mpfs_mbox_rx_data(chan);

- mbox_chan_txdone(chan, 0);
return IRQ_HANDLED;
}

@@ -213,6 +219,7 @@ static const struct mbox_chan_ops mpfs_mbox_ops = {
.send_data = mpfs_mbox_send_data,
.startup = mpfs_mbox_startup,
.shutdown = mpfs_mbox_shutdown,
+ .last_tx_done = mpfs_mbox_last_tx_done,
};

static int mpfs_mbox_probe(struct platform_device *pdev)
@@ -248,7 +255,8 @@ static int mpfs_mbox_probe(struct platform_device *pdev)
mbox->controller.num_chans = 1;
mbox->controller.chans = mbox->chans;
mbox->controller.ops = &mpfs_mbox_ops;
- mbox->controller.txdone_irq = true;
+ mbox->controller.txdone_poll = true;
+ mbox->controller.txpoll_period = 10u;

ret = devm_mbox_controller_register(&pdev->dev, &mbox->controller);
if (ret) {
--
2.39.2


2023-03-07 20:24:03

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v3 4/8] mailbox: mpfs: check the service status in .tx_done()

From: Conor Dooley <[email protected]>

Services are supposed to generate an interrupt once completed, whether
or not they have do so successfully. What appears to be a bug in the
system controller means that interrupts are only generated for
*successful* services.

Currently, the status of a service is only checked in the
mpfs_mbox_rx_data() once an interrupt is received. As it turns out, this
is not really helpful where the potentially buggy behaviour is present,
as we'll only see the status for successes where it is moot anyway.

Jassi suggested moving the check to the .tx_done() callback instead.
This makes sense, as the busy bit that tx_done() is polling will be
lowered on completion, regardless of whether the service passed or
failed.
That allows us to check the status bits for all services, whether they
generate an interrupt or not & pass something more informative than
-EBADMSG back to the drivers implementing individual services.

Suggested-by: Jassi Brar <[email protected]>
Signed-off-by: Conor Dooley <[email protected]>
---
drivers/mailbox/mailbox-mpfs.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c
index 0d176aba3462..162df49654fb 100644
--- a/drivers/mailbox/mailbox-mpfs.c
+++ b/drivers/mailbox/mailbox-mpfs.c
@@ -82,8 +82,22 @@ static bool mpfs_mbox_busy(struct mpfs_mbox *mbox)
static bool mpfs_mbox_last_tx_done(struct mbox_chan *chan)
{
struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv;
+ struct mpfs_mss_response *response = mbox->response;
+ u32 val;
+
+ if (mpfs_mbox_busy(mbox))
+ return false;
+
+ /*
+ * The service status is stored in bits 31:16 of the SERVICES_SR
+ * register & is only valid when the system controller is not busy.
+ * Failed services are intended to generated interrupts, but in reality
+ * this does not happen, so the status must be checked here.
+ */
+ val = readl_relaxed(mbox->ctrl_base + SERVICES_SR_OFFSET);
+ response->resp_status = (val & SCB_STATUS_MASK) >> SCB_STATUS_POS;

- return !mpfs_mbox_busy(mbox);
+ return true;
}

static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data)
@@ -138,7 +152,7 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan)
struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv;
struct mpfs_mss_response *response = mbox->response;
u16 num_words = ALIGN((response->resp_size), (4)) / 4U;
- u32 i, status;
+ u32 i;

if (!response->resp_msg) {
dev_err(mbox->dev, "failed to assign memory for response %d\n", -ENOMEM);
@@ -146,8 +160,6 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan)
}

/*
- * The status is stored in bits 31:16 of the SERVICES_SR register.
- * It is only valid when BUSY == 0.
* We should *never* get an interrupt while the controller is
* still in the busy state. If we do, something has gone badly
* wrong & the content of the mailbox would not be valid.
@@ -158,18 +170,6 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan)
return;
}

- status = readl_relaxed(mbox->ctrl_base + SERVICES_SR_OFFSET);
-
- /*
- * If the status of the individual servers is non-zero, the service has
- * failed. The contents of the mailbox at this point are not be valid,
- * so don't bother reading them. Set the status so that the driver
- * implementing the service can handle the result.
- */
- response->resp_status = (status & SCB_STATUS_MASK) >> SCB_STATUS_POS;
- if (response->resp_status)
- return;
-
for (i = 0; i < num_words; i++) {
response->resp_msg[i] =
readl_relaxed(mbox->mbox_base
--
2.39.2


2023-03-07 20:24:07

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v3 5/8] soc: microchip: mpfs: fix some horrible alignment

From: Conor Dooley <[email protected]>

mpfs_sys_controller_delete() has some horrible alignment that upsets my
OCD... Move the RHS of the assignment to a new line for greater
satifaction.

Signed-off-by: Conor Dooley <[email protected]>
---
drivers/soc/microchip/mpfs-sys-controller.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c
index 6e20207b5756..12039cb38b33 100644
--- a/drivers/soc/microchip/mpfs-sys-controller.c
+++ b/drivers/soc/microchip/mpfs-sys-controller.c
@@ -66,8 +66,8 @@ static void rx_callback(struct mbox_client *client, void *msg)

static void mpfs_sys_controller_delete(struct kref *kref)
{
- struct mpfs_sys_controller *sys_controller = container_of(kref, struct mpfs_sys_controller,
- consumers);
+ struct mpfs_sys_controller *sys_controller =
+ container_of(kref, struct mpfs_sys_controller, consumers);

mbox_free_channel(sys_controller->chan);
kfree(sys_controller);
--
2.39.2


2023-03-07 20:24:10

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v3 7/8] soc: microchip: mpfs: simplify error handling in mpfs_blocking_transaction()

From: Conor Dooley <[email protected]>

The error handling has a kinda weird nested-if setup that is not really
adding anything. Switch it to more of an early return arrangement as a
predatory step for adding different handing for timeouts and failed
services.

Signed-off-by: Conor Dooley <[email protected]>
---
drivers/soc/microchip/mpfs-sys-controller.c | 27 ++++++++++-----------
1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c
index 738ecd624d64..e61ba9b7aae3 100644
--- a/drivers/soc/microchip/mpfs-sys-controller.c
+++ b/drivers/soc/microchip/mpfs-sys-controller.c
@@ -32,28 +32,27 @@ struct mpfs_sys_controller {
int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mpfs_mss_msg *msg)
{
unsigned long timeout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS);
- int ret, err;
+ int ret;

- err = mutex_lock_interruptible(&transaction_lock);
- if (err)
- return err;
+ ret = mutex_lock_interruptible(&transaction_lock);
+ if (ret)
+ return ret;

reinit_completion(&sys_controller->c);

ret = mbox_send_message(sys_controller->chan, msg);
- if (ret >= 0) {
- if (wait_for_completion_timeout(&sys_controller->c, timeout)) {
- ret = 0;
- } else {
- ret = -ETIMEDOUT;
- dev_warn(sys_controller->client.dev,
- "MPFS sys controller transaction timeout\n");
- }
+ if (ret < 0)
+ goto out;
+
+ if (!wait_for_completion_timeout(&sys_controller->c, timeout)) {
+ ret = -ETIMEDOUT;
+ dev_warn(sys_controller->client.dev, "MPFS sys controller transaction timeout\n");
} else {
- dev_err(sys_controller->client.dev,
- "mpfs sys controller transaction returned %d\n", ret);
+ /* mbox_send_message() returns positive integers on success */
+ ret = 0;
}

+out:
mutex_unlock(&transaction_lock);

return ret;
--
2.39.2


2023-03-07 20:24:14

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v3 6/8] soc: microchip: mpfs: use a consistent completion timeout

From: Conor Dooley <[email protected]>

Completion timeouts use jiffies, so passing a number directly will
produce inconsistent timeouts depending on config. Define the timeout in
ms and convert it to jiffies instead.

Signed-off-by: Conor Dooley <[email protected]>
---
drivers/soc/microchip/mpfs-sys-controller.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c
index 12039cb38b33..738ecd624d64 100644
--- a/drivers/soc/microchip/mpfs-sys-controller.c
+++ b/drivers/soc/microchip/mpfs-sys-controller.c
@@ -11,12 +11,15 @@
#include <linux/slab.h>
#include <linux/kref.h>
#include <linux/module.h>
+#include <linux/jiffies.h>
#include <linux/interrupt.h>
#include <linux/of_platform.h>
#include <linux/mailbox_client.h>
#include <linux/platform_device.h>
#include <soc/microchip/mpfs.h>

+#define MPFS_SYS_CTRL_TIMEOUT_MS 100
+
static DEFINE_MUTEX(transaction_lock);

struct mpfs_sys_controller {
@@ -28,6 +31,7 @@ struct mpfs_sys_controller {

int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mpfs_mss_msg *msg)
{
+ unsigned long timeout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS);
int ret, err;

err = mutex_lock_interruptible(&transaction_lock);
@@ -38,7 +42,7 @@ int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct

ret = mbox_send_message(sys_controller->chan, msg);
if (ret >= 0) {
- if (wait_for_completion_timeout(&sys_controller->c, HZ)) {
+ if (wait_for_completion_timeout(&sys_controller->c, timeout)) {
ret = 0;
} else {
ret = -ETIMEDOUT;
--
2.39.2


2023-03-07 20:24:18

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v3 8/8] soc: microchip: mpfs: handle timeouts and failed services differently

From: Conor Dooley <[email protected]>

The system controller will only deliver an interrupt if a service
succeeds. This leaves us in the unfortunate position with current code
where there is no way to differentiate between a legitimate timeout
where the service has not completed & where it has completed, but
failed.

mbox_send_message() has its own completion, and it will time out of the
system controller does not lower the busy flag. In this case, a timeout
has occurred and the error can be propagated back to the caller.

If the busy flag is lowered, but no interrupt has arrived to trigger the
rx callback, the service can be deemed to have failed. Report -EBADMSG
in this case so that callers can differentiate.

Signed-off-by: Conor Dooley <[email protected]>
---
drivers/soc/microchip/mpfs-sys-controller.c | 27 +++++++++++++++++----
1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c
index e61ba9b7aae3..ceaeebc1fc6b 100644
--- a/drivers/soc/microchip/mpfs-sys-controller.c
+++ b/drivers/soc/microchip/mpfs-sys-controller.c
@@ -18,7 +18,11 @@
#include <linux/platform_device.h>
#include <soc/microchip/mpfs.h>

-#define MPFS_SYS_CTRL_TIMEOUT_MS 100
+/*
+ * This timeout must be long, as some services (example: image authentication)
+ * take significant time to complete
+ */
+#define MPFS_SYS_CTRL_TIMEOUT_MS 30000

static DEFINE_MUTEX(transaction_lock);

@@ -41,14 +45,26 @@ int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct
reinit_completion(&sys_controller->c);

ret = mbox_send_message(sys_controller->chan, msg);
- if (ret < 0)
+ if (ret < 0) {
+ dev_warn(sys_controller->client.dev, "MPFS sys controller service timeout\n");
goto out;
+ }

+ /*
+ * Unfortunately, the system controller will only deliver an interrupt
+ * if a service succeeds. mbox_send_message() will block until the busy
+ * flag is gone. If the busy flag is gone but no interrupt has arrived
+ * to trigger the rx callback then the service can be deemed to have
+ * failed.
+ * The caller can then interrogate msg::response::resp_status to
+ * determine the cause of the failure.
+ * mbox_send_message() returns positive integers in the success path, so
+ * ret needs to be cleared if we do get an interrupt.
+ */
if (!wait_for_completion_timeout(&sys_controller->c, timeout)) {
- ret = -ETIMEDOUT;
- dev_warn(sys_controller->client.dev, "MPFS sys controller transaction timeout\n");
+ ret = -EBADMSG;
+ dev_warn(sys_controller->client.dev, "MPFS sys controller service failed\n");
} else {
- /* mbox_send_message() returns positive integers on success */
ret = 0;
}

@@ -107,6 +123,7 @@ static int mpfs_sys_controller_probe(struct platform_device *pdev)
sys_controller->client.dev = dev;
sys_controller->client.rx_callback = rx_callback;
sys_controller->client.tx_block = 1U;
+ sys_controller->client.tx_tout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS);

sys_controller->chan = mbox_request_channel(&sys_controller->client, 0);
if (IS_ERR(sys_controller->chan)) {
--
2.39.2


2023-03-07 20:30:42

by Conor Dooley

[permalink] [raw]
Subject: mailbox,soc: mpfs: add support for fallible services (was [PATCH v3 0/8] Hey Jassi, all,)

On Tue, Mar 07, 2023 at 08:22:50PM +0000, Conor Dooley wrote:
> From: Conor Dooley <[email protected]>

I botched $subject, I blame copy pasting the branch-description from
lore and not double checking the output of --cover-from-description=auto

This should be a more suitable one... /sigh

>
> Here are some fixes for the system controller on PolarFire SoC that I
> ran into while implementing support for using the system controller to
> re-program the FPGA. A few are just minor bits that I fixed in passing,
> but the bulk of the patchset is changes to how the mailbox figures out
> if a "service" has completed.
>
> Prior to implementing this particular functionality, the services
> requested from the system controller, via its mailbox interface, always
> triggered an interrupt when the system controller was finished with
> the service.
>
> Unfortunately some of the services used to validate the FPGA images
> before programming them do not trigger an interrupt if they fail.
> For example, the service that checks whether an FPGA image is actually
> a newer version than what is already programmed, does not trigger an
> interrupt, unless the image is actually newer than the one currently
> programmed. If it has an earlier version, no interrupt is triggered
> and a status is set in the system controller's status register to
> signify the reason for the failure.
>
> In order to differentiate between the service succeeding & the system
> controller being inoperative or otherwise unable to function, I had to
> switch the controller to poll a busy bit in the system controller's
> registers to see if it has completed a service.
> This makes sense anyway, as the interrupt corresponds to "data ready"
> rather than "tx done", so I have changed the mailbox controller driver
> to do that & left the interrupt solely for signalling data ready.
> It just so happened that all of the services that I had worked with and
> tested up to this point were "infallible" & did not set a status, so the
> particular code paths were never tested.
>
> Jassi, the mailbox and soc patches depend on each other, as the change
> in what the interrupt is used for requires changing the client driver's
> behaviour too, as mbox_send_message() will now return when the system
> controller is no longer busy rather than when the data is ready.
> I'm happy to send the lot via the soc tree with your Ack and/or reivew,
> if that also works you?
> I've got some other bits that I'd like to change in the client driver,
> so via the soc tree would suit me better.
>
> Thanks,
> Conor.
>
> Changes in v3:
> - check the service status in the .tx_done() callback rather than
> mpfs_mbox_rx_data()
> - re-order the if/else bits in mpfs_blocking_transaction() to please my
> eyes a bit more
> - expand on the comment in same
>
> Changes in v2:
> - up the timeout to 30 seconds, as required for services like image
> validation, which may vary significantly in execution time
> - fixed a typo!
>
> CC: Conor Dooley <[email protected]>
> CC: Daire McNamara <[email protected]>
> CC: Jassi Brar <[email protected]>
> CC: [email protected]
> CC: [email protected]
>
> Conor Dooley (8):
> mailbox: mpfs: fix an incorrect mask width
> mailbox: mpfs: switch to txdone_poll
> mailbox: mpfs: ditch a useless busy check
> mailbox: mpfs: check the service status in .tx_done()
> soc: microchip: mpfs: fix some horrible alignment
> soc: microchip: mpfs: use a consistent completion timeout
> soc: microchip: mpfs: simplify error handling in
> mpfs_blocking_transaction()
> soc: microchip: mpfs: handle timeouts and failed services differently
>
> drivers/mailbox/mailbox-mpfs.c | 55 ++++++++++++---------
> drivers/soc/microchip/mpfs-sys-controller.c | 52 +++++++++++++------
> 2 files changed, 67 insertions(+), 40 deletions(-)
>
> --
> 2.39.2
>


Attachments:
(No filename) (3.85 kB)
signature.asc (228.00 B)
Download all attachments

2023-03-29 16:22:51

by Conor Dooley

[permalink] [raw]
Subject: Re: mailbox,soc: mpfs: add support for fallible services (was [PATCH v3 0/8] Hey Jassi, all,)

Hey Jassi,

On Tue, Mar 07, 2023 at 08:30:31PM +0000, Conor Dooley wrote:
> On Tue, Mar 07, 2023 at 08:22:50PM +0000, Conor Dooley wrote:
> > From: Conor Dooley <[email protected]>
>
> I botched $subject, I blame copy pasting the branch-description from
> lore and not double checking the output of --cover-from-description=auto
>
> This should be a more suitable one... /sigh

Replying to the one with a reasonable $subject... Are you okay with this
revised version of the series (you were happy with most of the v2 IIRC),
and if you are, would you be okay with me taking the lot via the soc
tree as I have some other bits that depend on the changes here?

Thanks,
Conor.

> > Here are some fixes for the system controller on PolarFire SoC that I
> > ran into while implementing support for using the system controller to
> > re-program the FPGA. A few are just minor bits that I fixed in passing,
> > but the bulk of the patchset is changes to how the mailbox figures out
> > if a "service" has completed.
> >
> > Prior to implementing this particular functionality, the services
> > requested from the system controller, via its mailbox interface, always
> > triggered an interrupt when the system controller was finished with
> > the service.
> >
> > Unfortunately some of the services used to validate the FPGA images
> > before programming them do not trigger an interrupt if they fail.
> > For example, the service that checks whether an FPGA image is actually
> > a newer version than what is already programmed, does not trigger an
> > interrupt, unless the image is actually newer than the one currently
> > programmed. If it has an earlier version, no interrupt is triggered
> > and a status is set in the system controller's status register to
> > signify the reason for the failure.
> >
> > In order to differentiate between the service succeeding & the system
> > controller being inoperative or otherwise unable to function, I had to
> > switch the controller to poll a busy bit in the system controller's
> > registers to see if it has completed a service.
> > This makes sense anyway, as the interrupt corresponds to "data ready"
> > rather than "tx done", so I have changed the mailbox controller driver
> > to do that & left the interrupt solely for signalling data ready.
> > It just so happened that all of the services that I had worked with and
> > tested up to this point were "infallible" & did not set a status, so the
> > particular code paths were never tested.
> >
> > Jassi, the mailbox and soc patches depend on each other, as the change
> > in what the interrupt is used for requires changing the client driver's
> > behaviour too, as mbox_send_message() will now return when the system
> > controller is no longer busy rather than when the data is ready.
> > I'm happy to send the lot via the soc tree with your Ack and/or reivew,
> > if that also works you?
> > I've got some other bits that I'd like to change in the client driver,
> > so via the soc tree would suit me better.
> >
> > Thanks,
> > Conor.
> >
> > Changes in v3:
> > - check the service status in the .tx_done() callback rather than
> > mpfs_mbox_rx_data()
> > - re-order the if/else bits in mpfs_blocking_transaction() to please my
> > eyes a bit more
> > - expand on the comment in same
> >
> > Changes in v2:
> > - up the timeout to 30 seconds, as required for services like image
> > validation, which may vary significantly in execution time
> > - fixed a typo!
> >
> > CC: Conor Dooley <[email protected]>
> > CC: Daire McNamara <[email protected]>
> > CC: Jassi Brar <[email protected]>
> > CC: [email protected]
> > CC: [email protected]
> >
> > Conor Dooley (8):
> > mailbox: mpfs: fix an incorrect mask width
> > mailbox: mpfs: switch to txdone_poll
> > mailbox: mpfs: ditch a useless busy check
> > mailbox: mpfs: check the service status in .tx_done()
> > soc: microchip: mpfs: fix some horrible alignment
> > soc: microchip: mpfs: use a consistent completion timeout
> > soc: microchip: mpfs: simplify error handling in
> > mpfs_blocking_transaction()
> > soc: microchip: mpfs: handle timeouts and failed services differently
> >
> > drivers/mailbox/mailbox-mpfs.c | 55 ++++++++++++---------
> > drivers/soc/microchip/mpfs-sys-controller.c | 52 +++++++++++++------
> > 2 files changed, 67 insertions(+), 40 deletions(-)
> >
> > --
> > 2.39.2
> >



Attachments:
(No filename) (4.47 kB)
signature.asc (235.00 B)
Download all attachments

2023-03-31 15:10:37

by Jassi Brar

[permalink] [raw]
Subject: Re: mailbox,soc: mpfs: add support for fallible services (was [PATCH v3 0/8] Hey Jassi, all,)

On Wed, Mar 29, 2023 at 11:15 AM Conor Dooley <[email protected]> wrote:
>
> Hey Jassi,
>
> On Tue, Mar 07, 2023 at 08:30:31PM +0000, Conor Dooley wrote:
> > On Tue, Mar 07, 2023 at 08:22:50PM +0000, Conor Dooley wrote:
> > > From: Conor Dooley <[email protected]>
> >
> > I botched $subject, I blame copy pasting the branch-description from
> > lore and not double checking the output of --cover-from-description=auto
> >
> > This should be a more suitable one... /sigh
>
> Replying to the one with a reasonable $subject... Are you okay with this
> revised version of the series (you were happy with most of the v2 IIRC),
> and if you are, would you be okay with me taking the lot via the soc
> tree as I have some other bits that depend on the changes here?
>
I am okay. Acked-by: Jassi Brar <[email protected]>

cheers.

2023-03-31 18:20:51

by Conor Dooley

[permalink] [raw]
Subject: Re: mailbox,soc: mpfs: add support for fallible services (was [PATCH v3 0/8] Hey Jassi, all,)

On Fri, Mar 31, 2023 at 10:03:08AM -0500, Jassi Brar wrote:

> I am okay. Acked-by: Jassi Brar <[email protected]>

Great, thanks Jassi!


Attachments:
(No filename) (151.00 B)
signature.asc (235.00 B)
Download all attachments
Subject: Re: [PATCH v3 0/8] Hey Jassi, all,

On 07/03/2023 20:22, Conor Dooley wrote:
> From: Conor Dooley <[email protected]>
>
> Here are some fixes for the system controller on PolarFire SoC that I
> ran into while implementing support for using the system controller to
> re-program the FPGA. A few are just minor bits that I fixed in passing,
> but the bulk of the patchset is changes to how the mailbox figures out
> if a "service" has completed.
>
> Prior to implementing this particular functionality, the services
> requested from the system controller, via its mailbox interface, always
> triggered an interrupt when the system controller was finished with
> the service.
>
> Unfortunately some of the services used to validate the FPGA images
> before programming them do not trigger an interrupt if they fail.
> For example, the service that checks whether an FPGA image is actually
> a newer version than what is already programmed, does not trigger an
> interrupt, unless the image is actually newer than the one currently
> programmed. If it has an earlier version, no interrupt is triggered
> and a status is set in the system controller's status register to
> signify the reason for the failure.
>
> In order to differentiate between the service succeeding & the system
> controller being inoperative or otherwise unable to function, I had to
> switch the controller to poll a busy bit in the system controller's
> registers to see if it has completed a service.
> This makes sense anyway, as the interrupt corresponds to "data ready"
> rather than "tx done", so I have changed the mailbox controller driver
> to do that & left the interrupt solely for signalling data ready.
> It just so happened that all of the services that I had worked with and
> tested up to this point were "infallible" & did not set a status, so the
> particular code paths were never tested.
>
> Jassi, the mailbox and soc patches depend on each other, as the change
> in what the interrupt is used for requires changing the client driver's
> behaviour too, as mbox_send_message() will now return when the system
> controller is no longer busy rather than when the data is ready.
> I'm happy to send the lot via the soc tree with your Ack and/or reivew,
> if that also works you?
> I've got some other bits that I'd like to change in the client driver,
> so via the soc tree would suit me better.
>
> Thanks,
> Conor.
Hi Conor,

I tested this on the Icicle Kit board, looks good to me. So:
Tested-by: Valentina Fernandez <[email protected]>
>
> Changes in v3:
> - check the service status in the .tx_done() callback rather than
> mpfs_mbox_rx_data()
> - re-order the if/else bits in mpfs_blocking_transaction() to please my
> eyes a bit more
> - expand on the comment in same
>
> Changes in v2:
> - up the timeout to 30 seconds, as required for services like image
> validation, which may vary significantly in execution time
> - fixed a typo!
>
> CC: Conor Dooley <[email protected]>
> CC: Daire McNamara <[email protected]>
> CC: Jassi Brar <[email protected]>
> CC: [email protected]
> CC: [email protected]
>
> Conor Dooley (8):
> mailbox: mpfs: fix an incorrect mask width
> mailbox: mpfs: switch to txdone_poll
> mailbox: mpfs: ditch a useless busy check
> mailbox: mpfs: check the service status in .tx_done()
> soc: microchip: mpfs: fix some horrible alignment
> soc: microchip: mpfs: use a consistent completion timeout
> soc: microchip: mpfs: simplify error handling in
> mpfs_blocking_transaction()
> soc: microchip: mpfs: handle timeouts and failed services differently
>
> drivers/mailbox/mailbox-mpfs.c | 55 ++++++++++++---------
> drivers/soc/microchip/mpfs-sys-controller.c | 52 +++++++++++++------
> 2 files changed, 67 insertions(+), 40 deletions(-)
>

2023-04-03 18:31:02

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v3 0/8] Hey Jassi, all,

From: Conor Dooley <[email protected]>

On Tue, 07 Mar 2023 20:22:50 +0000, Conor Dooley wrote:
> From: Conor Dooley <[email protected]>
>
> Here are some fixes for the system controller on PolarFire SoC that I
> ran into while implementing support for using the system controller to
> re-program the FPGA. A few are just minor bits that I fixed in passing,
> but the bulk of the patchset is changes to how the mailbox figures out
> if a "service" has completed.
>
> [...]

Applied to riscv-soc-for-next, thanks!

[1/8] mailbox: mpfs: fix an incorrect mask width
https://git.kernel.org/conor/c/75dfbcbfd781
[2/8] mailbox: mpfs: switch to txdone_poll
https://git.kernel.org/conor/c/b5984a9844fc
[3/8] mailbox: mpfs: ditch a useless busy check
https://git.kernel.org/conor/c/da82f95f7c07
[4/8] mailbox: mpfs: check the service status in .tx_done()
https://git.kernel.org/conor/c/37e3430176ff
[5/8] soc: microchip: mpfs: fix some horrible alignment
https://git.kernel.org/conor/c/5ca631ec757b
[6/8] soc: microchip: mpfs: use a consistent completion timeout
https://git.kernel.org/conor/c/4f739af1934a
[7/8] soc: microchip: mpfs: simplify error handling in mpfs_blocking_transaction()
https://git.kernel.org/conor/c/7606f4dfffa7
[8/8] soc: microchip: mpfs: handle timeouts and failed services differently
https://git.kernel.org/conor/c/8f943dd12eef

Thanks,
Conor.