public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Kerr <jk@codeconstruct.com.au>
To: Adam Young <admiyo@amperemail.onmicrosoft.com>,
	 admiyo@os.amperecomputing.com,
	Matt Johnston <matt@codeconstruct.com.au>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] mctp pcc: Implement MCTP over PCC Transport
Date: Tue, 04 Jun 2024 09:15:53 +0800	[thread overview]
Message-ID: <4eefd134bec51482655018bbbd7c4d5c7668a7fa.camel@codeconstruct.com.au> (raw)
In-Reply-To: <1a38b394-30ae-42c6-b363-9f3a00166259@amperemail.onmicrosoft.com>

Hi Adam,

> > And can you include a brief summary of changes since the prior version
> > you have sent?
> > 
> They are all in the header patch.

Ah, neat. Can you include reviewers on CC for that 0/n patch then?

> > > +static struct list_head mctp_pcc_ndevs;
> > I'm not clear on what this list is doing; it seems to be for freeing
> > devices on module unload (or device remove).
> > 
> > However, the module will be refcounted while there are devices bound, so
> > module unload shouldn't be possible in that state. So the only time
> > you'll be iterating this list to free everything will be when it's
> > empty.
> > 
> > You could replace this with the mctp_pcc_driver_remove() just removing the
> > device passed in the argument, rather than doing any list iteration.
> > 
> > ... unless I've missed something?
> 
> There is no requirement that all the devices  be unloaded in order for 
> the module to get unloaded.

... aside from the driver refcounting. You're essentially replicating
the driver core's own facility for device-to-driver mappings here.

> It someone wants to disable the MCTP devices, they can unload the 
> module, and it gets cleaned up.
> 
> With ACPI, the devices never go away, they are defined in a table read 
> at start up and stay there.

Sure, the ACPI bus devices may always be present, but you can still
unbind the driver from one device:

   echo '<device-id>' > /sys/bus/acpi/drivers/mctp_pcc/unbind

- where device-id is one of the links to a device in that mctp_pcc dir.

then:

> So without this change there is no way to unload the module.

... with no devices bound, you can safely unload the module (but the
unload path will also perform that unbind anyway, more on that below).

> Maybe it is just a convenience for development, but I think most
> modules behave this way.

If you can avoid holding internal references to devices, you have a
whole class of bugs you can avoid.

> > Any benefit in including the pcc_hdr in the skb?
> > 
> > (not necessarily an issue, just asking...)
> It shows up in  tracing of the packet.  Useful for debugging.

Sounds good!

> > Does anything need to tell the mailbox driver to do that ack after
> > setting ack_rx?
> 
> Yes.  It is in the previous patch, in the pcc_mailbox code.  I 
> originally had it as a follow on, but reordered to make it a pre-req.  
> That allows me to inline this logic, making the driver easier to review 
> (I hope).

OK. As far as I can tell here this is just setting a member of the
mailbox interface, but not calling back into the mailbox code. If this
is okay, then all good.

> > > +       netif_stop_queue(ndev);
> > Do you need to stop and restart the queue? Your handling is atomic.
> I guess not.  This was just from following the examples of others. Will 
> remove.

Those examples (at least, in the MCTP drivers) will not have been able
to complete transmission until way later - say, after a separate
completion, or after a separate thread has processed the outgoing skb.
While that is happening, we may have stopped the queue.

In your case, you complete transmission entirely within the start_xmit
operation (*and* that path is atomic), so the queue is fine to remain
enabled.

> > > +               if (adev && mctp_pcc_dev->acpi_device == adev)
> > > +                       continue;
> > I think you meant '!=' instead of '=='?
> Yes.  Yes I did.  This is code that has to be there for completeness,
> but I don't really have a way to test, except for the "delete all" case.

The 'unbind' example above will test this.

> > > +static int __init mctp_pcc_mod_init(void)
> > > +{
> > > +       int rc;
> > > +
> > > +       pr_debug("Initializing MCTP over PCC transport driver\n");
> > > +       INIT_LIST_HEAD(&mctp_pcc_ndevs);
> > > +       rc = acpi_bus_register_driver(&mctp_pcc_driver);
> > > +       if (rc < 0)
> > > +               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error registering driver\n"));
> > > +       return rc;
> > > +}
> > > +
> > > +static __exit void mctp_pcc_mod_exit(void)
> > > +{
> > > +       pr_debug("Removing MCTP over PCC transport driver\n");
> > > +       mctp_pcc_driver_remove(NULL);
> > > +       acpi_bus_unregister_driver(&mctp_pcc_driver);
> > > +}
> > > +
> > > +module_init(mctp_pcc_mod_init);
> > > +module_exit(mctp_pcc_mod_exit);
> > If you end up removing the mctp_pcc_ndevs list, these can all be
> > replaced with module_acpi_driver(mctp_pcc_driver);
> 
> Yeah, I can't get away with that.  The ACPI devices may still be there 
> when some one calls rmmod, and so we need to clean up the ndevs.

The core driver unregister path should unbind all devices before the
module is removed, so your mctp_pcc_driver_remove() should get invoked
on each individual device during that process.

(with the above != vs. == bug fixed, you'll probably find that
"delete-all" case will always hit an empty list)

... this is unless something is different about the ACPI bus type, but
it all looks standard from a brief look!

Cheers,


Jeremy

  reply	other threads:[~2024-06-04  1:16 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13 17:35 [PATCH 0/3] MCTP over PCC admiyo
2024-05-13 17:35 ` [PATCH 1/3] mctp pcc: Implement MCTP over PCC Transport admiyo
2024-05-13 18:31   ` Simon Horman
2024-05-13 20:08   ` Andrew Lunn
2024-05-13 20:17   ` Andrew Lunn
2024-05-13 20:22   ` Andrew Lunn
2024-05-14  5:24   ` Jeremy Kerr
2024-05-14 10:12   ` kernel test robot
2024-05-14 11:36   ` kernel test robot
2024-05-14 16:29   ` kernel test robot
2024-05-29 13:10   ` kernel test robot
2024-05-29 14:56   ` kernel test robot
2024-05-13 17:35 ` [PATCH 2/3] mctp pcc: Allow PCC Data Type in MCTP resource admiyo
2024-05-13 20:23   ` Andrew Lunn
2024-05-13 17:35 ` [PATCH 3/3] mctp pcc: RFC Check before sending MCTP PCC response ACK admiyo
2024-05-13 20:26   ` Andrew Lunn
2024-05-28 19:18 ` [PATCH v2 0/3] MCTP over PCC admiyo
2024-05-28 19:18   ` [PATCH v2 1/3] mctp pcc: Check before sending MCTP PCC response ACK admiyo
2024-05-29  3:26     ` Ratheesh Kannoth
2024-06-03  9:07     ` Sudeep Holla
2024-05-28 19:18   ` [PATCH v2 2/3] mctp pcc: Allow PCC Data Type in MCTP resource admiyo
2024-05-29  3:25     ` Ratheesh Kannoth
2024-05-30 16:24       ` Adam Young
2024-05-28 19:18   ` [PATCH v2 3/3] mctp pcc: Implement MCTP over PCC Transport admiyo
2024-05-29  2:45     ` Jakub Kicinski
2024-05-29  3:30       ` Jeremy Kerr
2024-05-30 23:51       ` Adam Young
2024-05-29  3:02     ` Jeremy Kerr
2024-06-03 17:53       ` Adam Young
2024-06-04  1:15         ` Jeremy Kerr [this message]
2024-05-29 13:21     ` kernel test robot
2024-05-29 14:03     ` kernel test robot
2024-06-07  7:06   ` [PATCH v2 0/3] MCTP over PCC John Chung
2024-06-19 20:05 ` admiyo
2024-06-19 20:05   ` [PATCH v2 1/3] mctp pcc: Check before sending MCTP PCC response ACK admiyo
2024-06-19 20:05   ` [PATCH v2 2/3] mctp pcc: Allow PCC Data Type in MCTP resource admiyo
2024-06-19 20:05   ` [PATCH v2 3/3] mctp pcc: Implement MCTP over PCC Transport admiyo
2024-06-19 23:26     ` Jakub Kicinski
2024-06-20  3:24       ` Adam Young
2024-06-20 13:26         ` Jakub Kicinski
2024-06-20 11:05     ` kernel test robot
2024-06-20 15:13     ` kernel test robot
2024-06-20  3:10   ` [PATCH v2 0/3] MCTP over PCC Adam Young

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4eefd134bec51482655018bbbd7c4d5c7668a7fa.camel@codeconstruct.com.au \
    --to=jk@codeconstruct.com.au \
    --cc=admiyo@amperemail.onmicrosoft.com \
    --cc=admiyo@os.amperecomputing.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@codeconstruct.com.au \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox