Re: [RFC 13/13] scsi: megaraid: Make use of dev_64bit_mmio_supported()
On Fri, Feb 26, 2021 at 3:30 PM Arnd Bergmann wrote: > > On Fri, Feb 26, 2021 at 3:03 PM Nicolas Saenz Julienne > wrote: > > > unsigned long flags; > > - spin_lock_irqsave(>hba_lock, flags); > > - writel(le32_to_cpu(req_desc->u.low), > > - >reg_set->inbound_low_queue_port); > > - writel(le32_to_cpu(req_desc->u.high), > > - >reg_set->inbound_high_queue_port); > > - spin_unlock_irqrestore(>hba_lock, flags); > > > + > > + if (dev_64bit_mmio_supported(>pdev->dev)) { > > + writeq(req_data, > > >reg_set->inbound_low_queue_port); > > + } else { > > + spin_lock_irqsave(>hba_lock, flags); > > + lo_hi_writeq(req_data, > > >reg_set->inbound_low_queue_port); > > + spin_unlock_irqrestore(>hba_lock, flags); > > + } > > I see your patch changes the code to the lo_hi_writeq() accessor, > and it also fixes the endianness bug (double byteswap on big-endian), > but it does not fix the spinlock bug (writel on pci leaks out of the lock > unless it's followed by a read). On second look, it seems your patch breaks the byteorder logic, rather than fixing it. It would seem better to leave it unchanged then, or to send a separate rework of the endianness conversion if you think it is wrong. Arnd
Re: [RFC 13/13] scsi: megaraid: Make use of dev_64bit_mmio_supported()
On Fri, Feb 26, 2021 at 3:03 PM Nicolas Saenz Julienne wrote: > unsigned long flags; > - spin_lock_irqsave(>hba_lock, flags); > - writel(le32_to_cpu(req_desc->u.low), > - >reg_set->inbound_low_queue_port); > - writel(le32_to_cpu(req_desc->u.high), > - >reg_set->inbound_high_queue_port); > - spin_unlock_irqrestore(>hba_lock, flags); > + > + if (dev_64bit_mmio_supported(>pdev->dev)) { > + writeq(req_data, >reg_set->inbound_low_queue_port); > + } else { > + spin_lock_irqsave(>hba_lock, flags); > + lo_hi_writeq(req_data, > >reg_set->inbound_low_queue_port); > + spin_unlock_irqrestore(>hba_lock, flags); > + } I see your patch changes the code to the lo_hi_writeq() accessor, and it also fixes the endianness bug (double byteswap on big-endian), but it does not fix the spinlock bug (writel on pci leaks out of the lock unless it's followed by a read). I'd suggest splitting the bugfix from the cleanup here, and fixing both of the bugs while you're at it. Arnd
[RFC 13/13] scsi: megaraid: Make use of dev_64bit_mmio_supported()
Instead of relying on defines use dev_64bit_mmio_supported(), which provides the same functionality. On top of that convert the implementation to lo_hi_writeq(), for a cleaner end result. Signed-off-by: Nicolas Saenz Julienne --- drivers/scsi/megaraid/megaraid_sas_fusion.c | 23 ++--- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 38fc9467c625..d4933a591330 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -259,19 +260,17 @@ static void megasas_write_64bit_req_desc(struct megasas_instance *instance, union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc) { -#if defined(writeq) && defined(CONFIG_64BIT) - u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) | - le32_to_cpu(req_desc->u.low)); - writeq(req_data, >reg_set->inbound_low_queue_port); -#else + u64 req_data = ((u64)le32_to_cpu(req_desc->u.high) << 32) | + le32_to_cpu(req_desc->u.low); unsigned long flags; - spin_lock_irqsave(>hba_lock, flags); - writel(le32_to_cpu(req_desc->u.low), - >reg_set->inbound_low_queue_port); - writel(le32_to_cpu(req_desc->u.high), - >reg_set->inbound_high_queue_port); - spin_unlock_irqrestore(>hba_lock, flags); -#endif + + if (dev_64bit_mmio_supported(>pdev->dev)) { + writeq(req_data, >reg_set->inbound_low_queue_port); + } else { + spin_lock_irqsave(>hba_lock, flags); + lo_hi_writeq(req_data, >reg_set->inbound_low_queue_port); + spin_unlock_irqrestore(>hba_lock, flags); + } } /** -- 2.30.1