On 2021/12/09 16:17, Hannes Reinecke wrote: > On 12/9/21 1:38 AM, Damien Le Moal wrote: >> On 2021/12/09 1:31, Hannes Reinecke wrote: >>> Implement module parameter 'pci_dump' and move the DPRINTK calls >>> over to dev_printk(). >>> >>> Signed-off-by: Hannes Reinecke <hare@xxxxxxx> >>> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@xxxxxxxxxxx> >>> --- >>> drivers/ata/sata_mv.c | 88 ++++++++++++++++++++++++------------------- >>> 1 file changed, 49 insertions(+), 39 deletions(-) >>> >>> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c >>> index cae4c1eab102..f0257685495f 100644 >>> --- a/drivers/ata/sata_mv.c >>> +++ b/drivers/ata/sata_mv.c >>> @@ -83,6 +83,10 @@ module_param(irq_coalescing_usecs, int, S_IRUGO); >>> MODULE_PARM_DESC(irq_coalescing_usecs, >>> "IRQ coalescing time threshold in usecs"); >>> >>> +static int pci_dump; >>> +module_param(pci_dump, int, S_IRUGO); >>> +MODULE_PARM_DESC(pci_dump, "Enable dumping of PCI registers on error"); >>> + >>> enum { >>> /* BAR's are enumerated in terms of pci_resource_start() terms */ >>> MV_PRIMARY_BAR = 0, /* offset 0x10: memory space */ >>> @@ -1248,42 +1252,43 @@ static int mv_stop_edma(struct ata_port *ap) >>> return err; >>> } >>> >>> -#ifdef ATA_DEBUG >>> -static void mv_dump_mem(void __iomem *start, unsigned bytes) >>> +static void mv_dump_mem(struct device *dev, void __iomem *start, unsigned bytes) >>> { >>> - int b, w; >>> + int b, w, o; >>> + unsigned char linebuf[38]; >>> + >>> for (b = 0; b < bytes; ) { >>> - DPRINTK("%p: ", start + b); >>> - for (w = 0; b < bytes && w < 4; w++) { >>> - printk("%08x ", readl(start + b)); >>> + for (w = 0, o = 0; b < bytes && w < 4; w++) { >>> + o += snprintf(linebuf + o, 38 - o, >>> + "%08x ", readl(start + b)); >>> b += sizeof(u32); >>> } >>> - printk("\n"); >>> + dev_printk(KERN_DEBUG, dev, "%s: %p: %s\n", >>> + __func__, start + b, linebuf); >> >> Why not dev_dbg() ? Same comment for all the prints below. >> > Because the entire thing is encapsulated by the 'pci_dump' parameter, ie > it'll be only ever called when 'pci_dump' is set. > So it feels redundant to require both, 'pci_dump' _and_ dynamic debugging. > > But I can move it over to dynamic debugging and kill the pci_dump parameter. That sounds simpler to me. > > Cheers, > > Hannes -- Damien Le Moal Western Digital Research