Subject: linux-next: manual merge of the tip tree with the pci tree

From: Stephen Rothwell <[email-masked]>
Date: Fri, 25 Sep 2020 15:21:18 +1000

Hi all,

Today's linux-next merge of the tip tree got a conflict in:

  drivers/pci/controller/vmd.c

between commit:

  42443f036042 ("PCI: vmd: Create IRQ Domain configuration helper")

from the pci tree and commit:

  585dfe8abc44 ("PCI: vmd: Dont abuse vector irqomain as parent")

from the tip tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/pci/controller/vmd.c
index 3c4418cbde1c,aa1b12bac9a1..000000000000
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@@ -304,50 -298,6 +304,50 @@@ static struct msi_domain_info vmd_msi_d
  	.chip		= &vmd_msi_controller,
  };
  
 +static void vmd_enable_msi_remapping(struct vmd_dev *vmd, bool enable)
 +{
 +	u16 reg;
 +
 +	pci_read_config_word(vmd->dev, PCI_REG_VMCONFIG, &reg);
 +	reg = enable ? (reg & ~0x2) : (reg | 0x2);
 +	pci_write_config_word(vmd->dev, PCI_REG_VMCONFIG, reg);
 +}
 +
 +static int vmd_create_irq_domain(struct vmd_dev *vmd)
 +{
 +	struct fwnode_handle *fn;
 +
 +	fn = irq_domain_alloc_named_id_fwnode("VMD-MSI", vmd->sysdata.domain);
 +	if (!fn)
 +		return -ENODEV;
 +
 +	vmd->irq_domain = pci_msi_create_irq_domain(fn, &vmd_msi_domain_info,
- 						    x86_vector_domain);
++						    NULL);
 +	if (!vmd->irq_domain) {
 +		irq_domain_free_fwnode(fn);
 +		return -ENODEV;
 +	}
 +
 +	return 0;
 +}
 +
 +static void vmd_remove_irq_domain(struct vmd_dev *vmd)
 +{
 +	/*
 +	 * Some production BIOS won't enable remapping between soft reboots.
 +	 * Ensure remapping is restored before unloading the driver
 +	 */
 +	if (!vmd->msix_count)
 +		vmd_enable_msi_remapping(vmd, true);
 +
 +	if (vmd->irq_domain) {
 +		struct fwnode_handle *fn = vmd->irq_domain->fwnode;
 +
 +		irq_domain_remove(vmd->irq_domain);
 +		irq_domain_free_fwnode(fn);
 +	}
 +}
 +
  static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus,
  				  unsigned int devfn, int reg, int len)
  {
@@@ -717,12 -568,24 +717,18 @@@ static int vmd_enable_domain(struct vmd
  
  	sd->node = pcibus_to_node(vmd->dev->bus);
  
 -	fn = irq_domain_alloc_named_id_fwnode("VMD-MSI", vmd->sysdata.domain);
 -	if (!fn)
 -		return -ENODEV;
 -
 -	vmd->irq_domain = pci_msi_create_irq_domain(fn, &vmd_msi_domain_info,
 -						    NULL);
 -
 -	if (!vmd->irq_domain) {
 -		irq_domain_free_fwnode(fn);
 -		return -ENODEV;
 +	if (vmd->msix_count) {
 +		ret = vmd_create_irq_domain(vmd);
 +		if (ret)
 +			return ret;
  	}
  
+ 	/*
+ 	 * Override the irq domain bus token so the domain can be distinguished
+ 	 * from a regular PCI/MSI domain.
+ 	 */
+ 	irq_domain_update_bus_token(vmd->irq_domain, DOMAIN_BUS_VMD_MSI);
+ 
  	pci_add_resource(&resources, &vmd->resources[0]);
  	pci_add_resource_offset(&resources, &vmd->resources[1], offset[0]);
  	pci_add_resource_offset(&resources, &vmd->resources[2], offset[1]);