Re: [PATCH v4 07/23] mailbox: Add RISC-V SBI message proxy (MPXY) based mailbox driver

From: Andy Shevchenko
Date: Tue Jun 10 2025 - 05:56:09 EST


On Tue, Jun 10, 2025 at 10:05:27AM +0530, Anup Patel wrote:
> On Tue, Jun 10, 2025 at 1:34 AM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > On Mon, Jun 09, 2025 at 05:59:40PM +0530, Anup Patel wrote:
> > > On Wed, May 28, 2025 at 4:23 PM Andy Shevchenko
> > > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > > > On Sun, May 25, 2025 at 02:16:54PM +0530, Anup Patel wrote:

...

> > > > > + if (mbox->msi_count)
> > > >
> > > > Is this check really needed?
> > >
> > > MSIs are optional for the SBI MPXY mailbox so we should only use
> > > platform_device_msi_xyz() APIs only when MSIs are available.
> >
> > > > > + platform_device_msi_free_irqs_all(mbox->dev);
> >
> > Hmm... I am not sure why. Do you have any Oops or warnings if the check
> > is not there and no MSI provided?
>
> We don't see any oops or warnings. This check is to avoid unnecessary
> work (such as acquiring lock, checking default domain, etc) in the
> msi_domain_free_irqs_all() called by platform_device_msi_free_irqs_all().
>
> I don't mind dropping the check so I will update in the next revision.

Perhaps you can rather add this check into the callee? Seems to me that
you have a justification for it. Usual pattern in the kernel that freeing
resources should be aware of the NULL pointers or optional resources
so we may call it unconditionally from the user(s).

--
With Best Regards,
Andy Shevchenko