Re: [PATCH v2] PCI: Move pci_dev->is_busmaster into priv_flags

"Maurice Hieronymus" <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux,org.kernel.vger.linux-edac,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci,org.kernel.vger.linux-scsi,org.kernel.vger.netdev,org.xenproject.lists.xen-devel
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.