All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
@ 2018-01-26 12:53 Huacai Chen
  2018-03-01  5:59 ` 陈华才
  0 siblings, 1 reply; 6+ messages in thread
From: Huacai Chen @ 2018-01-26 12:53 UTC (permalink / raw)
  To: James Smart, Dick Kennedy
  Cc: James E . J . Bottomley, Martin K . Petersen, Fuxin Zhang,
	linux-scsi, Huacai Chen, stable

In commit bc73905abf770192 ("[SCSI] lpfc 8.3.16: SLI Additions, updates,
and code cleanup"), lpfc_memcpy_to_slim() have switched memcpy_toio() to
__write32_copy() in order to prevent unaligned 64 bit copy. Recently, we
found that lpfc_memcpy_from_slim() have similar issues, so let it switch
memcpy_fromio() to __read32_copy().

Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 drivers/scsi/lpfc/lpfc_compat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_compat.h b/drivers/scsi/lpfc/lpfc_compat.h
index 6b32b0a..47d4fad 100644
--- a/drivers/scsi/lpfc/lpfc_compat.h
+++ b/drivers/scsi/lpfc/lpfc_compat.h
@@ -91,8 +91,8 @@ lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
 static inline void
 lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
 {
-	/* actually returns 1 byte past dest */
-	memcpy_fromio( dest, src, bytes);
+	/* convert bytes in argument list to word count for copy function */
+	__ioread32_copy(dest, src, bytes / sizeof(uint32_t));
 }
 
 #endif	/* __BIG_ENDIAN */
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re:[PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
  2018-01-26 12:53 [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy() Huacai Chen
@ 2018-03-01  5:59 ` 陈华才
  2018-03-05  6:56   ` 陈华才
  0 siblings, 1 reply; 6+ messages in thread
From: 陈华才 @ 2018-03-01  5:59 UTC (permalink / raw)
  To: James Smart, Dick Kennedy
  Cc: James E . J . Bottomley, Martin K . Petersen, Fuxin Zhang,
	linux-scsi, stable

Ping?
 
------------------ Original ------------------
From:  "Huacai Chen"<chenhc@lemote.com>;
Date:  Fri, Jan 26, 2018 08:53 PM
To:  "James Smart"<james.smart@broadcom.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "Huacai Chen"<chenhc@lemote.com>; "stable"<stable@vger.kernel.org>;
Subject:  [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
 
In commit bc73905abf770192 ("[SCSI] lpfc 8.3.16: SLI Additions, updates,
and code cleanup"), lpfc_memcpy_to_slim() have switched memcpy_toio() to
__write32_copy() in order to prevent unaligned 64 bit copy. Recently, we
found that lpfc_memcpy_from_slim() have similar issues, so let it switch
memcpy_fromio() to __read32_copy().

Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 drivers/scsi/lpfc/lpfc_compat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_compat.h b/drivers/scsi/lpfc/lpfc_compat.h
index 6b32b0a..47d4fad 100644
--- a/drivers/scsi/lpfc/lpfc_compat.h
+++ b/drivers/scsi/lpfc/lpfc_compat.h
@@ -91,8 +91,8 @@ lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
 static inline void
 lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
 {
-	/* actually returns 1 byte past dest */
-	memcpy_fromio( dest, src, bytes);
+	/* convert bytes in argument list to word count for copy function */
+	__ioread32_copy(dest, src, bytes / sizeof(uint32_t));
 }
 
 #endif	/* __BIG_ENDIAN */
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re:[PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
  2018-03-01  5:59 ` 陈华才
@ 2018-03-05  6:56   ` 陈华才
  2018-03-05 15:37     ` [PATCH] " James Smart
  0 siblings, 1 reply; 6+ messages in thread
From: 陈华才 @ 2018-03-05  6:56 UTC (permalink / raw)
  To: James Smart, Dick Kennedy
  Cc: James E . J . Bottomley, Martin K . Petersen, Fuxin Zhang,
	linux-scsi, stable

No one has the same problem? Or this patch need improve?

Huacai
 
------------------ Original ------------------
From:  "陈华才"<chenhc@lemote.com>;
Date:  Thu, Mar 1, 2018 01:59 PM
To:  "James Smart"<james.smart@broadcom.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "stable"<stable@vger.kernel.org>;
Subject:  Re:[PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
 
Ping?
 
------------------ Original ------------------
From:  "Huacai Chen"<chenhc@lemote.com>;
Date:  Fri, Jan 26, 2018 08:53 PM
To:  "James Smart"<james.smart@broadcom.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "Huacai Chen"<chenhc@lemote.com>; "stable"<stable@vger.kernel.org>;
Subject:  [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
 
In commit bc73905abf770192 ("[SCSI] lpfc 8.3.16: SLI Additions, updates,
and code cleanup"), lpfc_memcpy_to_slim() have switched memcpy_toio() to
__write32_copy() in order to prevent unaligned 64 bit copy. Recently, we
found that lpfc_memcpy_from_slim() have similar issues, so let it switch
memcpy_fromio() to __read32_copy().

Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 drivers/scsi/lpfc/lpfc_compat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_compat.h b/drivers/scsi/lpfc/lpfc_compat.h
index 6b32b0a..47d4fad 100644
--- a/drivers/scsi/lpfc/lpfc_compat.h
+++ b/drivers/scsi/lpfc/lpfc_compat.h
@@ -91,8 +91,8 @@ lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
 static inline void
 lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
 {
-	/* actually returns 1 byte past dest */
-	memcpy_fromio( dest, src, bytes);
+	/* convert bytes in argument list to word count for copy function */
+	__ioread32_copy(dest, src, bytes / sizeof(uint32_t));
 }
 
 #endif	/* __BIG_ENDIAN */
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
  2018-03-05  6:56   ` 陈华才
@ 2018-03-05 15:37     ` James Smart
  2018-03-06  1:19       ` 陈华才
  2018-07-09  1:36       ` 陈华才
  0 siblings, 2 replies; 6+ messages in thread
From: James Smart @ 2018-03-05 15:37 UTC (permalink / raw)
  To: 陈华才, Dick Kennedy
  Cc: James E . J . Bottomley, Martin K . Petersen, Fuxin Zhang,
	linux-scsi, stable


On 3/4/2018 10:56 PM, 陈华才 wrote:
> No one has the same problem? Or this patch need improve?
>
> Huacai
>   
> ------------------ Original ------------------
> From:  "陈华才"<chenhc@lemote.com>;
> Date:  Thu, Mar 1, 2018 01:59 PM
> To:  "James Smart"<james.smart@broadcom.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
> Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "stable"<stable@vger.kernel.org>;
> Subject:  Re:[PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
>   
> Ping?
>   
> ------------------ Original ------------------
> From:  "Huacai Chen"<chenhc@lemote.com>;
> Date:  Fri, Jan 26, 2018 08:53 PM
> To:  "James Smart"<james.smart@broadcom.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
> Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "Huacai Chen"<chenhc@lemote.com>; "stable"<stable@vger.kernel.org>;
> Subject:  [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
>   
> In commit bc73905abf770192 ("[SCSI] lpfc 8.3.16: SLI Additions, updates,
> and code cleanup"), lpfc_memcpy_to_slim() have switched memcpy_toio() to
> __write32_copy() in order to prevent unaligned 64 bit copy. Recently, we
> found that lpfc_memcpy_from_slim() have similar issues, so let it switch
> memcpy_fromio() to __read32_copy().
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> ---
>   drivers/scsi/lpfc/lpfc_compat.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_compat.h b/drivers/scsi/lpfc/lpfc_compat.h
> index 6b32b0a..47d4fad 100644
> --- a/drivers/scsi/lpfc/lpfc_compat.h
> +++ b/drivers/scsi/lpfc/lpfc_compat.h
> @@ -91,8 +91,8 @@ lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
>   static inline void
>   lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
>   {
> -	/* actually returns 1 byte past dest */
> -	memcpy_fromio( dest, src, bytes);
> +	/* convert bytes in argument list to word count for copy function */
> +	__ioread32_copy(dest, src, bytes / sizeof(uint32_t));
>   }
>   
>   #endif	/* __BIG_ENDIAN */

Huacai,

Note: the original change was 7 yrs ago and we've had no reports of 
issues. but....

This change didn't look necessary as the memcpy_XXXio() should allow 
byte alignments and byte-based lengths. Which means the original patch 
also wasn't necessary, which implies that the platform that had the 
issues has an api restriction not normally found on the other platforms.

I have no problem with the change though.

-- james

Signed-off-by: James Smart  <james.smart@broadcom.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
  2018-03-05 15:37     ` [PATCH] " James Smart
@ 2018-03-06  1:19       ` 陈华才
  2018-07-09  1:36       ` 陈华才
  1 sibling, 0 replies; 6+ messages in thread
From: 陈华才 @ 2018-03-06  1:19 UTC (permalink / raw)
  To: James Smart, Dick Kennedy
  Cc: James E . J . Bottomley, Martin K . Petersen, Fuxin Zhang,
	linux-scsi, stable

Hi, James,

At least on MIPS (Loongson-3), we found that this patch is necessary.
 
Huacai

------------------ Original ------------------
From:  "James Smart"<james.smart@broadcom.com>;
Date:  Mon, Mar 5, 2018 11:37 PM
To:  "陈华才"<chenhc@lemote.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "stable"<stable@vger.kernel.org>;
Subject:  Re: [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
 

On 3/4/2018 10:56 PM, 陈华才 wrote:
> No one has the same problem? Or this patch need improve?
>
> Huacai
>   
> ------------------ Original ------------------
> From:  "陈华才"<chenhc@lemote.com>;
> Date:  Thu, Mar 1, 2018 01:59 PM
> To:  "James Smart"<james.smart@broadcom.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
> Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "stable"<stable@vger.kernel.org>;
> Subject:  Re:[PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
>   
> Ping?
>   
> ------------------ Original ------------------
> From:  "Huacai Chen"<chenhc@lemote.com>;
> Date:  Fri, Jan 26, 2018 08:53 PM
> To:  "James Smart"<james.smart@broadcom.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
> Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "Huacai Chen"<chenhc@lemote.com>; "stable"<stable@vger.kernel.org>;
> Subject:  [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
>   
> In commit bc73905abf770192 ("[SCSI] lpfc 8.3.16: SLI Additions, updates,
> and code cleanup"), lpfc_memcpy_to_slim() have switched memcpy_toio() to
> __write32_copy() in order to prevent unaligned 64 bit copy. Recently, we
> found that lpfc_memcpy_from_slim() have similar issues, so let it switch
> memcpy_fromio() to __read32_copy().
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> ---
>   drivers/scsi/lpfc/lpfc_compat.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_compat.h b/drivers/scsi/lpfc/lpfc_compat.h
> index 6b32b0a..47d4fad 100644
> --- a/drivers/scsi/lpfc/lpfc_compat.h
> +++ b/drivers/scsi/lpfc/lpfc_compat.h
> @@ -91,8 +91,8 @@ lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
>   static inline void
>   lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
>   {
> -	/* actually returns 1 byte past dest */
> -	memcpy_fromio( dest, src, bytes);
> +	/* convert bytes in argument list to word count for copy function */
> +	__ioread32_copy(dest, src, bytes / sizeof(uint32_t));
>   }
>   
>   #endif	/* __BIG_ENDIAN */

Huacai,

Note: the original change was 7 yrs ago and we've had no reports of 
issues. but....

This change didn't look necessary as the memcpy_XXXio() should allow 
byte alignments and byte-based lengths. Which means the original patch 
also wasn't necessary, which implies that the platform that had the 
issues has an api restriction not normally found on the other platforms.

I have no problem with the change though.

-- james

Signed-off-by: James Smart  <james.smart@broadcom.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
  2018-03-05 15:37     ` [PATCH] " James Smart
  2018-03-06  1:19       ` 陈华才
@ 2018-07-09  1:36       ` 陈华才
  1 sibling, 0 replies; 6+ messages in thread
From: 陈华才 @ 2018-07-09  1:36 UTC (permalink / raw)
  To: James Smart, Dick Kennedy
  Cc: James E . J . Bottomley, Martin K . Petersen, Fuxin Zhang,
	linux-scsi, stable

Hi, James,

I think I found the root cause: lpfc's device memory doesn't support 128bit load/store. But Loongson-3's optimised memcpy() will use 128bit load/store instructions (gslq/gssq). So is this patch neccesory to avoid 128bit memory access (maybe there are other platforms have the same problem)?
 
Huacai
 
------------------ Original ------------------
From:  "James Smart"<james.smart@broadcom.com>;
Date:  Mon, Mar 5, 2018 11:37 PM
To:  "陈华才"<chenhc@lemote.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "stable"<stable@vger.kernel.org>;
Subject:  Re: [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
 

On 3/4/2018 10:56 PM, 陈华才 wrote:
> No one has the same problem? Or this patch need improve?
>
> Huacai
>   
> ------------------ Original ------------------
> From:  "陈华才"<chenhc@lemote.com>;
> Date:  Thu, Mar 1, 2018 01:59 PM
> To:  "James Smart"<james.smart@broadcom.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
> Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "stable"<stable@vger.kernel.org>;
> Subject:  Re:[PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
>   
> Ping?
>   
> ------------------ Original ------------------
> From:  "Huacai Chen"<chenhc@lemote.com>;
> Date:  Fri, Jan 26, 2018 08:53 PM
> To:  "James Smart"<james.smart@broadcom.com>; "Dick Kennedy"<dick.kennedy@broadcom.com>;
> Cc:  "James E . J . Bottomley"<jejb@linux.vnet.ibm.com>; "Martin K . Petersen"<martin.petersen@oracle.com>; "Fuxin Zhang"<zhangfx@lemote.com>; "linux-scsi"<linux-scsi@vger.kernel.org>; "Huacai Chen"<chenhc@lemote.com>; "stable"<stable@vger.kernel.org>;
> Subject:  [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy()
>   
> In commit bc73905abf770192 ("[SCSI] lpfc 8.3.16: SLI Additions, updates,
> and code cleanup"), lpfc_memcpy_to_slim() have switched memcpy_toio() to
> __write32_copy() in order to prevent unaligned 64 bit copy. Recently, we
> found that lpfc_memcpy_from_slim() have similar issues, so let it switch
> memcpy_fromio() to __read32_copy().
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> ---
>   drivers/scsi/lpfc/lpfc_compat.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_compat.h b/drivers/scsi/lpfc/lpfc_compat.h
> index 6b32b0a..47d4fad 100644
> --- a/drivers/scsi/lpfc/lpfc_compat.h
> +++ b/drivers/scsi/lpfc/lpfc_compat.h
> @@ -91,8 +91,8 @@ lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
>   static inline void
>   lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
>   {
> -	/* actually returns 1 byte past dest */
> -	memcpy_fromio( dest, src, bytes);
> +	/* convert bytes in argument list to word count for copy function */
> +	__ioread32_copy(dest, src, bytes / sizeof(uint32_t));
>   }
>   
>   #endif	/* __BIG_ENDIAN */

Huacai,

Note: the original change was 7 yrs ago and we've had no reports of 
issues. but....

This change didn't look necessary as the memcpy_XXXio() should allow 
byte alignments and byte-based lengths. Which means the original patch 
also wasn't necessary, which implies that the platform that had the 
issues has an api restriction not normally found on the other platforms.

I have no problem with the change though.

-- james

Signed-off-by: James Smart  <james.smart@broadcom.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-09  1:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26 12:53 [PATCH] scsi: lpfc: Switch memcpy_fromio() to __read32_copy() Huacai Chen
2018-03-01  5:59 ` 陈华才
2018-03-05  6:56   ` 陈华才
2018-03-05 15:37     ` [PATCH] " James Smart
2018-03-06  1:19       ` 陈华才
2018-07-09  1:36       ` 陈华才

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.