diff mbox

[v2] lpfc: use __raw_writeX on DPP copies

Message ID 20180305182903.21583-1-jsmart2021@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

James Smart March 5, 2018, 6:29 p.m. UTC
This patch replaces:
https://www.spinics.net/lists/linux-scsi/msg117838.html

A prior lpfc patch:
scsi: lpfc: Add push-to-adapter support to sli4
commitid=1351e69fc6db30e186295f1c9495d03cef6a01a2

Fails compilation on some 32-bit systems as writeq() is not supported
on all architectures. Additionally, it was pointed out that as writeX()
does byteswapping if necessary for pci vs the cpu endianness, the code
was broken on BE PPC.

After discussions with Arnd Bergmann, we've resolved the issue
to the following:
  Instead of writeX(), use __raw_writeX() - which writes to io
    space while preserving byte order. To use this, the code
    was changed to use a different buffer that lpfc prepped
    via sli_pcimem_bcopy() that was set to the bytestream to
    be written.
  On platforms with __raw_writeq support, use the routine, otherwise
    use __raw_writel()

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>

---
v2:
  check for __raw_writeq defined, instead of CONFIG_64bit
    allows 32bit platforms with support to use it.
---
 drivers/scsi/lpfc/lpfc_sli.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Arnd Bergmann March 5, 2018, 7:23 p.m. UTC | #1
On Mon, Mar 5, 2018 at 7:29 PM, James Smart <jsmart2021@gmail.com> wrote:
> This patch replaces:
> https://www.spinics.net/lists/linux-scsi/msg117838.html
>
> A prior lpfc patch:
> scsi: lpfc: Add push-to-adapter support to sli4
> commitid=1351e69fc6db30e186295f1c9495d03cef6a01a2
>
> Fails compilation on some 32-bit systems as writeq() is not supported
> on all architectures. Additionally, it was pointed out that as writeX()
> does byteswapping if necessary for pci vs the cpu endianness, the code
> was broken on BE PPC.
>
> After discussions with Arnd Bergmann, we've resolved the issue
> to the following:
>   Instead of writeX(), use __raw_writeX() - which writes to io
>     space while preserving byte order. To use this, the code
>     was changed to use a different buffer that lpfc prepped
>     via sli_pcimem_bcopy() that was set to the bytestream to
>     be written.
>   On platforms with __raw_writeq support, use the routine, otherwise
>     use __raw_writel()
>
> Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
> Signed-off-by: James Smart <james.smart@broadcom.com>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

It would be interesting to try this version on powerpc64 as well (with
a patch to use ioremap_wc() an d set dpp_enable), the lack of "sync"
style barriers in __raw_writel should make it much faster than the old
version.

       Arnd
Martin K. Petersen March 7, 2018, 2:32 a.m. UTC | #2
James,

Minor patch formatting nits:

> This patch replaces:
> https://www.spinics.net/lists/linux-scsi/msg117838.html

Patch revision commentary needs to go below the "---" delimiter so it
doesn't end up in the commit description.

> A prior lpfc patch:
> scsi: lpfc: Add push-to-adapter support to sli4
> commitid=1351e69fc6db30e186295f1c9495d03cef6a01a2

This should be formatted as:

Commit 1351e69fc6db ("scsi: lpfc: Add push-to-adapter support to sli4")
fails compilation...

And the following should be added to the tags section:

Fixes: 1351e69fc6db ("scsi: lpfc: Add push-to-adapter support to sli4")


I fixed things up and applied to 4.17/scsi-queue.

Thanks!
diff mbox

Patch

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 4ce3ca6f4b79..d20cf51ca15d 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -140,9 +140,16 @@  lpfc_sli4_wq_put(struct lpfc_queue *q, union lpfc_wqe *wqe)
 	lpfc_sli_pcimem_bcopy(wqe, temp_wqe, q->entry_size);
 	if (q->dpp_enable && q->phba->cfg_enable_dpp) {
 		/* write to DPP aperture taking advatage of Combined Writes */
-		tmp = (uint8_t *)wqe;
+		tmp = (uint8_t *)temp_wqe;
+#ifdef __raw_writeq
 		for (i = 0; i < q->entry_size; i += sizeof(uint64_t))
-			writeq(*((uint64_t *)(tmp + i)), q->dpp_regaddr + i);
+			__raw_writeq(*((uint64_t *)(tmp + i)),
+					q->dpp_regaddr + i);
+#else
+		for (i = 0; i < q->entry_size; i += sizeof(uint32_t))
+			__raw_writel(*((uint32_t *)(tmp + i)),
+					q->dpp_regaddr + i);
+#endif
 	}
 	/* ensure WQE bcopy and DPP flushed before doorbell write */
 	wmb();