diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-11 21:50:26 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-11 21:50:26 -0500 |
commit | 7b67e751479d50b7f84d1a3cc5216eed5e534b66 (patch) | |
tree | a1a6746857cf65f04dde739fe271bf4143d55eaf /drivers/uio | |
parent | 9f13a1fd452f11c18004ba2422a6384b424ec8a9 (diff) | |
parent | 76ccc297018d25d55b789bbd508861ef1e2cdb0c (diff) |
Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci
* 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci: (80 commits)
x86/PCI: Expand the x86_msi_ops to have a restore MSIs.
PCI: Increase resource array mask bit size in pcim_iomap_regions()
PCI: DEVICE_COUNT_RESOURCE should be equal to PCI_NUM_RESOURCES
PCI: pci_ids: add device ids for STA2X11 device (aka ConneXT)
PNP: work around Dell 1536/1546 BIOS MMCONFIG bug that breaks USB
x86/PCI: amd: factor out MMCONFIG discovery
PCI: Enable ATS at the device state restore
PCI: msi: fix imbalanced refcount of msi irq sysfs objects
PCI: kconfig: English typo in pci/pcie/Kconfig
PCI/PM/Runtime: make PCI traces quieter
PCI: remove pci_create_bus()
xtensa/PCI: convert to pci_scan_root_bus() for correct root bus resources
x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented()
x86/PCI: read Broadcom CNB20LE host bridge info before PCI scan
sparc32, leon/PCI: convert to pci_scan_root_bus() for correct root bus resources
sparc/PCI: convert to pci_create_root_bus()
sh/PCI: convert to pci_scan_root_bus() for correct root bus resources
powerpc/PCI: convert to pci_create_root_bus()
powerpc/PCI: split PHB part out of pcibios_map_io_space()
...
Fix up conflicts in drivers/pci/msi.c and include/linux/pci_regs.h due
to the same patches being applied in other branches.
Diffstat (limited to 'drivers/uio')
-rw-r--r-- | drivers/uio/uio_pci_generic.c | 78 |
1 files changed, 7 insertions, 71 deletions
diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c index 02bd47bdee1c..0bd08ef2b394 100644 --- a/drivers/uio/uio_pci_generic.c +++ b/drivers/uio/uio_pci_generic.c | |||
@@ -45,77 +45,12 @@ to_uio_pci_generic_dev(struct uio_info *info) | |||
45 | static irqreturn_t irqhandler(int irq, struct uio_info *info) | 45 | static irqreturn_t irqhandler(int irq, struct uio_info *info) |
46 | { | 46 | { |
47 | struct uio_pci_generic_dev *gdev = to_uio_pci_generic_dev(info); | 47 | struct uio_pci_generic_dev *gdev = to_uio_pci_generic_dev(info); |
48 | struct pci_dev *pdev = gdev->pdev; | ||
49 | irqreturn_t ret = IRQ_NONE; | ||
50 | u32 cmd_status_dword; | ||
51 | u16 origcmd, newcmd, status; | ||
52 | |||
53 | /* We do a single dword read to retrieve both command and status. | ||
54 | * Document assumptions that make this possible. */ | ||
55 | BUILD_BUG_ON(PCI_COMMAND % 4); | ||
56 | BUILD_BUG_ON(PCI_COMMAND + 2 != PCI_STATUS); | ||
57 | |||
58 | pci_block_user_cfg_access(pdev); | ||
59 | |||
60 | /* Read both command and status registers in a single 32-bit operation. | ||
61 | * Note: we could cache the value for command and move the status read | ||
62 | * out of the lock if there was a way to get notified of user changes | ||
63 | * to command register through sysfs. Should be good for shared irqs. */ | ||
64 | pci_read_config_dword(pdev, PCI_COMMAND, &cmd_status_dword); | ||
65 | origcmd = cmd_status_dword; | ||
66 | status = cmd_status_dword >> 16; | ||
67 | |||
68 | /* Check interrupt status register to see whether our device | ||
69 | * triggered the interrupt. */ | ||
70 | if (!(status & PCI_STATUS_INTERRUPT)) | ||
71 | goto done; | ||
72 | |||
73 | /* We triggered the interrupt, disable it. */ | ||
74 | newcmd = origcmd | PCI_COMMAND_INTX_DISABLE; | ||
75 | if (newcmd != origcmd) | ||
76 | pci_write_config_word(pdev, PCI_COMMAND, newcmd); | ||
77 | 48 | ||
78 | /* UIO core will signal the user process. */ | 49 | if (!pci_check_and_mask_intx(gdev->pdev)) |
79 | ret = IRQ_HANDLED; | 50 | return IRQ_NONE; |
80 | done: | ||
81 | |||
82 | pci_unblock_user_cfg_access(pdev); | ||
83 | return ret; | ||
84 | } | ||
85 | 51 | ||
86 | /* Verify that the device supports Interrupt Disable bit in command register, | 52 | /* UIO core will signal the user process. */ |
87 | * per PCI 2.3, by flipping this bit and reading it back: this bit was readonly | 53 | return IRQ_HANDLED; |
88 | * in PCI 2.2. */ | ||
89 | static int __devinit verify_pci_2_3(struct pci_dev *pdev) | ||
90 | { | ||
91 | u16 orig, new; | ||
92 | int err = 0; | ||
93 | |||
94 | pci_block_user_cfg_access(pdev); | ||
95 | pci_read_config_word(pdev, PCI_COMMAND, &orig); | ||
96 | pci_write_config_word(pdev, PCI_COMMAND, | ||
97 | orig ^ PCI_COMMAND_INTX_DISABLE); | ||
98 | pci_read_config_word(pdev, PCI_COMMAND, &new); | ||
99 | /* There's no way to protect against | ||
100 | * hardware bugs or detect them reliably, but as long as we know | ||
101 | * what the value should be, let's go ahead and check it. */ | ||
102 | if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) { | ||
103 | err = -EBUSY; | ||
104 | dev_err(&pdev->dev, "Command changed from 0x%x to 0x%x: " | ||
105 | "driver or HW bug?\n", orig, new); | ||
106 | goto err; | ||
107 | } | ||
108 | if (!((new ^ orig) & PCI_COMMAND_INTX_DISABLE)) { | ||
109 | dev_warn(&pdev->dev, "Device does not support " | ||
110 | "disabling interrupts: unable to bind.\n"); | ||
111 | err = -ENODEV; | ||
112 | goto err; | ||
113 | } | ||
114 | /* Now restore the original value. */ | ||
115 | pci_write_config_word(pdev, PCI_COMMAND, orig); | ||
116 | err: | ||
117 | pci_unblock_user_cfg_access(pdev); | ||
118 | return err; | ||
119 | } | 54 | } |
120 | 55 | ||
121 | static int __devinit probe(struct pci_dev *pdev, | 56 | static int __devinit probe(struct pci_dev *pdev, |
@@ -138,9 +73,10 @@ static int __devinit probe(struct pci_dev *pdev, | |||
138 | return -ENODEV; | 73 | return -ENODEV; |
139 | } | 74 | } |
140 | 75 | ||
141 | err = verify_pci_2_3(pdev); | 76 | if (!pci_intx_mask_supported(pdev)) { |
142 | if (err) | 77 | err = -ENODEV; |
143 | goto err_verify; | 78 | goto err_verify; |
79 | } | ||
144 | 80 | ||
145 | gdev = kzalloc(sizeof(struct uio_pci_generic_dev), GFP_KERNEL); | 81 | gdev = kzalloc(sizeof(struct uio_pci_generic_dev), GFP_KERNEL); |
146 | if (!gdev) { | 82 | if (!gdev) { |