Re: [PATCH v2] PCI: Move pci_dev->is_busmaster into priv_flags
From: Maurice Hieronymus
Date: Sat Jul 18 2026 - 13:03:35 EST
On Wed Jul 15, 2026 at 6:54 AM CEST, Lukas Wunner wrote:
> pci_dev_assign_busmaster() should not have public visibility.
> Drivers should really use pci_set_master() / pci_clear_master()
> and nothing else.
>
> It seems Xen is the only one in the tree which needs this:
>
>> +++ b/drivers/xen/xen-pciback/pciback_ops.c
>> @@ -125,14 +125,14 @@ void xen_pcibk_reset_device(struct pci_dev *dev)
>> if (pci_is_enabled(dev))
>> pci_disable_device(dev);
>>
>> - dev->is_busmaster = 0;
>> + pci_dev_assign_busmaster(dev, false);
>> } 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;
>> + pci_dev_assign_busmaster(dev, false);
>> }
>> }
>> }
>
> Please change these direct assignments to pci_clear_master(),
> preferably in a separate patch to ease bisecting if anything
> breaks.
This conversion does not preserve behavior. The direct assignments
clear only the software flag, while pci_clear_master() also clears
PCI_COMMAND_MASTER in config space.
I am not an expert on xen devices. That's why I want to clarify first
that this does not break anything. Especially since commit
7681f31ec9cd ("xen/pciback: Don't disable PCI_COMMAND on PCI device
reset.") deliberately removed the PCI_COMMAND write right above the
first assignment, and pci_clear_master() would reintroduce a
PCI_COMMAND write there.
Best,
Maurice