Skip to content

Commit

Permalink
xen-pciback: Use dev_printk() when possible
Browse files Browse the repository at this point in the history
Use dev_printk() when possible to include device and driver information in
the conventional format.

Add "#define dev_fmt" when needed to preserve DRV_NAME or KBUILD_MODNAME in
messages.

No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/r/20200527174326.254329-2-helgaas@kernel.org
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
  • Loading branch information
Bjorn Helgaas authored and Boris Ostrovsky committed May 27, 2020
1 parent 2abb65a commit 6904945
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 83 deletions.
16 changes: 9 additions & 7 deletions drivers/xen/xen-pciback/conf_space.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* Author: Ryan Wilson <hap9@epoch.ncsc.mil>
*/

#define dev_fmt(fmt) DRV_NAME ": " fmt

#include <linux/kernel.h>
#include <linux/moduleparam.h>
#include <linux/pci.h>
Expand Down Expand Up @@ -155,8 +157,8 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size,
u32 value = 0, tmp_val;

if (unlikely(verbose_request))
printk(KERN_DEBUG DRV_NAME ": %s: read %d bytes at 0x%x\n",
pci_name(dev), size, offset);
dev_printk(KERN_DEBUG, &dev->dev, "read %d bytes at 0x%x\n",
size, offset);

if (!valid_request(offset, size)) {
err = XEN_PCI_ERR_invalid_offset;
Expand Down Expand Up @@ -196,8 +198,8 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size,

out:
if (unlikely(verbose_request))
printk(KERN_DEBUG DRV_NAME ": %s: read %d bytes at 0x%x = %x\n",
pci_name(dev), size, offset, value);
dev_printk(KERN_DEBUG, &dev->dev,
"read %d bytes at 0x%x = %x\n", size, offset, value);

*ret_val = value;
return xen_pcibios_err_to_errno(err);
Expand All @@ -213,9 +215,9 @@ int xen_pcibk_config_write(struct pci_dev *dev, int offset, int size, u32 value)
int field_start, field_end;

if (unlikely(verbose_request))
printk(KERN_DEBUG
DRV_NAME ": %s: write request %d bytes at 0x%x = %x\n",
pci_name(dev), size, offset, value);
dev_printk(KERN_DEBUG, &dev->dev,
"write request %d bytes at 0x%x = %x\n", size,
offset, value);

if (!valid_request(offset, size))
return XEN_PCI_ERR_invalid_offset;
Expand Down
40 changes: 16 additions & 24 deletions drivers/xen/xen-pciback/conf_space_header.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define dev_fmt pr_fmt

#include <linux/kernel.h>
#include <linux/pci.h>
Expand Down Expand Up @@ -68,52 +69,46 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
dev_data = pci_get_drvdata(dev);
if (!pci_is_enabled(dev) && is_enable_cmd(value)) {
if (unlikely(verbose_request))
printk(KERN_DEBUG DRV_NAME ": %s: enable\n",
pci_name(dev));
dev_printk(KERN_DEBUG, &dev->dev, "enable\n");
err = pci_enable_device(dev);
if (err)
return err;
if (dev_data)
dev_data->enable_intx = 1;
} else if (pci_is_enabled(dev) && !is_enable_cmd(value)) {
if (unlikely(verbose_request))
printk(KERN_DEBUG DRV_NAME ": %s: disable\n",
pci_name(dev));
dev_printk(KERN_DEBUG, &dev->dev, "disable\n");
pci_disable_device(dev);
if (dev_data)
dev_data->enable_intx = 0;
}

if (!dev->is_busmaster && is_master_cmd(value)) {
if (unlikely(verbose_request))
printk(KERN_DEBUG DRV_NAME ": %s: set bus master\n",
pci_name(dev));
dev_printk(KERN_DEBUG, &dev->dev, "set bus master\n");
pci_set_master(dev);
} else if (dev->is_busmaster && !is_master_cmd(value)) {
if (unlikely(verbose_request))
printk(KERN_DEBUG DRV_NAME ": %s: clear bus master\n",
pci_name(dev));
dev_printk(KERN_DEBUG, &dev->dev, "clear bus master\n");
pci_clear_master(dev);
}

if (!(cmd->val & PCI_COMMAND_INVALIDATE) &&
(value & PCI_COMMAND_INVALIDATE)) {
if (unlikely(verbose_request))
printk(KERN_DEBUG
DRV_NAME ": %s: enable memory-write-invalidate\n",
pci_name(dev));
dev_printk(KERN_DEBUG, &dev->dev,
"enable memory-write-invalidate\n");
err = pci_set_mwi(dev);
if (err) {
pr_warn("%s: cannot enable memory-write-invalidate (%d)\n",
pci_name(dev), err);
dev_warn(&dev->dev, "cannot enable memory-write-invalidate (%d)\n",
err);
value &= ~PCI_COMMAND_INVALIDATE;
}
} else if ((cmd->val & PCI_COMMAND_INVALIDATE) &&
!(value & PCI_COMMAND_INVALIDATE)) {
if (unlikely(verbose_request))
printk(KERN_DEBUG
DRV_NAME ": %s: disable memory-write-invalidate\n",
pci_name(dev));
dev_printk(KERN_DEBUG, &dev->dev,
"disable memory-write-invalidate\n");
pci_clear_mwi(dev);
}

Expand Down Expand Up @@ -157,8 +152,7 @@ static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data)
struct pci_bar_info *bar = data;

if (unlikely(!bar)) {
pr_warn(DRV_NAME ": driver data not found for %s\n",
pci_name(dev));
dev_warn(&dev->dev, "driver data not found\n");
return XEN_PCI_ERR_op_failed;
}

Expand Down Expand Up @@ -194,8 +188,7 @@ static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data)
u32 mask;

if (unlikely(!bar)) {
pr_warn(DRV_NAME ": driver data not found for %s\n",
pci_name(dev));
dev_warn(&dev->dev, "driver data not found\n");
return XEN_PCI_ERR_op_failed;
}

Expand Down Expand Up @@ -228,8 +221,7 @@ static int bar_read(struct pci_dev *dev, int offset, u32 * value, void *data)
struct pci_bar_info *bar = data;

if (unlikely(!bar)) {
pr_warn(DRV_NAME ": driver data not found for %s\n",
pci_name(dev));
dev_warn(&dev->dev, "driver data not found\n");
return XEN_PCI_ERR_op_failed;
}

Expand Down Expand Up @@ -433,8 +425,8 @@ int xen_pcibk_config_header_add_fields(struct pci_dev *dev)

default:
err = -EINVAL;
pr_err("%s: Unsupported header type %d!\n",
pci_name(dev), dev->hdr_type);
dev_err(&dev->dev, "Unsupported header type %d!\n",
dev->hdr_type);
break;
}

Expand Down
6 changes: 4 additions & 2 deletions drivers/xen/xen-pciback/conf_space_quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Author: Chris Bookholt <hap10@epoch.ncsc.mil>
*/

#define dev_fmt(fmt) DRV_NAME ": " fmt

#include <linux/kernel.h>
#include <linux/pci.h>
#include "pciback.h"
Expand Down Expand Up @@ -35,8 +37,8 @@ static struct xen_pcibk_config_quirk *xen_pcibk_find_quirk(struct pci_dev *dev)
if (match_one_device(&tmp_quirk->devid, dev) != NULL)
goto out;
tmp_quirk = NULL;
printk(KERN_DEBUG DRV_NAME
": quirk didn't match any device known\n");
dev_printk(KERN_DEBUG, &dev->dev,
"quirk didn't match any device known\n");
out:
return tmp_quirk;
}
Expand Down
38 changes: 16 additions & 22 deletions drivers/xen/xen-pciback/pci_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define dev_fmt pr_fmt

#include <linux/module.h>
#include <linux/init.h>
Expand Down Expand Up @@ -626,11 +627,11 @@ static void pcistub_remove(struct pci_dev *dev)
if (found_psdev->pdev) {
int domid = xen_find_device_domain_owner(dev);

pr_warn("****** removing device %s while still in-use by domain %d! ******\n",
dev_warn(&dev->dev, "****** removing device %s while still in-use by domain %d! ******\n",
pci_name(found_psdev->dev), domid);
pr_warn("****** driver domain may still access this device's i/o resources!\n");
pr_warn("****** shutdown driver domain before binding device\n");
pr_warn("****** to other drivers or domains\n");
dev_warn(&dev->dev, "****** driver domain may still access this device's i/o resources!\n");
dev_warn(&dev->dev, "****** shutdown driver domain before binding device\n");
dev_warn(&dev->dev, "****** to other drivers or domains\n");

/* N.B. This ends up calling pcistub_put_pci_dev which ends up
* doing the FLR. */
Expand Down Expand Up @@ -711,14 +712,12 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev,
ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev,
&aer_op->domain, &aer_op->bus, &aer_op->devfn);
if (!ret) {
dev_err(&psdev->dev->dev,
DRV_NAME ": failed to get pcifront device\n");
dev_err(&psdev->dev->dev, "failed to get pcifront device\n");
return PCI_ERS_RESULT_NONE;
}
wmb();

dev_dbg(&psdev->dev->dev,
DRV_NAME ": aer_op %x dom %x bus %x devfn %x\n",
dev_dbg(&psdev->dev->dev, "aer_op %x dom %x bus %x devfn %x\n",
aer_cmd, aer_op->domain, aer_op->bus, aer_op->devfn);
/*local flag to mark there's aer request, xen_pcibk callback will use
* this flag to judge whether we need to check pci-front give aer
Expand Down Expand Up @@ -754,8 +753,7 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev,

if (test_bit(_XEN_PCIF_active,
(unsigned long *)&sh_info->flags)) {
dev_dbg(&psdev->dev->dev,
"schedule pci_conf service in " DRV_NAME "\n");
dev_dbg(&psdev->dev->dev, "schedule pci_conf service\n");
xen_pcibk_test_and_schedule_op(psdev->pdev);
}

Expand Down Expand Up @@ -786,13 +784,12 @@ static pci_ers_result_t xen_pcibk_slot_reset(struct pci_dev *dev)
PCI_FUNC(dev->devfn));

if (!psdev || !psdev->pdev) {
dev_err(&dev->dev,
DRV_NAME " device is not found/assigned\n");
dev_err(&dev->dev, "device is not found/assigned\n");
goto end;
}

if (!psdev->pdev->sh_info) {
dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
dev_err(&dev->dev, "device is not connected or owned"
" by HVM, kill it\n");
kill_domain_by_device(psdev);
goto end;
Expand Down Expand Up @@ -844,13 +841,12 @@ static pci_ers_result_t xen_pcibk_mmio_enabled(struct pci_dev *dev)
PCI_FUNC(dev->devfn));

if (!psdev || !psdev->pdev) {
dev_err(&dev->dev,
DRV_NAME " device is not found/assigned\n");
dev_err(&dev->dev, "device is not found/assigned\n");
goto end;
}

if (!psdev->pdev->sh_info) {
dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
dev_err(&dev->dev, "device is not connected or owned"
" by HVM, kill it\n");
kill_domain_by_device(psdev);
goto end;
Expand Down Expand Up @@ -902,13 +898,12 @@ static pci_ers_result_t xen_pcibk_error_detected(struct pci_dev *dev,
PCI_FUNC(dev->devfn));

if (!psdev || !psdev->pdev) {
dev_err(&dev->dev,
DRV_NAME " device is not found/assigned\n");
dev_err(&dev->dev, "device is not found/assigned\n");
goto end;
}

if (!psdev->pdev->sh_info) {
dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
dev_err(&dev->dev, "device is not connected or owned"
" by HVM, kill it\n");
kill_domain_by_device(psdev);
goto end;
Expand Down Expand Up @@ -956,13 +951,12 @@ static void xen_pcibk_error_resume(struct pci_dev *dev)
PCI_FUNC(dev->devfn));

if (!psdev || !psdev->pdev) {
dev_err(&dev->dev,
DRV_NAME " device is not found/assigned\n");
dev_err(&dev->dev, "device is not found/assigned\n");
goto end;
}

if (!psdev->pdev->sh_info) {
dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
dev_err(&dev->dev, "device is not connected or owned"
" by HVM, kill it\n");
kill_domain_by_device(psdev);
goto end;
Expand Down
Loading

0 comments on commit 6904945

Please sign in to comment.