unsigned int pinned:1;
        unsigned int orig_intx:1;
        unsigned int restore_intx:1;
+       unsigned int mwi:1;
        u32 region_mask;
 };
 
                if (this->region_mask & (1 << i))
                        pci_release_region(dev, i);
 
+       if (this->mwi)
+               pci_clear_mwi(dev);
+
        if (this->restore_intx)
                pci_intx(dev, this->orig_intx);
 
 }
 EXPORT_SYMBOL(pci_set_mwi);
 
+/**
+ * pcim_set_mwi - a device-managed pci_set_mwi()
+ * @dev: the PCI device for which MWI is enabled
+ *
+ * Managed pci_set_mwi().
+ *
+ * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
+ */
+int pcim_set_mwi(struct pci_dev *dev)
+{
+       struct pci_devres *dr;
+
+       dr = find_pci_dr(dev);
+       if (!dr)
+               return -ENOMEM;
+
+       dr->mwi = 1;
+       return pci_set_mwi(dev);
+}
+EXPORT_SYMBOL(pcim_set_mwi);
+
 /**
  * pci_try_set_mwi - enables memory-write-invalidate PCI transaction
  * @dev: the PCI device for which MWI is enabled
 
 int pci_set_cacheline_size(struct pci_dev *dev);
 #define HAVE_PCI_SET_MWI
 int __must_check pci_set_mwi(struct pci_dev *dev);
+int __must_check pcim_set_mwi(struct pci_dev *dev);
 int pci_try_set_mwi(struct pci_dev *dev);
 void pci_clear_mwi(struct pci_dev *dev);
 void pci_intx(struct pci_dev *dev, int enable);