Re: [PATCH v2 3/3] mctp pcc: Implement MCTP over PCC Transport
From: Jeremy Kerr <jk@codeconstruct.com.au>
Date: 2024-06-04 01:16:02
Also in:
lkml
Hi Adam,
quoted
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?
quoted
quoted
+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.
quoted
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!
quoted
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.
quoted
quoted
+ 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.
quoted
quoted
+ 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.
quoted
quoted
+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