mbox series

[v3,0/8] Hey Jassi, all,

Message ID 20230307202257.1762151-1-conor@kernel.org (mailing list archive)
Headers show
Series Hey Jassi, all, | expand

Message

Conor Dooley March 7, 2023, 8:22 p.m. UTC
From: Conor Dooley <conor.dooley@microchip.com>

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 <conor.dooley@microchip.com>
CC: Daire McNamara <daire.mcnamara@microchip.com>
CC: Jassi Brar <jassisinghbrar@gmail.com>
CC: linux-riscv@lists.infradead.org
CC: linux-kernel@vger.kernel.org

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(-)

Comments

Conor Dooley March 7, 2023, 8:30 p.m. UTC | #1
On Tue, Mar 07, 2023 at 08:22:50PM +0000, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>

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 <conor.dooley@microchip.com>
> CC: Daire McNamara <daire.mcnamara@microchip.com>
> CC: Jassi Brar <jassisinghbrar@gmail.com>
> CC: linux-riscv@lists.infradead.org
> CC: linux-kernel@vger.kernel.org
> 
> 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
>
Conor Dooley March 29, 2023, 4:15 p.m. UTC | #2
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 <conor.dooley@microchip.com>
> 
> 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 <conor.dooley@microchip.com>
> > CC: Daire McNamara <daire.mcnamara@microchip.com>
> > CC: Jassi Brar <jassisinghbrar@gmail.com>
> > CC: linux-riscv@lists.infradead.org
> > CC: linux-kernel@vger.kernel.org
> > 
> > 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
> >
Jassi Brar March 31, 2023, 3:03 p.m. UTC | #3
On Wed, Mar 29, 2023 at 11:15 AM Conor Dooley <conor@kernel.org> 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 <conor.dooley@microchip.com>
> >
> > 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 <jaswinder.singh@linaro.org>

cheers.
Conor Dooley March 31, 2023, 6:14 p.m. UTC | #4
On Fri, Mar 31, 2023 at 10:03:08AM -0500, Jassi Brar wrote:

> I am okay. Acked-by: Jassi Brar <jaswinder.singh@linaro.org>

Great, thanks Jassi!
Valentina Fernandez April 3, 2023, 6:11 p.m. UTC | #5
On 07/03/2023 20:22, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
> 
> 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 <valentina.fernandezalanis@microchip.com>
> 
> 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 <conor.dooley@microchip.com>
> CC: Daire McNamara <daire.mcnamara@microchip.com>
> CC: Jassi Brar <jassisinghbrar@gmail.com>
> CC: linux-riscv@lists.infradead.org
> CC: linux-kernel@vger.kernel.org
> 
> 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(-)
>
Conor Dooley April 3, 2023, 6:28 p.m. UTC | #6
From: Conor Dooley <conor.dooley@microchip.com>

On Tue, 07 Mar 2023 20:22:50 +0000, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
> 
> 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.