xen-pciback: would using pci_clear_master() in xen_pcibk_reset_device() break anything?
Maurice Hieronymus <[email protected]>
| Newsgroups | org.xenproject.lists.xen-devel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am moving `is_busmaster` out of the C bitfield in `struct pci_dev` [1],
because the bits sharing that word are written without a common lock.
xen-pciback is the only code outside drivers/pci that writes the flag,
in `xen_pcibk_reset_device()`:
if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
...
if (pci_is_enabled(dev))
pci_disable_device(dev);
dev->is_busmaster = 0;
} else {
pci_read_config_word(dev, PCI_COMMAND, &cmd);
if (cmd & (PCI_COMMAND_INVALIDATE)) {
cmd &= ~(PCI_COMMAND_INVALIDATE);
pci_write_config_word(dev, PCI_COMMAND, cmd);
dev->is_busmaster = 0;
}
}
Lukas Wunner suggested converting both assignments to `pci_clear_master()`,
so that nothing outside drivers/pci writes the flag [2]. That is not
behavior-preserving: the assignments clear the software flag only, while
`pci_clear_master()` also clears `PCI_COMMAND_MASTER` in config space (it
skips the write only if the bit is already clear).
I do not know xen-pciback, so I cannot tell whether that difference
matters. One thing makes me suspicious: commit 7681f31ec9cd ("xen/pciback:
Don't disable PCI_COMMAND on PCI device reset.") deliberately removed a
`pci_write_config_word(dev, PCI_COMMAND, 0)` from directly above the first
assignment, and `pci_clear_master()` would put a `PCI_COMMAND` write back
at that exact spot.
So my question is simply: would converting these two assignments to
`pci_clear_master()` break anything?
If it would, I will keep xen-pciback's current semantics and export a
narrow flag-only helper instead.
[1] https://lore.kernel.org/linux-pci/[email protected]/
[2] https://lore.kernel.org/linux-pci/[email protected]/
Best,
Maurice