hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/xen/xen-pciback/conf_space.c
....@@ -10,6 +10,8 @@
1010 * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
1111 */
1212
13
+#define dev_fmt(fmt) DRV_NAME ": " fmt
14
+
1315 #include <linux/kernel.h>
1416 #include <linux/moduleparam.h>
1517 #include <linux/pci.h>
....@@ -154,9 +156,7 @@
154156 * (as if device didn't respond) */
155157 u32 value = 0, tmp_val;
156158
157
- if (unlikely(verbose_request))
158
- printk(KERN_DEBUG DRV_NAME ": %s: read %d bytes at 0x%x\n",
159
- pci_name(dev), size, offset);
159
+ dev_dbg(&dev->dev, "read %d bytes at 0x%x\n", size, offset);
160160
161161 if (!valid_request(offset, size)) {
162162 err = XEN_PCI_ERR_invalid_offset;
....@@ -195,9 +195,7 @@
195195 }
196196
197197 out:
198
- if (unlikely(verbose_request))
199
- printk(KERN_DEBUG DRV_NAME ": %s: read %d bytes at 0x%x = %x\n",
200
- pci_name(dev), size, offset, value);
198
+ dev_dbg(&dev->dev, "read %d bytes at 0x%x = %x\n", size, offset, value);
201199
202200 *ret_val = value;
203201 return xen_pcibios_err_to_errno(err);
....@@ -212,10 +210,8 @@
212210 u32 tmp_val;
213211 int field_start, field_end;
214212
215
- if (unlikely(verbose_request))
216
- printk(KERN_DEBUG
217
- DRV_NAME ": %s: write request %d bytes at 0x%x = %x\n",
218
- pci_name(dev), size, offset, value);
213
+ dev_dbg(&dev->dev, "write request %d bytes at 0x%x = %x\n",
214
+ size, offset, value);
219215
220216 if (!valid_request(offset, size))
221217 return XEN_PCI_ERR_invalid_offset;
....@@ -286,6 +282,43 @@
286282 return xen_pcibios_err_to_errno(err);
287283 }
288284
285
+int xen_pcibk_get_interrupt_type(struct pci_dev *dev)
286
+{
287
+ int err;
288
+ u16 val;
289
+ int ret = 0;
290
+
291
+ err = pci_read_config_word(dev, PCI_COMMAND, &val);
292
+ if (err)
293
+ return err;
294
+ if (!(val & PCI_COMMAND_INTX_DISABLE))
295
+ ret |= INTERRUPT_TYPE_INTX;
296
+
297
+ /*
298
+ * Do not trust dev->msi(x)_enabled here, as enabling could be done
299
+ * bypassing the pci_*msi* functions, by the qemu.
300
+ */
301
+ if (dev->msi_cap) {
302
+ err = pci_read_config_word(dev,
303
+ dev->msi_cap + PCI_MSI_FLAGS,
304
+ &val);
305
+ if (err)
306
+ return err;
307
+ if (val & PCI_MSI_FLAGS_ENABLE)
308
+ ret |= INTERRUPT_TYPE_MSI;
309
+ }
310
+ if (dev->msix_cap) {
311
+ err = pci_read_config_word(dev,
312
+ dev->msix_cap + PCI_MSIX_FLAGS,
313
+ &val);
314
+ if (err)
315
+ return err;
316
+ if (val & PCI_MSIX_FLAGS_ENABLE)
317
+ ret |= INTERRUPT_TYPE_MSIX;
318
+ }
319
+ return ret ?: INTERRUPT_TYPE_NONE;
320
+}
321
+
289322 void xen_pcibk_config_free_dyn_fields(struct pci_dev *dev)
290323 {
291324 struct xen_pcibk_dev_data *dev_data = pci_get_drvdata(dev);