Commit a75d68f6 authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Daniel Vetter

vgaarb: Use dev_printk() when possible

Use dev_printk() when possible.  This makes messages more consistent with
other device-related messages and, in some cases, adds useful information.
This changes messages like this:

  vgaarb: failed to allocate pci device
  vgaarb: setting as boot device: PCI:0000:01:00.0
  vgaarb: device added: PCI:0000:01:00.0,decodes=io+mem,owns=io+mem,locks=none
  vgaarb: bridge control possible 0000:01:00.0

to this:

  pci 0000:01:00.0: vgaarb: failed to allocate VGA arbiter data
  pci 0000:01:00.0: vgaarb: setting as boot VGA device
  pci 0000:01:00.0: vgaarb: VGA device added: decodes=io+mem,owns=io+mem,locks=none
  pci 0000:01:00.0: vgaarb: bridge control possible

No functional change intended.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161117174758.16810.67625.stgit@bhelgaas-glaptop.roam.corp.google.com
parent 069cad6d
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
#define pr_fmt(fmt) "vgaarb: " fmt #define pr_fmt(fmt) "vgaarb: " fmt
#define vgaarb_dbg(dev, fmt, arg...) dev_dbg(dev, "vgaarb: " fmt, ##arg)
#define vgaarb_info(dev, fmt, arg...) dev_info(dev, "vgaarb: " fmt, ##arg)
#define vgaarb_err(dev, fmt, arg...) dev_err(dev, "vgaarb: " fmt, ##arg)
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -188,6 +192,7 @@ static void vga_check_first_use(void) ...@@ -188,6 +192,7 @@ static void vga_check_first_use(void)
static struct vga_device *__vga_tryget(struct vga_device *vgadev, static struct vga_device *__vga_tryget(struct vga_device *vgadev,
unsigned int rsrc) unsigned int rsrc)
{ {
struct device *dev = &vgadev->pdev->dev;
unsigned int wants, legacy_wants, match; unsigned int wants, legacy_wants, match;
struct vga_device *conflict; struct vga_device *conflict;
unsigned int pci_bits; unsigned int pci_bits;
...@@ -203,8 +208,8 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev, ...@@ -203,8 +208,8 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev,
(vgadev->decodes & VGA_RSRC_LEGACY_MEM)) (vgadev->decodes & VGA_RSRC_LEGACY_MEM))
rsrc |= VGA_RSRC_LEGACY_MEM; rsrc |= VGA_RSRC_LEGACY_MEM;
pr_debug("%s: %d\n", __func__, rsrc); vgaarb_dbg(dev, "%s: %d\n", __func__, rsrc);
pr_debug("%s: owns: %d\n", __func__, vgadev->owns); vgaarb_dbg(dev, "%s: owns: %d\n", __func__, vgadev->owns);
/* Check what resources we need to acquire */ /* Check what resources we need to acquire */
wants = rsrc & ~vgadev->owns; wants = rsrc & ~vgadev->owns;
...@@ -336,9 +341,10 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev, ...@@ -336,9 +341,10 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev,
static void __vga_put(struct vga_device *vgadev, unsigned int rsrc) static void __vga_put(struct vga_device *vgadev, unsigned int rsrc)
{ {
struct device *dev = &vgadev->pdev->dev;
unsigned int old_locks = vgadev->locks; unsigned int old_locks = vgadev->locks;
pr_debug("%s\n", __func__); vgaarb_dbg(dev, "%s\n", __func__);
/* Update our counters, and account for equivalent legacy resources /* Update our counters, and account for equivalent legacy resources
* if we decode them * if we decode them
...@@ -611,7 +617,7 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) ...@@ -611,7 +617,7 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev)
/* Allocate structure */ /* Allocate structure */
vgadev = kzalloc(sizeof(struct vga_device), GFP_KERNEL); vgadev = kzalloc(sizeof(struct vga_device), GFP_KERNEL);
if (vgadev == NULL) { if (vgadev == NULL) {
pr_err("failed to allocate pci device\n"); vgaarb_err(&pdev->dev, "failed to allocate VGA arbiter data\n");
/* /*
* What to do on allocation failure ? For now, let's just do * What to do on allocation failure ? For now, let's just do
* nothing, I'm not sure there is anything saner to be done. * nothing, I'm not sure there is anything saner to be done.
...@@ -663,7 +669,7 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) ...@@ -663,7 +669,7 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev)
*/ */
if (vga_default == NULL && if (vga_default == NULL &&
((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) { ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) {
pr_info("setting as boot device: PCI:%s\n", pci_name(pdev)); vgaarb_info(&pdev->dev, "setting as boot VGA device\n");
vga_set_default_device(pdev); vga_set_default_device(pdev);
} }
...@@ -672,8 +678,7 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) ...@@ -672,8 +678,7 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev)
/* Add to the list */ /* Add to the list */
list_add(&vgadev->list, &vga_list); list_add(&vgadev->list, &vga_list);
vga_count++; vga_count++;
pr_info("device added: PCI:%s,decodes=%s,owns=%s,locks=%s\n", vgaarb_info(&pdev->dev, "VGA device added: decodes=%s,owns=%s,locks=%s\n",
pci_name(pdev),
vga_iostate_to_str(vgadev->decodes), vga_iostate_to_str(vgadev->decodes),
vga_iostate_to_str(vgadev->owns), vga_iostate_to_str(vgadev->owns),
vga_iostate_to_str(vgadev->locks)); vga_iostate_to_str(vgadev->locks));
...@@ -725,6 +730,7 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev) ...@@ -725,6 +730,7 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev)
static inline void vga_update_device_decodes(struct vga_device *vgadev, static inline void vga_update_device_decodes(struct vga_device *vgadev,
int new_decodes) int new_decodes)
{ {
struct device *dev = &vgadev->pdev->dev;
int old_decodes, decodes_removed, decodes_unlocked; int old_decodes, decodes_removed, decodes_unlocked;
old_decodes = vgadev->decodes; old_decodes = vgadev->decodes;
...@@ -732,8 +738,7 @@ static inline void vga_update_device_decodes(struct vga_device *vgadev, ...@@ -732,8 +738,7 @@ static inline void vga_update_device_decodes(struct vga_device *vgadev,
decodes_unlocked = vgadev->locks & decodes_removed; decodes_unlocked = vgadev->locks & decodes_removed;
vgadev->decodes = new_decodes; vgadev->decodes = new_decodes;
pr_info("device changed decodes: PCI:%s,olddecodes=%s,decodes=%s:owns=%s\n", vgaarb_info(dev, "changed VGA decodes: olddecodes=%s,decodes=%s:owns=%s\n",
pci_name(vgadev->pdev),
vga_iostate_to_str(old_decodes), vga_iostate_to_str(old_decodes),
vga_iostate_to_str(vgadev->decodes), vga_iostate_to_str(vgadev->decodes),
vga_iostate_to_str(vgadev->owns)); vga_iostate_to_str(vgadev->owns));
...@@ -754,7 +759,7 @@ static inline void vga_update_device_decodes(struct vga_device *vgadev, ...@@ -754,7 +759,7 @@ static inline void vga_update_device_decodes(struct vga_device *vgadev,
if (!(old_decodes & VGA_RSRC_LEGACY_MASK) && if (!(old_decodes & VGA_RSRC_LEGACY_MASK) &&
new_decodes & VGA_RSRC_LEGACY_MASK) new_decodes & VGA_RSRC_LEGACY_MASK)
vga_decode_count++; vga_decode_count++;
pr_debug("decoding count now is: %d\n", vga_decode_count); vgaarb_dbg(dev, "decoding count now is: %d\n", vga_decode_count);
} }
static void __vga_set_legacy_decoding(struct pci_dev *pdev, static void __vga_set_legacy_decoding(struct pci_dev *pdev,
...@@ -1184,24 +1189,25 @@ static ssize_t vga_arb_write(struct file *file, const char __user *buf, ...@@ -1184,24 +1189,25 @@ static ssize_t vga_arb_write(struct file *file, const char __user *buf,
ret_val = -EPROTO; ret_val = -EPROTO;
goto done; goto done;
} }
pr_debug("%s ==> %x:%x:%x.%x\n", curr_pos,
domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
pdev = pci_get_domain_bus_and_slot(domain, bus, devfn); pdev = pci_get_domain_bus_and_slot(domain, bus, devfn);
pr_debug("pdev %p\n", pdev);
if (!pdev) { if (!pdev) {
pr_err("invalid PCI address %x:%x:%x\n", pr_err("invalid PCI address %04x:%02x:%02x.%x\n",
domain, bus, devfn); domain, bus, PCI_SLOT(devfn),
PCI_FUNC(devfn));
ret_val = -ENODEV; ret_val = -ENODEV;
goto done; goto done;
} }
pr_debug("%s ==> %04x:%02x:%02x.%x pdev %p\n", curr_pos,
domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
pdev);
} }
vgadev = vgadev_find(pdev); vgadev = vgadev_find(pdev);
pr_debug("vgadev %p\n", vgadev); pr_debug("vgadev %p\n", vgadev);
if (vgadev == NULL) { if (vgadev == NULL) {
if (pdev) { if (pdev) {
pr_err("this pci device is not a vga device\n"); vgaarb_err(&pdev->dev, "not a VGA device\n");
pci_dev_put(pdev); pci_dev_put(pdev);
} }
...@@ -1221,7 +1227,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user *buf, ...@@ -1221,7 +1227,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user *buf,
} }
} }
if (i == MAX_USER_CARDS) { if (i == MAX_USER_CARDS) {
pr_err("maximum user cards (%d) number reached!\n", vgaarb_err(&pdev->dev, "maximum user cards (%d) number reached, ignoring this one!\n",
MAX_USER_CARDS); MAX_USER_CARDS);
pci_dev_put(pdev); pci_dev_put(pdev);
/* XXX: which value to return? */ /* XXX: which value to return? */
...@@ -1310,7 +1316,7 @@ static int vga_arb_release(struct inode *inode, struct file *file) ...@@ -1310,7 +1316,7 @@ static int vga_arb_release(struct inode *inode, struct file *file)
uc = &priv->cards[i]; uc = &priv->cards[i];
if (uc->pdev == NULL) if (uc->pdev == NULL)
continue; continue;
pr_debug("uc->io_cnt == %d, uc->mem_cnt == %d\n", vgaarb_dbg(&uc->pdev->dev, "uc->io_cnt == %d, uc->mem_cnt == %d\n",
uc->io_cnt, uc->mem_cnt); uc->io_cnt, uc->mem_cnt);
while (uc->io_cnt--) while (uc->io_cnt--)
vga_put(uc->pdev, VGA_RSRC_LEGACY_IO); vga_put(uc->pdev, VGA_RSRC_LEGACY_IO);
...@@ -1364,7 +1370,7 @@ static int pci_notify(struct notifier_block *nb, unsigned long action, ...@@ -1364,7 +1370,7 @@ static int pci_notify(struct notifier_block *nb, unsigned long action,
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
bool notify = false; bool notify = false;
pr_debug("%s\n", __func__); vgaarb_dbg(dev, "%s\n", __func__);
/* For now we're only intereted in devices added and removed. I didn't /* For now we're only intereted in devices added and removed. I didn't
* test this thing here, so someone needs to double check for the * test this thing here, so someone needs to double check for the
...@@ -1401,6 +1407,7 @@ static int __init vga_arb_device_init(void) ...@@ -1401,6 +1407,7 @@ static int __init vga_arb_device_init(void)
int rc; int rc;
struct pci_dev *pdev; struct pci_dev *pdev;
struct vga_device *vgadev; struct vga_device *vgadev;
struct device *dev;
rc = misc_register(&vga_arb_device); rc = misc_register(&vga_arb_device);
if (rc < 0) if (rc < 0)
...@@ -1416,8 +1423,6 @@ static int __init vga_arb_device_init(void) ...@@ -1416,8 +1423,6 @@ static int __init vga_arb_device_init(void)
PCI_ANY_ID, pdev)) != NULL) PCI_ANY_ID, pdev)) != NULL)
vga_arbiter_add_pci_device(pdev); vga_arbiter_add_pci_device(pdev);
pr_info("loaded\n");
list_for_each_entry(vgadev, &vga_list, list) { list_for_each_entry(vgadev, &vga_list, list) {
#if defined(CONFIG_X86) || defined(CONFIG_IA64) #if defined(CONFIG_X86) || defined(CONFIG_IA64)
/* /*
...@@ -1433,6 +1438,7 @@ static int __init vga_arb_device_init(void) ...@@ -1433,6 +1438,7 @@ static int __init vga_arb_device_init(void)
int i; int i;
limit = screen_info.lfb_base + screen_info.lfb_size; limit = screen_info.lfb_base + screen_info.lfb_size;
dev = &vgadev->pdev->dev;
/* Does firmware framebuffer belong to us? */ /* Does firmware framebuffer belong to us? */
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
...@@ -1451,21 +1457,19 @@ static int __init vga_arb_device_init(void) ...@@ -1451,21 +1457,19 @@ static int __init vga_arb_device_init(void)
continue; continue;
if (!vga_default_device()) if (!vga_default_device())
pr_info("setting as boot device: PCI:%s\n", vgaarb_info(dev, "setting as boot device\n");
pci_name(vgadev->pdev));
else if (vgadev->pdev != vga_default_device()) else if (vgadev->pdev != vga_default_device())
pr_info("overriding boot device: PCI:%s\n", vgaarb_info(dev, "overriding boot device\n");
pci_name(vgadev->pdev));
vga_set_default_device(vgadev->pdev); vga_set_default_device(vgadev->pdev);
} }
#endif #endif
if (vgadev->bridge_has_one_vga) if (vgadev->bridge_has_one_vga)
pr_info("bridge control possible %s\n", vgaarb_info(dev, "bridge control possible\n");
pci_name(vgadev->pdev));
else else
pr_info("no bridge control possible %s\n", vgaarb_info(dev, "no bridge control possible\n");
pci_name(vgadev->pdev));
} }
pr_info("loaded\n");
return rc; return rc;
} }
subsys_initcall(vga_arb_device_init); subsys_initcall(vga_arb_device_init);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment