History

PCI/MSI: Protect msi_desc::masked for multi-MSI

Multi-MSI uses a single MSI descriptor and there is a single mask register when the device supports per vector masking. To avoid reading back the mask register the value is cached in the MSI descriptor and updates are done by clearing and setting bits in the cache and writing it to the device. But nothing protects msi_desc::masked and the mask register from being modified concurrently on two different CPUs for two different Linux interrupts which belong to the same multi-MSI descriptor. Add a lock to struct device and protect any operation on the mask and the mask register with it. This makes the update of msi_desc::masked unconditional, but there is no place which requires a modification of the hardware register without updating the masked cache. msi_mask_irq() is now an empty wrapper which will be cleaned up in follow up changes. The problem goes way back to the initial support of multi-MSI, but picking the commit which introduced the mask cache is a valid cut off point (2.6.30).

Thomas Gleixner committed 5 years ago

Commit 77e89af1 parent d28d4ad4 files · +13 −10Browse files

Showing the changes to include (2 of 4 files). Show all

Unified · Split

2 files
  1. include/linux/device.h +1 −0
  2. include/linux/msi.h +1 −1
include/linux/device.h+1−0
@@ -506,6 +506,7 @@ struct device { · 505 unmodified lines
506 struct dev_pin_info *pins;506 struct dev_pin_info *pins;
507#endif507#endif
508#ifdef CONFIG_GENERIC_MSI_IRQ508#ifdef CONFIG_GENERIC_MSI_IRQ
509 raw_spinlock_t msi_lock;
509 struct list_head msi_list;510 struct list_head msi_list;
510#endif511#endif
511#ifdef CONFIG_DMA_OPS512#ifdef CONFIG_DMA_OPS
include/linux/msi.h+1−1
@@ -233,7 +233,7 @@ void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg); · 232 unmodified lines
233void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);233void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
234 234
235u32 __pci_msix_desc_mask_irq(struct msi_desc *desc, u32 flag);235u32 __pci_msix_desc_mask_irq(struct msi_desc *desc, u32 flag);
236u32 __pci_msi_desc_mask_irq(struct msi_desc *desc, u32 mask, u32 flag);236void __pci_msi_desc_mask_irq(struct msi_desc *desc, u32 mask, u32 flag);
237void pci_msi_mask_irq(struct irq_data *data);237void pci_msi_mask_irq(struct irq_data *data);
238void pci_msi_unmask_irq(struct irq_data *data);238void pci_msi_unmask_irq(struct irq_data *data);
239 239