aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/pci.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c824dc8d617c..f3fd55df67db 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1667,6 +1667,22 @@ int pci_request_regions_exclusive(struct pci_dev *pdev, const char *res_name)
1667 ((1 << 6) - 1), res_name); 1667 ((1 << 6) - 1), res_name);
1668} 1668}
1669 1669
1670static void __pci_set_master(struct pci_dev *dev, bool enable)
1671{
1672 u16 old_cmd, cmd;
1673
1674 pci_read_config_word(dev, PCI_COMMAND, &old_cmd);
1675 if (enable)
1676 cmd = old_cmd | PCI_COMMAND_MASTER;
1677 else
1678 cmd = old_cmd & ~PCI_COMMAND_MASTER;
1679 if (cmd != old_cmd) {
1680 dev_dbg(&dev->dev, "%s bus mastering\n",
1681 enable ? "enabling" : "disabling");
1682 pci_write_config_word(dev, PCI_COMMAND, cmd);
1683 }
1684 dev->is_busmaster = enable;
1685}
1670 1686
1671/** 1687/**
1672 * pci_set_master - enables bus-mastering for device dev 1688 * pci_set_master - enables bus-mastering for device dev
@@ -1675,21 +1691,21 @@ int pci_request_regions_exclusive(struct pci_dev *pdev, const char *res_name)
1675 * Enables bus-mastering on the device and calls pcibios_set_master() 1691 * Enables bus-mastering on the device and calls pcibios_set_master()
1676 * to do the needed arch specific settings. 1692 * to do the needed arch specific settings.
1677 */ 1693 */
1678void 1694void pci_set_master(struct pci_dev *dev)
1679pci_set_master(struct pci_dev *dev)
1680{ 1695{
1681 u16 cmd; 1696 __pci_set_master(dev, true);
1682
1683 pci_read_config_word(dev, PCI_COMMAND, &cmd);
1684 if (! (cmd & PCI_COMMAND_MASTER)) {
1685 dev_dbg(&dev->dev, "enabling bus mastering\n");
1686 cmd |= PCI_COMMAND_MASTER;
1687 pci_write_config_word(dev, PCI_COMMAND, cmd);
1688 }
1689 dev->is_busmaster = 1;
1690 pcibios_set_master(dev); 1697 pcibios_set_master(dev);
1691} 1698}
1692 1699
1700/**
1701 * pci_clear_master - disables bus-mastering for device dev
1702 * @dev: the PCI device to disable
1703 */
1704void pci_clear_master(struct pci_dev *dev)
1705{
1706 __pci_set_master(dev, false);
1707}
1708
1693#ifdef PCI_DISABLE_MWI 1709#ifdef PCI_DISABLE_MWI
1694int pci_set_mwi(struct pci_dev *dev) 1710int pci_set_mwi(struct pci_dev *dev)
1695{ 1711{
@@ -2346,6 +2362,7 @@ EXPORT_SYMBOL(pci_release_selected_regions);
2346EXPORT_SYMBOL(pci_request_selected_regions); 2362EXPORT_SYMBOL(pci_request_selected_regions);
2347EXPORT_SYMBOL(pci_request_selected_regions_exclusive); 2363EXPORT_SYMBOL(pci_request_selected_regions_exclusive);
2348EXPORT_SYMBOL(pci_set_master); 2364EXPORT_SYMBOL(pci_set_master);
2365EXPORT_SYMBOL(pci_clear_master);
2349EXPORT_SYMBOL(pci_set_mwi); 2366EXPORT_SYMBOL(pci_set_mwi);
2350EXPORT_SYMBOL(pci_try_set_mwi); 2367EXPORT_SYMBOL(pci_try_set_mwi);
2351EXPORT_SYMBOL(pci_clear_mwi); 2368EXPORT_SYMBOL(pci_clear_mwi);