All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 0/2] scatterlist: add I/O variant of sg_pcopy & sg_copy and use them
@ 2021-06-28 12:34 ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-06-28 12:34 UTC (permalink / raw)
  To: jgg, leon, m.szyprowski, robin.murphy, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel, Neil Armstrong

A local variant of sg_copy_buffer has been introduced in the meson-gx mmc driver [1] after
a mempcy optimization, fixing the iomem buffer manipulation and the reported system crash [2].

But, the fix is suboptimal in terms of performace/ugliness [3] and a proper I/O variant of
sg_copy_buffer should be added and used instead.

[1] https://lore.kernel.org/r/20210609150230.9291-1-narmstrong@baylibre.com
[2] https://lore.kernel.org/r/acb244ad-0759-5a96-c659-5c23003d3dcd@samsung.com
[3] https://lore.kernel.org/r/CAPDyKFrLSMpPJOgd5e4B1x3Vwfg4q23zgy4ESc8EmFL2MnyK7g@mail.gmail.com

Neil Armstrong (2):
  scatterlist: add I/O variant of sg_pcopy & sg_copy
  mmc: meson-gx: use sg_copy_to/from_io instead of local version

 drivers/mmc/host/meson-gx-mmc.c |  53 +++-----------
 include/linux/scatterlist.h     |  14 ++++
 lib/scatterlist.c               | 119 ++++++++++++++++++++++++++++++++
 3 files changed, 143 insertions(+), 43 deletions(-)

-- 
2.25.1


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

* [PATCH RFC 0/2] scatterlist: add I/O variant of sg_pcopy & sg_copy and use them
@ 2021-06-28 12:34 ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-06-28 12:34 UTC (permalink / raw)
  To: jgg, leon, m.szyprowski, robin.murphy, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel, Neil Armstrong

A local variant of sg_copy_buffer has been introduced in the meson-gx mmc driver [1] after
a mempcy optimization, fixing the iomem buffer manipulation and the reported system crash [2].

But, the fix is suboptimal in terms of performace/ugliness [3] and a proper I/O variant of
sg_copy_buffer should be added and used instead.

[1] https://lore.kernel.org/r/20210609150230.9291-1-narmstrong@baylibre.com
[2] https://lore.kernel.org/r/acb244ad-0759-5a96-c659-5c23003d3dcd@samsung.com
[3] https://lore.kernel.org/r/CAPDyKFrLSMpPJOgd5e4B1x3Vwfg4q23zgy4ESc8EmFL2MnyK7g@mail.gmail.com

Neil Armstrong (2):
  scatterlist: add I/O variant of sg_pcopy & sg_copy
  mmc: meson-gx: use sg_copy_to/from_io instead of local version

 drivers/mmc/host/meson-gx-mmc.c |  53 +++-----------
 include/linux/scatterlist.h     |  14 ++++
 lib/scatterlist.c               | 119 ++++++++++++++++++++++++++++++++
 3 files changed, 143 insertions(+), 43 deletions(-)

-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH RFC 0/2] scatterlist: add I/O variant of sg_pcopy & sg_copy and use them
@ 2021-06-28 12:34 ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-06-28 12:34 UTC (permalink / raw)
  To: jgg, leon, m.szyprowski, robin.murphy, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel, Neil Armstrong

A local variant of sg_copy_buffer has been introduced in the meson-gx mmc driver [1] after
a mempcy optimization, fixing the iomem buffer manipulation and the reported system crash [2].

But, the fix is suboptimal in terms of performace/ugliness [3] and a proper I/O variant of
sg_copy_buffer should be added and used instead.

[1] https://lore.kernel.org/r/20210609150230.9291-1-narmstrong@baylibre.com
[2] https://lore.kernel.org/r/acb244ad-0759-5a96-c659-5c23003d3dcd@samsung.com
[3] https://lore.kernel.org/r/CAPDyKFrLSMpPJOgd5e4B1x3Vwfg4q23zgy4ESc8EmFL2MnyK7g@mail.gmail.com

Neil Armstrong (2):
  scatterlist: add I/O variant of sg_pcopy & sg_copy
  mmc: meson-gx: use sg_copy_to/from_io instead of local version

 drivers/mmc/host/meson-gx-mmc.c |  53 +++-----------
 include/linux/scatterlist.h     |  14 ++++
 lib/scatterlist.c               | 119 ++++++++++++++++++++++++++++++++
 3 files changed, 143 insertions(+), 43 deletions(-)

-- 
2.25.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy
  2021-06-28 12:34 ` Neil Armstrong
  (?)
@ 2021-06-28 12:34   ` Neil Armstrong
  -1 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-06-28 12:34 UTC (permalink / raw)
  To: jgg, leon, m.szyprowski, robin.murphy, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel, Neil Armstrong

When copying from/to an iomem mapped memory, the current sg_copy & sg_pcopy can't
be used and lead to local variants in drivers like in [1] & [2].

This introduces an I/O variant to be used instead of the local variants.

[1] mv_cesa_sg_copy in drivers/crypto/marvell/cesa/tdma.c
[2] meson_mmc_copy_buffer in drivers/mmc/host/meson-gx-mmc.c

Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 include/linux/scatterlist.h |  14 +++++
 lib/scatterlist.c           | 119 ++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 6f70572b2938..6ef339ba5290 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -308,15 +308,29 @@ void sgl_free(struct scatterlist *sgl);
 size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
 		      size_t buflen, off_t skip, bool to_buffer);
 
+size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
+		  size_t buflen, off_t skip, bool to_buffer);
+
 size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
 			   const void *buf, size_t buflen);
 size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 			 void *buf, size_t buflen);
 
+size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
+		       const void __iomem *buf, size_t buflen);
+size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
+		     void __iomem *buf, size_t buflen);
+
 size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
 			    const void *buf, size_t buflen, off_t skip);
 size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 			  void *buf, size_t buflen, off_t skip);
+
+size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
+			const void __iomem *buf, size_t buflen, off_t skip);
+size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
+		      void __iomem *buf, size_t buflen, off_t skip);
+
 size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents,
 		       size_t buflen, off_t skip);
 
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index a59778946404..e52f37b181fa 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -954,6 +954,55 @@ size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
 }
 EXPORT_SYMBOL(sg_copy_buffer);
 
+/**
+ * sg_copy_io - Copy data between an I/O mapped buffer and an SG list
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy from
+ * @buflen:		 The number of bytes to copy
+ * @skip:		 Number of bytes to skip before copying
+ * @to_buffer:		 transfer direction (true == from an sg list to a
+ *			 buffer, false == from a buffer to an sg list)
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
+		  size_t buflen, off_t skip, bool to_buffer)
+{
+	unsigned int offset = 0;
+	struct sg_mapping_iter miter;
+	unsigned int sg_flags = SG_MITER_ATOMIC;
+
+	if (to_buffer)
+		sg_flags |= SG_MITER_FROM_SG;
+	else
+		sg_flags |= SG_MITER_TO_SG;
+
+	sg_miter_start(&miter, sgl, nents, sg_flags);
+
+	if (!sg_miter_skip(&miter, skip))
+		return 0;
+
+	while ((offset < buflen) && sg_miter_next(&miter)) {
+		unsigned int len;
+
+		len = min(miter.length, buflen - offset);
+
+		if (to_buffer)
+			memcpy_toio(buf + offset, miter.addr, len);
+		else
+			memcpy_fromio(miter.addr, buf + offset, len);
+
+		offset += len;
+	}
+
+	sg_miter_stop(&miter);
+
+	return offset;
+}
+EXPORT_SYMBOL(sg_copy_io);
+
 /**
  * sg_copy_from_buffer - Copy from a linear buffer to an SG list
  * @sgl:		 The SG list
@@ -988,6 +1037,40 @@ size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 }
 EXPORT_SYMBOL(sg_copy_to_buffer);
 
+/**
+ * sg_copy_from_io - Copy from an I/O mapped buffer to an SG list
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy from
+ * @buflen:		 The number of bytes to copy
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
+		       const void *buf, size_t buflen)
+{
+	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, 0, false);
+}
+EXPORT_SYMBOL(sg_copy_from_io);
+
+/**
+ * sg_copy_to_io - Copy from an SG list to an I/O mapped buffer
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy to
+ * @buflen:		 The number of bytes to copy
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
+		     void __iomem *buf, size_t buflen)
+{
+	return sg_copy_io(sgl, nents, buf, buflen, 0, true);
+}
+EXPORT_SYMBOL(sg_copy_to_io);
+
 /**
  * sg_pcopy_from_buffer - Copy from a linear buffer to an SG list
  * @sgl:		 The SG list
@@ -1024,6 +1107,42 @@ size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 }
 EXPORT_SYMBOL(sg_pcopy_to_buffer);
 
+/**
+ * sg_pcopy_from_io - Copy from an I/O mapped buffer to an SG list
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy from
+ * @buflen:		 The number of bytes to copy
+ * @skip:		 Number of bytes to skip before copying
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
+			const void __iomem *buf, size_t buflen, off_t skip)
+{
+	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, skip, false);
+}
+EXPORT_SYMBOL(sg_pcopy_from_io);
+
+/**
+ * sg_pcopy_to_io - Copy from an SG list to an I/O mapped buffer
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy to
+ * @buflen:		 The number of bytes to copy
+ * @skip:		 Number of bytes to skip before copying
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
+		      void __iomem *buf, size_t buflen, off_t skip)
+{
+	return sg_copy_io(sgl, nents, buf, buflen, skip, true);
+}
+EXPORT_SYMBOL(sg_pcopy_to_io);
+
 /**
  * sg_zero_buffer - Zero-out a part of a SG list
  * @sgl:		 The SG list
-- 
2.25.1


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

* [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy
@ 2021-06-28 12:34   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-06-28 12:34 UTC (permalink / raw)
  To: jgg, leon, m.szyprowski, robin.murphy, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel, Neil Armstrong

When copying from/to an iomem mapped memory, the current sg_copy & sg_pcopy can't
be used and lead to local variants in drivers like in [1] & [2].

This introduces an I/O variant to be used instead of the local variants.

[1] mv_cesa_sg_copy in drivers/crypto/marvell/cesa/tdma.c
[2] meson_mmc_copy_buffer in drivers/mmc/host/meson-gx-mmc.c

Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 include/linux/scatterlist.h |  14 +++++
 lib/scatterlist.c           | 119 ++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 6f70572b2938..6ef339ba5290 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -308,15 +308,29 @@ void sgl_free(struct scatterlist *sgl);
 size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
 		      size_t buflen, off_t skip, bool to_buffer);
 
+size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
+		  size_t buflen, off_t skip, bool to_buffer);
+
 size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
 			   const void *buf, size_t buflen);
 size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 			 void *buf, size_t buflen);
 
+size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
+		       const void __iomem *buf, size_t buflen);
+size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
+		     void __iomem *buf, size_t buflen);
+
 size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
 			    const void *buf, size_t buflen, off_t skip);
 size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 			  void *buf, size_t buflen, off_t skip);
+
+size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
+			const void __iomem *buf, size_t buflen, off_t skip);
+size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
+		      void __iomem *buf, size_t buflen, off_t skip);
+
 size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents,
 		       size_t buflen, off_t skip);
 
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index a59778946404..e52f37b181fa 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -954,6 +954,55 @@ size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
 }
 EXPORT_SYMBOL(sg_copy_buffer);
 
+/**
+ * sg_copy_io - Copy data between an I/O mapped buffer and an SG list
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy from
+ * @buflen:		 The number of bytes to copy
+ * @skip:		 Number of bytes to skip before copying
+ * @to_buffer:		 transfer direction (true == from an sg list to a
+ *			 buffer, false == from a buffer to an sg list)
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
+		  size_t buflen, off_t skip, bool to_buffer)
+{
+	unsigned int offset = 0;
+	struct sg_mapping_iter miter;
+	unsigned int sg_flags = SG_MITER_ATOMIC;
+
+	if (to_buffer)
+		sg_flags |= SG_MITER_FROM_SG;
+	else
+		sg_flags |= SG_MITER_TO_SG;
+
+	sg_miter_start(&miter, sgl, nents, sg_flags);
+
+	if (!sg_miter_skip(&miter, skip))
+		return 0;
+
+	while ((offset < buflen) && sg_miter_next(&miter)) {
+		unsigned int len;
+
+		len = min(miter.length, buflen - offset);
+
+		if (to_buffer)
+			memcpy_toio(buf + offset, miter.addr, len);
+		else
+			memcpy_fromio(miter.addr, buf + offset, len);
+
+		offset += len;
+	}
+
+	sg_miter_stop(&miter);
+
+	return offset;
+}
+EXPORT_SYMBOL(sg_copy_io);
+
 /**
  * sg_copy_from_buffer - Copy from a linear buffer to an SG list
  * @sgl:		 The SG list
@@ -988,6 +1037,40 @@ size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 }
 EXPORT_SYMBOL(sg_copy_to_buffer);
 
+/**
+ * sg_copy_from_io - Copy from an I/O mapped buffer to an SG list
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy from
+ * @buflen:		 The number of bytes to copy
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
+		       const void *buf, size_t buflen)
+{
+	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, 0, false);
+}
+EXPORT_SYMBOL(sg_copy_from_io);
+
+/**
+ * sg_copy_to_io - Copy from an SG list to an I/O mapped buffer
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy to
+ * @buflen:		 The number of bytes to copy
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
+		     void __iomem *buf, size_t buflen)
+{
+	return sg_copy_io(sgl, nents, buf, buflen, 0, true);
+}
+EXPORT_SYMBOL(sg_copy_to_io);
+
 /**
  * sg_pcopy_from_buffer - Copy from a linear buffer to an SG list
  * @sgl:		 The SG list
@@ -1024,6 +1107,42 @@ size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 }
 EXPORT_SYMBOL(sg_pcopy_to_buffer);
 
+/**
+ * sg_pcopy_from_io - Copy from an I/O mapped buffer to an SG list
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy from
+ * @buflen:		 The number of bytes to copy
+ * @skip:		 Number of bytes to skip before copying
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
+			const void __iomem *buf, size_t buflen, off_t skip)
+{
+	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, skip, false);
+}
+EXPORT_SYMBOL(sg_pcopy_from_io);
+
+/**
+ * sg_pcopy_to_io - Copy from an SG list to an I/O mapped buffer
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy to
+ * @buflen:		 The number of bytes to copy
+ * @skip:		 Number of bytes to skip before copying
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
+		      void __iomem *buf, size_t buflen, off_t skip)
+{
+	return sg_copy_io(sgl, nents, buf, buflen, skip, true);
+}
+EXPORT_SYMBOL(sg_pcopy_to_io);
+
 /**
  * sg_zero_buffer - Zero-out a part of a SG list
  * @sgl:		 The SG list
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy
@ 2021-06-28 12:34   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-06-28 12:34 UTC (permalink / raw)
  To: jgg, leon, m.szyprowski, robin.murphy, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel, Neil Armstrong

When copying from/to an iomem mapped memory, the current sg_copy & sg_pcopy can't
be used and lead to local variants in drivers like in [1] & [2].

This introduces an I/O variant to be used instead of the local variants.

[1] mv_cesa_sg_copy in drivers/crypto/marvell/cesa/tdma.c
[2] meson_mmc_copy_buffer in drivers/mmc/host/meson-gx-mmc.c

Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 include/linux/scatterlist.h |  14 +++++
 lib/scatterlist.c           | 119 ++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 6f70572b2938..6ef339ba5290 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -308,15 +308,29 @@ void sgl_free(struct scatterlist *sgl);
 size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
 		      size_t buflen, off_t skip, bool to_buffer);
 
+size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
+		  size_t buflen, off_t skip, bool to_buffer);
+
 size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
 			   const void *buf, size_t buflen);
 size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 			 void *buf, size_t buflen);
 
+size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
+		       const void __iomem *buf, size_t buflen);
+size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
+		     void __iomem *buf, size_t buflen);
+
 size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
 			    const void *buf, size_t buflen, off_t skip);
 size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 			  void *buf, size_t buflen, off_t skip);
+
+size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
+			const void __iomem *buf, size_t buflen, off_t skip);
+size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
+		      void __iomem *buf, size_t buflen, off_t skip);
+
 size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents,
 		       size_t buflen, off_t skip);
 
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index a59778946404..e52f37b181fa 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -954,6 +954,55 @@ size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
 }
 EXPORT_SYMBOL(sg_copy_buffer);
 
+/**
+ * sg_copy_io - Copy data between an I/O mapped buffer and an SG list
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy from
+ * @buflen:		 The number of bytes to copy
+ * @skip:		 Number of bytes to skip before copying
+ * @to_buffer:		 transfer direction (true == from an sg list to a
+ *			 buffer, false == from a buffer to an sg list)
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
+		  size_t buflen, off_t skip, bool to_buffer)
+{
+	unsigned int offset = 0;
+	struct sg_mapping_iter miter;
+	unsigned int sg_flags = SG_MITER_ATOMIC;
+
+	if (to_buffer)
+		sg_flags |= SG_MITER_FROM_SG;
+	else
+		sg_flags |= SG_MITER_TO_SG;
+
+	sg_miter_start(&miter, sgl, nents, sg_flags);
+
+	if (!sg_miter_skip(&miter, skip))
+		return 0;
+
+	while ((offset < buflen) && sg_miter_next(&miter)) {
+		unsigned int len;
+
+		len = min(miter.length, buflen - offset);
+
+		if (to_buffer)
+			memcpy_toio(buf + offset, miter.addr, len);
+		else
+			memcpy_fromio(miter.addr, buf + offset, len);
+
+		offset += len;
+	}
+
+	sg_miter_stop(&miter);
+
+	return offset;
+}
+EXPORT_SYMBOL(sg_copy_io);
+
 /**
  * sg_copy_from_buffer - Copy from a linear buffer to an SG list
  * @sgl:		 The SG list
@@ -988,6 +1037,40 @@ size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 }
 EXPORT_SYMBOL(sg_copy_to_buffer);
 
+/**
+ * sg_copy_from_io - Copy from an I/O mapped buffer to an SG list
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy from
+ * @buflen:		 The number of bytes to copy
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
+		       const void *buf, size_t buflen)
+{
+	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, 0, false);
+}
+EXPORT_SYMBOL(sg_copy_from_io);
+
+/**
+ * sg_copy_to_io - Copy from an SG list to an I/O mapped buffer
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy to
+ * @buflen:		 The number of bytes to copy
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
+		     void __iomem *buf, size_t buflen)
+{
+	return sg_copy_io(sgl, nents, buf, buflen, 0, true);
+}
+EXPORT_SYMBOL(sg_copy_to_io);
+
 /**
  * sg_pcopy_from_buffer - Copy from a linear buffer to an SG list
  * @sgl:		 The SG list
@@ -1024,6 +1107,42 @@ size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 }
 EXPORT_SYMBOL(sg_pcopy_to_buffer);
 
+/**
+ * sg_pcopy_from_io - Copy from an I/O mapped buffer to an SG list
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy from
+ * @buflen:		 The number of bytes to copy
+ * @skip:		 Number of bytes to skip before copying
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
+			const void __iomem *buf, size_t buflen, off_t skip)
+{
+	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, skip, false);
+}
+EXPORT_SYMBOL(sg_pcopy_from_io);
+
+/**
+ * sg_pcopy_to_io - Copy from an SG list to an I/O mapped buffer
+ * @sgl:		 The SG list
+ * @nents:		 Number of SG entries
+ * @buf:		 Where to copy to
+ * @buflen:		 The number of bytes to copy
+ * @skip:		 Number of bytes to skip before copying
+ *
+ * Returns the number of copied bytes.
+ *
+ **/
+size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
+		      void __iomem *buf, size_t buflen, off_t skip)
+{
+	return sg_copy_io(sgl, nents, buf, buflen, skip, true);
+}
+EXPORT_SYMBOL(sg_pcopy_to_io);
+
 /**
  * sg_zero_buffer - Zero-out a part of a SG list
  * @sgl:		 The SG list
-- 
2.25.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH RFC 2/2] mmc: meson-gx: use sg_copy_to/from_io instead of local version
  2021-06-28 12:34 ` Neil Armstrong
  (?)
@ 2021-06-28 12:34   ` Neil Armstrong
  -1 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-06-28 12:34 UTC (permalink / raw)
  To: jgg, leon, m.szyprowski, robin.murphy, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel, Neil Armstrong

Use the proper sg_copy_to_io & sg_copy_from_io instead of having a local
sg_copy_buffer variant to handle the I/O mapped buffer case.

Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/mmc/host/meson-gx-mmc.c | 53 +++++++--------------------------
 1 file changed, 10 insertions(+), 43 deletions(-)

diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index 3f28eb4d17fe..c13436efb414 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -746,47 +746,6 @@ static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg)
 	writel(start, host->regs + SD_EMMC_START);
 }
 
-/* local sg copy to buffer version with _to/fromio usage for dram_access_quirk */
-static void meson_mmc_copy_buffer(struct meson_host *host, struct mmc_data *data,
-				  size_t buflen, bool to_buffer)
-{
-	unsigned int sg_flags = SG_MITER_ATOMIC;
-	struct scatterlist *sgl = data->sg;
-	unsigned int nents = data->sg_len;
-	struct sg_mapping_iter miter;
-	unsigned int offset = 0;
-
-	if (to_buffer)
-		sg_flags |= SG_MITER_FROM_SG;
-	else
-		sg_flags |= SG_MITER_TO_SG;
-
-	sg_miter_start(&miter, sgl, nents, sg_flags);
-
-	while ((offset < buflen) && sg_miter_next(&miter)) {
-		unsigned int len;
-
-		len = min(miter.length, buflen - offset);
-
-		/* When dram_access_quirk, the bounce buffer is a iomem mapping */
-		if (host->dram_access_quirk) {
-			if (to_buffer)
-				memcpy_toio(host->bounce_iomem_buf + offset, miter.addr, len);
-			else
-				memcpy_fromio(miter.addr, host->bounce_iomem_buf + offset, len);
-		} else {
-			if (to_buffer)
-				memcpy(host->bounce_buf + offset, miter.addr, len);
-			else
-				memcpy(miter.addr, host->bounce_buf + offset, len);
-		}
-
-		offset += len;
-	}
-
-	sg_miter_stop(&miter);
-}
-
 static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
 {
 	struct meson_host *host = mmc_priv(mmc);
@@ -830,7 +789,12 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
 		if (data->flags & MMC_DATA_WRITE) {
 			cmd_cfg |= CMD_CFG_DATA_WR;
 			WARN_ON(xfer_bytes > host->bounce_buf_size);
-			meson_mmc_copy_buffer(host, data, xfer_bytes, true);
+			if (host->dram_access_quirk)
+				sg_copy_to_io(data->sg, data->sg_len,
+					      host->bounce_iomem_buf, xfer_bytes);
+			else
+				sg_copy_to_buffer(data->sg, data->sg_len,
+						  host->bounce_buf, xfer_bytes);
 			dma_wmb();
 		}
 
@@ -999,7 +963,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
 	if (meson_mmc_bounce_buf_read(data)) {
 		xfer_bytes = data->blksz * data->blocks;
 		WARN_ON(xfer_bytes > host->bounce_buf_size);
-		meson_mmc_copy_buffer(host, data, xfer_bytes, false);
+		if (host->dram_access_quirk)
+			sg_copy_from_io(data->sg, data->sg_len, host->bounce_iomem_buf, xfer_bytes);
+		else
+			sg_copy_from_buffer(data->sg, data->sg_len, host->bounce_buf, xfer_bytes);
 	}
 
 	next_cmd = meson_mmc_get_next_command(cmd);
-- 
2.25.1


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

* [PATCH RFC 2/2] mmc: meson-gx: use sg_copy_to/from_io instead of local version
@ 2021-06-28 12:34   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-06-28 12:34 UTC (permalink / raw)
  To: jgg, leon, m.szyprowski, robin.murphy, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel, Neil Armstrong

Use the proper sg_copy_to_io & sg_copy_from_io instead of having a local
sg_copy_buffer variant to handle the I/O mapped buffer case.

Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/mmc/host/meson-gx-mmc.c | 53 +++++++--------------------------
 1 file changed, 10 insertions(+), 43 deletions(-)

diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index 3f28eb4d17fe..c13436efb414 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -746,47 +746,6 @@ static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg)
 	writel(start, host->regs + SD_EMMC_START);
 }
 
-/* local sg copy to buffer version with _to/fromio usage for dram_access_quirk */
-static void meson_mmc_copy_buffer(struct meson_host *host, struct mmc_data *data,
-				  size_t buflen, bool to_buffer)
-{
-	unsigned int sg_flags = SG_MITER_ATOMIC;
-	struct scatterlist *sgl = data->sg;
-	unsigned int nents = data->sg_len;
-	struct sg_mapping_iter miter;
-	unsigned int offset = 0;
-
-	if (to_buffer)
-		sg_flags |= SG_MITER_FROM_SG;
-	else
-		sg_flags |= SG_MITER_TO_SG;
-
-	sg_miter_start(&miter, sgl, nents, sg_flags);
-
-	while ((offset < buflen) && sg_miter_next(&miter)) {
-		unsigned int len;
-
-		len = min(miter.length, buflen - offset);
-
-		/* When dram_access_quirk, the bounce buffer is a iomem mapping */
-		if (host->dram_access_quirk) {
-			if (to_buffer)
-				memcpy_toio(host->bounce_iomem_buf + offset, miter.addr, len);
-			else
-				memcpy_fromio(miter.addr, host->bounce_iomem_buf + offset, len);
-		} else {
-			if (to_buffer)
-				memcpy(host->bounce_buf + offset, miter.addr, len);
-			else
-				memcpy(miter.addr, host->bounce_buf + offset, len);
-		}
-
-		offset += len;
-	}
-
-	sg_miter_stop(&miter);
-}
-
 static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
 {
 	struct meson_host *host = mmc_priv(mmc);
@@ -830,7 +789,12 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
 		if (data->flags & MMC_DATA_WRITE) {
 			cmd_cfg |= CMD_CFG_DATA_WR;
 			WARN_ON(xfer_bytes > host->bounce_buf_size);
-			meson_mmc_copy_buffer(host, data, xfer_bytes, true);
+			if (host->dram_access_quirk)
+				sg_copy_to_io(data->sg, data->sg_len,
+					      host->bounce_iomem_buf, xfer_bytes);
+			else
+				sg_copy_to_buffer(data->sg, data->sg_len,
+						  host->bounce_buf, xfer_bytes);
 			dma_wmb();
 		}
 
@@ -999,7 +963,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
 	if (meson_mmc_bounce_buf_read(data)) {
 		xfer_bytes = data->blksz * data->blocks;
 		WARN_ON(xfer_bytes > host->bounce_buf_size);
-		meson_mmc_copy_buffer(host, data, xfer_bytes, false);
+		if (host->dram_access_quirk)
+			sg_copy_from_io(data->sg, data->sg_len, host->bounce_iomem_buf, xfer_bytes);
+		else
+			sg_copy_from_buffer(data->sg, data->sg_len, host->bounce_buf, xfer_bytes);
 	}
 
 	next_cmd = meson_mmc_get_next_command(cmd);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH RFC 2/2] mmc: meson-gx: use sg_copy_to/from_io instead of local version
@ 2021-06-28 12:34   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-06-28 12:34 UTC (permalink / raw)
  To: jgg, leon, m.szyprowski, robin.murphy, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel, Neil Armstrong

Use the proper sg_copy_to_io & sg_copy_from_io instead of having a local
sg_copy_buffer variant to handle the I/O mapped buffer case.

Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/mmc/host/meson-gx-mmc.c | 53 +++++++--------------------------
 1 file changed, 10 insertions(+), 43 deletions(-)

diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index 3f28eb4d17fe..c13436efb414 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -746,47 +746,6 @@ static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg)
 	writel(start, host->regs + SD_EMMC_START);
 }
 
-/* local sg copy to buffer version with _to/fromio usage for dram_access_quirk */
-static void meson_mmc_copy_buffer(struct meson_host *host, struct mmc_data *data,
-				  size_t buflen, bool to_buffer)
-{
-	unsigned int sg_flags = SG_MITER_ATOMIC;
-	struct scatterlist *sgl = data->sg;
-	unsigned int nents = data->sg_len;
-	struct sg_mapping_iter miter;
-	unsigned int offset = 0;
-
-	if (to_buffer)
-		sg_flags |= SG_MITER_FROM_SG;
-	else
-		sg_flags |= SG_MITER_TO_SG;
-
-	sg_miter_start(&miter, sgl, nents, sg_flags);
-
-	while ((offset < buflen) && sg_miter_next(&miter)) {
-		unsigned int len;
-
-		len = min(miter.length, buflen - offset);
-
-		/* When dram_access_quirk, the bounce buffer is a iomem mapping */
-		if (host->dram_access_quirk) {
-			if (to_buffer)
-				memcpy_toio(host->bounce_iomem_buf + offset, miter.addr, len);
-			else
-				memcpy_fromio(miter.addr, host->bounce_iomem_buf + offset, len);
-		} else {
-			if (to_buffer)
-				memcpy(host->bounce_buf + offset, miter.addr, len);
-			else
-				memcpy(miter.addr, host->bounce_buf + offset, len);
-		}
-
-		offset += len;
-	}
-
-	sg_miter_stop(&miter);
-}
-
 static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
 {
 	struct meson_host *host = mmc_priv(mmc);
@@ -830,7 +789,12 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
 		if (data->flags & MMC_DATA_WRITE) {
 			cmd_cfg |= CMD_CFG_DATA_WR;
 			WARN_ON(xfer_bytes > host->bounce_buf_size);
-			meson_mmc_copy_buffer(host, data, xfer_bytes, true);
+			if (host->dram_access_quirk)
+				sg_copy_to_io(data->sg, data->sg_len,
+					      host->bounce_iomem_buf, xfer_bytes);
+			else
+				sg_copy_to_buffer(data->sg, data->sg_len,
+						  host->bounce_buf, xfer_bytes);
 			dma_wmb();
 		}
 
@@ -999,7 +963,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
 	if (meson_mmc_bounce_buf_read(data)) {
 		xfer_bytes = data->blksz * data->blocks;
 		WARN_ON(xfer_bytes > host->bounce_buf_size);
-		meson_mmc_copy_buffer(host, data, xfer_bytes, false);
+		if (host->dram_access_quirk)
+			sg_copy_from_io(data->sg, data->sg_len, host->bounce_iomem_buf, xfer_bytes);
+		else
+			sg_copy_from_buffer(data->sg, data->sg_len, host->bounce_buf, xfer_bytes);
 	}
 
 	next_cmd = meson_mmc_get_next_command(cmd);
-- 
2.25.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy
  2021-06-28 12:34   ` Neil Armstrong
  (?)
@ 2021-06-28 13:40     ` Robin Murphy
  -1 siblings, 0 replies; 17+ messages in thread
From: Robin Murphy @ 2021-06-28 13:40 UTC (permalink / raw)
  To: Neil Armstrong, jgg, leon, m.szyprowski, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel

On 2021-06-28 13:34, Neil Armstrong wrote:
> When copying from/to an iomem mapped memory, the current sg_copy & sg_pcopy can't
> be used and lead to local variants in drivers like in [1] & [2].
> 
> This introduces an I/O variant to be used instead of the local variants.
> 
> [1] mv_cesa_sg_copy in drivers/crypto/marvell/cesa/tdma.c
> [2] meson_mmc_copy_buffer in drivers/mmc/host/meson-gx-mmc.c

Other than one apparent typo below, this looks like what I imagined, 
thanks for putting it together!

> Cc: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>   include/linux/scatterlist.h |  14 +++++
>   lib/scatterlist.c           | 119 ++++++++++++++++++++++++++++++++++++
>   2 files changed, 133 insertions(+)
> 
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index 6f70572b2938..6ef339ba5290 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -308,15 +308,29 @@ void sgl_free(struct scatterlist *sgl);
>   size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
>   		      size_t buflen, off_t skip, bool to_buffer);
>   
> +size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
> +		  size_t buflen, off_t skip, bool to_buffer);
> +
>   size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
>   			   const void *buf, size_t buflen);
>   size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   			 void *buf, size_t buflen);
>   
> +size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
> +		       const void __iomem *buf, size_t buflen);
> +size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		     void __iomem *buf, size_t buflen);
> +
>   size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
>   			    const void *buf, size_t buflen, off_t skip);
>   size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   			  void *buf, size_t buflen, off_t skip);
> +
> +size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
> +			const void __iomem *buf, size_t buflen, off_t skip);
> +size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		      void __iomem *buf, size_t buflen, off_t skip);
> +
>   size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents,
>   		       size_t buflen, off_t skip);
>   
> diff --git a/lib/scatterlist.c b/lib/scatterlist.c
> index a59778946404..e52f37b181fa 100644
> --- a/lib/scatterlist.c
> +++ b/lib/scatterlist.c
> @@ -954,6 +954,55 @@ size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
>   }
>   EXPORT_SYMBOL(sg_copy_buffer);
>   
> +/**
> + * sg_copy_io - Copy data between an I/O mapped buffer and an SG list
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy from
> + * @buflen:		 The number of bytes to copy
> + * @skip:		 Number of bytes to skip before copying
> + * @to_buffer:		 transfer direction (true == from an sg list to a
> + *			 buffer, false == from a buffer to an sg list)
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
> +		  size_t buflen, off_t skip, bool to_buffer)
> +{
> +	unsigned int offset = 0;
> +	struct sg_mapping_iter miter;
> +	unsigned int sg_flags = SG_MITER_ATOMIC;
> +
> +	if (to_buffer)
> +		sg_flags |= SG_MITER_FROM_SG;
> +	else
> +		sg_flags |= SG_MITER_TO_SG;
> +
> +	sg_miter_start(&miter, sgl, nents, sg_flags);
> +
> +	if (!sg_miter_skip(&miter, skip))
> +		return 0;
> +
> +	while ((offset < buflen) && sg_miter_next(&miter)) {
> +		unsigned int len;
> +
> +		len = min(miter.length, buflen - offset);
> +
> +		if (to_buffer)
> +			memcpy_toio(buf + offset, miter.addr, len);
> +		else
> +			memcpy_fromio(miter.addr, buf + offset, len);
> +
> +		offset += len;
> +	}
> +
> +	sg_miter_stop(&miter);
> +
> +	return offset;
> +}
> +EXPORT_SYMBOL(sg_copy_io);
> +
>   /**
>    * sg_copy_from_buffer - Copy from a linear buffer to an SG list
>    * @sgl:		 The SG list
> @@ -988,6 +1037,40 @@ size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   }
>   EXPORT_SYMBOL(sg_copy_to_buffer);
>   
> +/**
> + * sg_copy_from_io - Copy from an I/O mapped buffer to an SG list
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy from
> + * @buflen:		 The number of bytes to copy
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
> +		       const void *buf, size_t buflen)

The __iomem annotation wants to be on buf here raher than cast in below, 
to match the prototype (and everything else).

Cheers,
Robin.

> +{
> +	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, 0, false);
> +}
> +EXPORT_SYMBOL(sg_copy_from_io);
> +
> +/**
> + * sg_copy_to_io - Copy from an SG list to an I/O mapped buffer
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy to
> + * @buflen:		 The number of bytes to copy
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		     void __iomem *buf, size_t buflen)
> +{
> +	return sg_copy_io(sgl, nents, buf, buflen, 0, true);
> +}
> +EXPORT_SYMBOL(sg_copy_to_io);
> +
>   /**
>    * sg_pcopy_from_buffer - Copy from a linear buffer to an SG list
>    * @sgl:		 The SG list
> @@ -1024,6 +1107,42 @@ size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   }
>   EXPORT_SYMBOL(sg_pcopy_to_buffer);
>   
> +/**
> + * sg_pcopy_from_io - Copy from an I/O mapped buffer to an SG list
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy from
> + * @buflen:		 The number of bytes to copy
> + * @skip:		 Number of bytes to skip before copying
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
> +			const void __iomem *buf, size_t buflen, off_t skip)
> +{
> +	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, skip, false);
> +}
> +EXPORT_SYMBOL(sg_pcopy_from_io);
> +
> +/**
> + * sg_pcopy_to_io - Copy from an SG list to an I/O mapped buffer
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy to
> + * @buflen:		 The number of bytes to copy
> + * @skip:		 Number of bytes to skip before copying
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		      void __iomem *buf, size_t buflen, off_t skip)
> +{
> +	return sg_copy_io(sgl, nents, buf, buflen, skip, true);
> +}
> +EXPORT_SYMBOL(sg_pcopy_to_io);
> +
>   /**
>    * sg_zero_buffer - Zero-out a part of a SG list
>    * @sgl:		 The SG list
> 

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

* Re: [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy
@ 2021-06-28 13:40     ` Robin Murphy
  0 siblings, 0 replies; 17+ messages in thread
From: Robin Murphy @ 2021-06-28 13:40 UTC (permalink / raw)
  To: Neil Armstrong, jgg, leon, m.szyprowski, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel

On 2021-06-28 13:34, Neil Armstrong wrote:
> When copying from/to an iomem mapped memory, the current sg_copy & sg_pcopy can't
> be used and lead to local variants in drivers like in [1] & [2].
> 
> This introduces an I/O variant to be used instead of the local variants.
> 
> [1] mv_cesa_sg_copy in drivers/crypto/marvell/cesa/tdma.c
> [2] meson_mmc_copy_buffer in drivers/mmc/host/meson-gx-mmc.c

Other than one apparent typo below, this looks like what I imagined, 
thanks for putting it together!

> Cc: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>   include/linux/scatterlist.h |  14 +++++
>   lib/scatterlist.c           | 119 ++++++++++++++++++++++++++++++++++++
>   2 files changed, 133 insertions(+)
> 
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index 6f70572b2938..6ef339ba5290 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -308,15 +308,29 @@ void sgl_free(struct scatterlist *sgl);
>   size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
>   		      size_t buflen, off_t skip, bool to_buffer);
>   
> +size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
> +		  size_t buflen, off_t skip, bool to_buffer);
> +
>   size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
>   			   const void *buf, size_t buflen);
>   size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   			 void *buf, size_t buflen);
>   
> +size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
> +		       const void __iomem *buf, size_t buflen);
> +size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		     void __iomem *buf, size_t buflen);
> +
>   size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
>   			    const void *buf, size_t buflen, off_t skip);
>   size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   			  void *buf, size_t buflen, off_t skip);
> +
> +size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
> +			const void __iomem *buf, size_t buflen, off_t skip);
> +size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		      void __iomem *buf, size_t buflen, off_t skip);
> +
>   size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents,
>   		       size_t buflen, off_t skip);
>   
> diff --git a/lib/scatterlist.c b/lib/scatterlist.c
> index a59778946404..e52f37b181fa 100644
> --- a/lib/scatterlist.c
> +++ b/lib/scatterlist.c
> @@ -954,6 +954,55 @@ size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
>   }
>   EXPORT_SYMBOL(sg_copy_buffer);
>   
> +/**
> + * sg_copy_io - Copy data between an I/O mapped buffer and an SG list
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy from
> + * @buflen:		 The number of bytes to copy
> + * @skip:		 Number of bytes to skip before copying
> + * @to_buffer:		 transfer direction (true == from an sg list to a
> + *			 buffer, false == from a buffer to an sg list)
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
> +		  size_t buflen, off_t skip, bool to_buffer)
> +{
> +	unsigned int offset = 0;
> +	struct sg_mapping_iter miter;
> +	unsigned int sg_flags = SG_MITER_ATOMIC;
> +
> +	if (to_buffer)
> +		sg_flags |= SG_MITER_FROM_SG;
> +	else
> +		sg_flags |= SG_MITER_TO_SG;
> +
> +	sg_miter_start(&miter, sgl, nents, sg_flags);
> +
> +	if (!sg_miter_skip(&miter, skip))
> +		return 0;
> +
> +	while ((offset < buflen) && sg_miter_next(&miter)) {
> +		unsigned int len;
> +
> +		len = min(miter.length, buflen - offset);
> +
> +		if (to_buffer)
> +			memcpy_toio(buf + offset, miter.addr, len);
> +		else
> +			memcpy_fromio(miter.addr, buf + offset, len);
> +
> +		offset += len;
> +	}
> +
> +	sg_miter_stop(&miter);
> +
> +	return offset;
> +}
> +EXPORT_SYMBOL(sg_copy_io);
> +
>   /**
>    * sg_copy_from_buffer - Copy from a linear buffer to an SG list
>    * @sgl:		 The SG list
> @@ -988,6 +1037,40 @@ size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   }
>   EXPORT_SYMBOL(sg_copy_to_buffer);
>   
> +/**
> + * sg_copy_from_io - Copy from an I/O mapped buffer to an SG list
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy from
> + * @buflen:		 The number of bytes to copy
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
> +		       const void *buf, size_t buflen)

The __iomem annotation wants to be on buf here raher than cast in below, 
to match the prototype (and everything else).

Cheers,
Robin.

> +{
> +	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, 0, false);
> +}
> +EXPORT_SYMBOL(sg_copy_from_io);
> +
> +/**
> + * sg_copy_to_io - Copy from an SG list to an I/O mapped buffer
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy to
> + * @buflen:		 The number of bytes to copy
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		     void __iomem *buf, size_t buflen)
> +{
> +	return sg_copy_io(sgl, nents, buf, buflen, 0, true);
> +}
> +EXPORT_SYMBOL(sg_copy_to_io);
> +
>   /**
>    * sg_pcopy_from_buffer - Copy from a linear buffer to an SG list
>    * @sgl:		 The SG list
> @@ -1024,6 +1107,42 @@ size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   }
>   EXPORT_SYMBOL(sg_pcopy_to_buffer);
>   
> +/**
> + * sg_pcopy_from_io - Copy from an I/O mapped buffer to an SG list
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy from
> + * @buflen:		 The number of bytes to copy
> + * @skip:		 Number of bytes to skip before copying
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
> +			const void __iomem *buf, size_t buflen, off_t skip)
> +{
> +	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, skip, false);
> +}
> +EXPORT_SYMBOL(sg_pcopy_from_io);
> +
> +/**
> + * sg_pcopy_to_io - Copy from an SG list to an I/O mapped buffer
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy to
> + * @buflen:		 The number of bytes to copy
> + * @skip:		 Number of bytes to skip before copying
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		      void __iomem *buf, size_t buflen, off_t skip)
> +{
> +	return sg_copy_io(sgl, nents, buf, buflen, skip, true);
> +}
> +EXPORT_SYMBOL(sg_pcopy_to_io);
> +
>   /**
>    * sg_zero_buffer - Zero-out a part of a SG list
>    * @sgl:		 The SG list
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy
@ 2021-06-28 13:40     ` Robin Murphy
  0 siblings, 0 replies; 17+ messages in thread
From: Robin Murphy @ 2021-06-28 13:40 UTC (permalink / raw)
  To: Neil Armstrong, jgg, leon, m.szyprowski, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel

On 2021-06-28 13:34, Neil Armstrong wrote:
> When copying from/to an iomem mapped memory, the current sg_copy & sg_pcopy can't
> be used and lead to local variants in drivers like in [1] & [2].
> 
> This introduces an I/O variant to be used instead of the local variants.
> 
> [1] mv_cesa_sg_copy in drivers/crypto/marvell/cesa/tdma.c
> [2] meson_mmc_copy_buffer in drivers/mmc/host/meson-gx-mmc.c

Other than one apparent typo below, this looks like what I imagined, 
thanks for putting it together!

> Cc: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>   include/linux/scatterlist.h |  14 +++++
>   lib/scatterlist.c           | 119 ++++++++++++++++++++++++++++++++++++
>   2 files changed, 133 insertions(+)
> 
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index 6f70572b2938..6ef339ba5290 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -308,15 +308,29 @@ void sgl_free(struct scatterlist *sgl);
>   size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
>   		      size_t buflen, off_t skip, bool to_buffer);
>   
> +size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
> +		  size_t buflen, off_t skip, bool to_buffer);
> +
>   size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
>   			   const void *buf, size_t buflen);
>   size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   			 void *buf, size_t buflen);
>   
> +size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
> +		       const void __iomem *buf, size_t buflen);
> +size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		     void __iomem *buf, size_t buflen);
> +
>   size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
>   			    const void *buf, size_t buflen, off_t skip);
>   size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   			  void *buf, size_t buflen, off_t skip);
> +
> +size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
> +			const void __iomem *buf, size_t buflen, off_t skip);
> +size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		      void __iomem *buf, size_t buflen, off_t skip);
> +
>   size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents,
>   		       size_t buflen, off_t skip);
>   
> diff --git a/lib/scatterlist.c b/lib/scatterlist.c
> index a59778946404..e52f37b181fa 100644
> --- a/lib/scatterlist.c
> +++ b/lib/scatterlist.c
> @@ -954,6 +954,55 @@ size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
>   }
>   EXPORT_SYMBOL(sg_copy_buffer);
>   
> +/**
> + * sg_copy_io - Copy data between an I/O mapped buffer and an SG list
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy from
> + * @buflen:		 The number of bytes to copy
> + * @skip:		 Number of bytes to skip before copying
> + * @to_buffer:		 transfer direction (true == from an sg list to a
> + *			 buffer, false == from a buffer to an sg list)
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_copy_io(struct scatterlist *sgl, unsigned int nents, void __iomem *buf,
> +		  size_t buflen, off_t skip, bool to_buffer)
> +{
> +	unsigned int offset = 0;
> +	struct sg_mapping_iter miter;
> +	unsigned int sg_flags = SG_MITER_ATOMIC;
> +
> +	if (to_buffer)
> +		sg_flags |= SG_MITER_FROM_SG;
> +	else
> +		sg_flags |= SG_MITER_TO_SG;
> +
> +	sg_miter_start(&miter, sgl, nents, sg_flags);
> +
> +	if (!sg_miter_skip(&miter, skip))
> +		return 0;
> +
> +	while ((offset < buflen) && sg_miter_next(&miter)) {
> +		unsigned int len;
> +
> +		len = min(miter.length, buflen - offset);
> +
> +		if (to_buffer)
> +			memcpy_toio(buf + offset, miter.addr, len);
> +		else
> +			memcpy_fromio(miter.addr, buf + offset, len);
> +
> +		offset += len;
> +	}
> +
> +	sg_miter_stop(&miter);
> +
> +	return offset;
> +}
> +EXPORT_SYMBOL(sg_copy_io);
> +
>   /**
>    * sg_copy_from_buffer - Copy from a linear buffer to an SG list
>    * @sgl:		 The SG list
> @@ -988,6 +1037,40 @@ size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   }
>   EXPORT_SYMBOL(sg_copy_to_buffer);
>   
> +/**
> + * sg_copy_from_io - Copy from an I/O mapped buffer to an SG list
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy from
> + * @buflen:		 The number of bytes to copy
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
> +		       const void *buf, size_t buflen)

The __iomem annotation wants to be on buf here raher than cast in below, 
to match the prototype (and everything else).

Cheers,
Robin.

> +{
> +	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, 0, false);
> +}
> +EXPORT_SYMBOL(sg_copy_from_io);
> +
> +/**
> + * sg_copy_to_io - Copy from an SG list to an I/O mapped buffer
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy to
> + * @buflen:		 The number of bytes to copy
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_copy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		     void __iomem *buf, size_t buflen)
> +{
> +	return sg_copy_io(sgl, nents, buf, buflen, 0, true);
> +}
> +EXPORT_SYMBOL(sg_copy_to_io);
> +
>   /**
>    * sg_pcopy_from_buffer - Copy from a linear buffer to an SG list
>    * @sgl:		 The SG list
> @@ -1024,6 +1107,42 @@ size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
>   }
>   EXPORT_SYMBOL(sg_pcopy_to_buffer);
>   
> +/**
> + * sg_pcopy_from_io - Copy from an I/O mapped buffer to an SG list
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy from
> + * @buflen:		 The number of bytes to copy
> + * @skip:		 Number of bytes to skip before copying
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_pcopy_from_io(struct scatterlist *sgl, unsigned int nents,
> +			const void __iomem *buf, size_t buflen, off_t skip)
> +{
> +	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, skip, false);
> +}
> +EXPORT_SYMBOL(sg_pcopy_from_io);
> +
> +/**
> + * sg_pcopy_to_io - Copy from an SG list to an I/O mapped buffer
> + * @sgl:		 The SG list
> + * @nents:		 Number of SG entries
> + * @buf:		 Where to copy to
> + * @buflen:		 The number of bytes to copy
> + * @skip:		 Number of bytes to skip before copying
> + *
> + * Returns the number of copied bytes.
> + *
> + **/
> +size_t sg_pcopy_to_io(struct scatterlist *sgl, unsigned int nents,
> +		      void __iomem *buf, size_t buflen, off_t skip)
> +{
> +	return sg_copy_io(sgl, nents, buf, buflen, skip, true);
> +}
> +EXPORT_SYMBOL(sg_pcopy_to_io);
> +
>   /**
>    * sg_zero_buffer - Zero-out a part of a SG list
>    * @sgl:		 The SG list
> 

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH RFC 2/2] mmc: meson-gx: use sg_copy_to/from_io instead of local version
  2021-06-28 12:34   ` Neil Armstrong
  (?)
@ 2021-06-28 13:44     ` Robin Murphy
  -1 siblings, 0 replies; 17+ messages in thread
From: Robin Murphy @ 2021-06-28 13:44 UTC (permalink / raw)
  To: Neil Armstrong, jgg, leon, m.szyprowski, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel

On 2021-06-28 13:34, Neil Armstrong wrote:
> Use the proper sg_copy_to_io & sg_copy_from_io instead of having a local
> sg_copy_buffer variant to handle the I/O mapped buffer case.
> 
> Cc: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>   drivers/mmc/host/meson-gx-mmc.c | 53 +++++++--------------------------
>   1 file changed, 10 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
> index 3f28eb4d17fe..c13436efb414 100644
> --- a/drivers/mmc/host/meson-gx-mmc.c
> +++ b/drivers/mmc/host/meson-gx-mmc.c
> @@ -746,47 +746,6 @@ static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg)
>   	writel(start, host->regs + SD_EMMC_START);
>   }
>   
> -/* local sg copy to buffer version with _to/fromio usage for dram_access_quirk */
> -static void meson_mmc_copy_buffer(struct meson_host *host, struct mmc_data *data,
> -				  size_t buflen, bool to_buffer)
> -{
> -	unsigned int sg_flags = SG_MITER_ATOMIC;
> -	struct scatterlist *sgl = data->sg;
> -	unsigned int nents = data->sg_len;
> -	struct sg_mapping_iter miter;
> -	unsigned int offset = 0;
> -
> -	if (to_buffer)
> -		sg_flags |= SG_MITER_FROM_SG;
> -	else
> -		sg_flags |= SG_MITER_TO_SG;
> -
> -	sg_miter_start(&miter, sgl, nents, sg_flags);
> -
> -	while ((offset < buflen) && sg_miter_next(&miter)) {
> -		unsigned int len;
> -
> -		len = min(miter.length, buflen - offset);
> -
> -		/* When dram_access_quirk, the bounce buffer is a iomem mapping */
> -		if (host->dram_access_quirk) {
> -			if (to_buffer)
> -				memcpy_toio(host->bounce_iomem_buf + offset, miter.addr, len);
> -			else
> -				memcpy_fromio(miter.addr, host->bounce_iomem_buf + offset, len);
> -		} else {
> -			if (to_buffer)
> -				memcpy(host->bounce_buf + offset, miter.addr, len);
> -			else
> -				memcpy(miter.addr, host->bounce_buf + offset, len);
> -		}
> -
> -		offset += len;
> -	}
> -
> -	sg_miter_stop(&miter);
> -}
> -
>   static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
>   {
>   	struct meson_host *host = mmc_priv(mmc);
> @@ -830,7 +789,12 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
>   		if (data->flags & MMC_DATA_WRITE) {
>   			cmd_cfg |= CMD_CFG_DATA_WR;
>   			WARN_ON(xfer_bytes > host->bounce_buf_size);
> -			meson_mmc_copy_buffer(host, data, xfer_bytes, true);
> +			if (host->dram_access_quirk)
> +				sg_copy_to_io(data->sg, data->sg_len,
> +					      host->bounce_iomem_buf, xfer_bytes);

Maybe you could just use host->regs + SD_EMMC_SRAM_DATA_BUF_OFF directly 
here (and below) and save carrying host->bounce_iomem_buf around?

Robin.

> +			else
> +				sg_copy_to_buffer(data->sg, data->sg_len,
> +						  host->bounce_buf, xfer_bytes);
>   			dma_wmb();
>   		}
>   
> @@ -999,7 +963,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
>   	if (meson_mmc_bounce_buf_read(data)) {
>   		xfer_bytes = data->blksz * data->blocks;
>   		WARN_ON(xfer_bytes > host->bounce_buf_size);
> -		meson_mmc_copy_buffer(host, data, xfer_bytes, false);
> +		if (host->dram_access_quirk)
> +			sg_copy_from_io(data->sg, data->sg_len, host->bounce_iomem_buf, xfer_bytes);
> +		else
> +			sg_copy_from_buffer(data->sg, data->sg_len, host->bounce_buf, xfer_bytes);
>   	}
>   
>   	next_cmd = meson_mmc_get_next_command(cmd);
> 

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

* Re: [PATCH RFC 2/2] mmc: meson-gx: use sg_copy_to/from_io instead of local version
@ 2021-06-28 13:44     ` Robin Murphy
  0 siblings, 0 replies; 17+ messages in thread
From: Robin Murphy @ 2021-06-28 13:44 UTC (permalink / raw)
  To: Neil Armstrong, jgg, leon, m.szyprowski, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel

On 2021-06-28 13:34, Neil Armstrong wrote:
> Use the proper sg_copy_to_io & sg_copy_from_io instead of having a local
> sg_copy_buffer variant to handle the I/O mapped buffer case.
> 
> Cc: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>   drivers/mmc/host/meson-gx-mmc.c | 53 +++++++--------------------------
>   1 file changed, 10 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
> index 3f28eb4d17fe..c13436efb414 100644
> --- a/drivers/mmc/host/meson-gx-mmc.c
> +++ b/drivers/mmc/host/meson-gx-mmc.c
> @@ -746,47 +746,6 @@ static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg)
>   	writel(start, host->regs + SD_EMMC_START);
>   }
>   
> -/* local sg copy to buffer version with _to/fromio usage for dram_access_quirk */
> -static void meson_mmc_copy_buffer(struct meson_host *host, struct mmc_data *data,
> -				  size_t buflen, bool to_buffer)
> -{
> -	unsigned int sg_flags = SG_MITER_ATOMIC;
> -	struct scatterlist *sgl = data->sg;
> -	unsigned int nents = data->sg_len;
> -	struct sg_mapping_iter miter;
> -	unsigned int offset = 0;
> -
> -	if (to_buffer)
> -		sg_flags |= SG_MITER_FROM_SG;
> -	else
> -		sg_flags |= SG_MITER_TO_SG;
> -
> -	sg_miter_start(&miter, sgl, nents, sg_flags);
> -
> -	while ((offset < buflen) && sg_miter_next(&miter)) {
> -		unsigned int len;
> -
> -		len = min(miter.length, buflen - offset);
> -
> -		/* When dram_access_quirk, the bounce buffer is a iomem mapping */
> -		if (host->dram_access_quirk) {
> -			if (to_buffer)
> -				memcpy_toio(host->bounce_iomem_buf + offset, miter.addr, len);
> -			else
> -				memcpy_fromio(miter.addr, host->bounce_iomem_buf + offset, len);
> -		} else {
> -			if (to_buffer)
> -				memcpy(host->bounce_buf + offset, miter.addr, len);
> -			else
> -				memcpy(miter.addr, host->bounce_buf + offset, len);
> -		}
> -
> -		offset += len;
> -	}
> -
> -	sg_miter_stop(&miter);
> -}
> -
>   static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
>   {
>   	struct meson_host *host = mmc_priv(mmc);
> @@ -830,7 +789,12 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
>   		if (data->flags & MMC_DATA_WRITE) {
>   			cmd_cfg |= CMD_CFG_DATA_WR;
>   			WARN_ON(xfer_bytes > host->bounce_buf_size);
> -			meson_mmc_copy_buffer(host, data, xfer_bytes, true);
> +			if (host->dram_access_quirk)
> +				sg_copy_to_io(data->sg, data->sg_len,
> +					      host->bounce_iomem_buf, xfer_bytes);

Maybe you could just use host->regs + SD_EMMC_SRAM_DATA_BUF_OFF directly 
here (and below) and save carrying host->bounce_iomem_buf around?

Robin.

> +			else
> +				sg_copy_to_buffer(data->sg, data->sg_len,
> +						  host->bounce_buf, xfer_bytes);
>   			dma_wmb();
>   		}
>   
> @@ -999,7 +963,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
>   	if (meson_mmc_bounce_buf_read(data)) {
>   		xfer_bytes = data->blksz * data->blocks;
>   		WARN_ON(xfer_bytes > host->bounce_buf_size);
> -		meson_mmc_copy_buffer(host, data, xfer_bytes, false);
> +		if (host->dram_access_quirk)
> +			sg_copy_from_io(data->sg, data->sg_len, host->bounce_iomem_buf, xfer_bytes);
> +		else
> +			sg_copy_from_buffer(data->sg, data->sg_len, host->bounce_buf, xfer_bytes);
>   	}
>   
>   	next_cmd = meson_mmc_get_next_command(cmd);
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH RFC 2/2] mmc: meson-gx: use sg_copy_to/from_io instead of local version
@ 2021-06-28 13:44     ` Robin Murphy
  0 siblings, 0 replies; 17+ messages in thread
From: Robin Murphy @ 2021-06-28 13:44 UTC (permalink / raw)
  To: Neil Armstrong, jgg, leon, m.szyprowski, ulf.hansson
  Cc: torvalds, khilman, jbrunet, linux-mmc, linux-amlogic,
	linux-arm-kernel, linux-kernel

On 2021-06-28 13:34, Neil Armstrong wrote:
> Use the proper sg_copy_to_io & sg_copy_from_io instead of having a local
> sg_copy_buffer variant to handle the I/O mapped buffer case.
> 
> Cc: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>   drivers/mmc/host/meson-gx-mmc.c | 53 +++++++--------------------------
>   1 file changed, 10 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
> index 3f28eb4d17fe..c13436efb414 100644
> --- a/drivers/mmc/host/meson-gx-mmc.c
> +++ b/drivers/mmc/host/meson-gx-mmc.c
> @@ -746,47 +746,6 @@ static void meson_mmc_desc_chain_transfer(struct mmc_host *mmc, u32 cmd_cfg)
>   	writel(start, host->regs + SD_EMMC_START);
>   }
>   
> -/* local sg copy to buffer version with _to/fromio usage for dram_access_quirk */
> -static void meson_mmc_copy_buffer(struct meson_host *host, struct mmc_data *data,
> -				  size_t buflen, bool to_buffer)
> -{
> -	unsigned int sg_flags = SG_MITER_ATOMIC;
> -	struct scatterlist *sgl = data->sg;
> -	unsigned int nents = data->sg_len;
> -	struct sg_mapping_iter miter;
> -	unsigned int offset = 0;
> -
> -	if (to_buffer)
> -		sg_flags |= SG_MITER_FROM_SG;
> -	else
> -		sg_flags |= SG_MITER_TO_SG;
> -
> -	sg_miter_start(&miter, sgl, nents, sg_flags);
> -
> -	while ((offset < buflen) && sg_miter_next(&miter)) {
> -		unsigned int len;
> -
> -		len = min(miter.length, buflen - offset);
> -
> -		/* When dram_access_quirk, the bounce buffer is a iomem mapping */
> -		if (host->dram_access_quirk) {
> -			if (to_buffer)
> -				memcpy_toio(host->bounce_iomem_buf + offset, miter.addr, len);
> -			else
> -				memcpy_fromio(miter.addr, host->bounce_iomem_buf + offset, len);
> -		} else {
> -			if (to_buffer)
> -				memcpy(host->bounce_buf + offset, miter.addr, len);
> -			else
> -				memcpy(miter.addr, host->bounce_buf + offset, len);
> -		}
> -
> -		offset += len;
> -	}
> -
> -	sg_miter_stop(&miter);
> -}
> -
>   static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
>   {
>   	struct meson_host *host = mmc_priv(mmc);
> @@ -830,7 +789,12 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
>   		if (data->flags & MMC_DATA_WRITE) {
>   			cmd_cfg |= CMD_CFG_DATA_WR;
>   			WARN_ON(xfer_bytes > host->bounce_buf_size);
> -			meson_mmc_copy_buffer(host, data, xfer_bytes, true);
> +			if (host->dram_access_quirk)
> +				sg_copy_to_io(data->sg, data->sg_len,
> +					      host->bounce_iomem_buf, xfer_bytes);

Maybe you could just use host->regs + SD_EMMC_SRAM_DATA_BUF_OFF directly 
here (and below) and save carrying host->bounce_iomem_buf around?

Robin.

> +			else
> +				sg_copy_to_buffer(data->sg, data->sg_len,
> +						  host->bounce_buf, xfer_bytes);
>   			dma_wmb();
>   		}
>   
> @@ -999,7 +963,10 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
>   	if (meson_mmc_bounce_buf_read(data)) {
>   		xfer_bytes = data->blksz * data->blocks;
>   		WARN_ON(xfer_bytes > host->bounce_buf_size);
> -		meson_mmc_copy_buffer(host, data, xfer_bytes, false);
> +		if (host->dram_access_quirk)
> +			sg_copy_from_io(data->sg, data->sg_len, host->bounce_iomem_buf, xfer_bytes);
> +		else
> +			sg_copy_from_buffer(data->sg, data->sg_len, host->bounce_buf, xfer_bytes);
>   	}
>   
>   	next_cmd = meson_mmc_get_next_command(cmd);
> 

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy
@ 2021-06-28 20:14 kernel test robot
  0 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2021-06-28 20:14 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3769 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210628123411.119778-2-narmstrong@baylibre.com>
References: <20210628123411.119778-2-narmstrong@baylibre.com>
TO: Neil Armstrong <narmstrong@baylibre.com>

Hi Neil,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on linus/master]
[also build test WARNING on v5.13 next-20210628]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Neil-Armstrong/scatterlist-add-I-O-variant-of-sg_pcopy-sg_copy-and-use-them/20210628-203511
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 62fb9874f5da54fdb243003b386128037319b219
:::::: branch date: 8 hours ago
:::::: commit date: 8 hours ago
config: i386-randconfig-s001-20210628 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/743501a6aa75533e65fbb9df89b85ec69ca27a3e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Neil-Armstrong/scatterlist-add-I-O-variant-of-sg_pcopy-sg_copy-and-use-them/20210628-203511
        git checkout 743501a6aa75533e65fbb9df89b85ec69ca27a3e
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
   lib/scatterlist.c:1050:8: sparse: sparse: symbol 'sg_copy_from_io' redeclared with different type (incompatible argument 3 (different address spaces)):
>> lib/scatterlist.c:1050:8: sparse:    unsigned int extern [addressable] [toplevel] [unsigned] sg_copy_from_io( ... )
   lib/scatterlist.c: note: in included file:
   include/linux/scatterlist.h:319:8: sparse: note: previously declared as:
>> include/linux/scatterlist.h:319:8: sparse:    unsigned int extern [addressable] [toplevel] [unsigned] sg_copy_from_io( ... )

vim +1050 lib/scatterlist.c

df642cea25c90d Akinobu Mita   2013-07-08  1039  
743501a6aa7553 Neil Armstrong 2021-06-28  1040  /**
743501a6aa7553 Neil Armstrong 2021-06-28  1041   * sg_copy_from_io - Copy from an I/O mapped buffer to an SG list
743501a6aa7553 Neil Armstrong 2021-06-28  1042   * @sgl:		 The SG list
743501a6aa7553 Neil Armstrong 2021-06-28  1043   * @nents:		 Number of SG entries
743501a6aa7553 Neil Armstrong 2021-06-28  1044   * @buf:		 Where to copy from
743501a6aa7553 Neil Armstrong 2021-06-28  1045   * @buflen:		 The number of bytes to copy
743501a6aa7553 Neil Armstrong 2021-06-28  1046   *
743501a6aa7553 Neil Armstrong 2021-06-28  1047   * Returns the number of copied bytes.
743501a6aa7553 Neil Armstrong 2021-06-28  1048   *
743501a6aa7553 Neil Armstrong 2021-06-28  1049   **/
743501a6aa7553 Neil Armstrong 2021-06-28 @1050  size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
743501a6aa7553 Neil Armstrong 2021-06-28  1051  		       const void *buf, size_t buflen)
743501a6aa7553 Neil Armstrong 2021-06-28  1052  {
743501a6aa7553 Neil Armstrong 2021-06-28  1053  	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, 0, false);
743501a6aa7553 Neil Armstrong 2021-06-28  1054  }
743501a6aa7553 Neil Armstrong 2021-06-28  1055  EXPORT_SYMBOL(sg_copy_from_io);
743501a6aa7553 Neil Armstrong 2021-06-28  1056  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 50720 bytes --]

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

* Re: [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy
@ 2021-06-28 17:09 kernel test robot
  0 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2021-06-28 17:09 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3969 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210628123411.119778-2-narmstrong@baylibre.com>
References: <20210628123411.119778-2-narmstrong@baylibre.com>
TO: Neil Armstrong <narmstrong@baylibre.com>

Hi Neil,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on linus/master]
[also build test WARNING on v5.13 next-20210628]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Neil-Armstrong/scatterlist-add-I-O-variant-of-sg_pcopy-sg_copy-and-use-them/20210628-203511
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 62fb9874f5da54fdb243003b386128037319b219
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: sparc-randconfig-s032-20210628 (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/743501a6aa75533e65fbb9df89b85ec69ca27a3e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Neil-Armstrong/scatterlist-add-I-O-variant-of-sg_pcopy-sg_copy-and-use-them/20210628-203511
        git checkout 743501a6aa75533e65fbb9df89b85ec69ca27a3e
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sparc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
   lib/scatterlist.c:1050:8: sparse: sparse: symbol 'sg_copy_from_io' redeclared with different type (incompatible argument 3 (different address spaces)):
>> lib/scatterlist.c:1050:8: sparse:    unsigned long extern [addressable] [toplevel] [unsigned] sg_copy_from_io( ... )
   lib/scatterlist.c: note: in included file:
   include/linux/scatterlist.h:319:8: sparse: note: previously declared as:
>> include/linux/scatterlist.h:319:8: sparse:    unsigned long extern [addressable] [toplevel] [unsigned] sg_copy_from_io( ... )

vim +1050 lib/scatterlist.c

df642cea25c90d Akinobu Mita   2013-07-08  1039  
743501a6aa7553 Neil Armstrong 2021-06-28  1040  /**
743501a6aa7553 Neil Armstrong 2021-06-28  1041   * sg_copy_from_io - Copy from an I/O mapped buffer to an SG list
743501a6aa7553 Neil Armstrong 2021-06-28  1042   * @sgl:		 The SG list
743501a6aa7553 Neil Armstrong 2021-06-28  1043   * @nents:		 Number of SG entries
743501a6aa7553 Neil Armstrong 2021-06-28  1044   * @buf:		 Where to copy from
743501a6aa7553 Neil Armstrong 2021-06-28  1045   * @buflen:		 The number of bytes to copy
743501a6aa7553 Neil Armstrong 2021-06-28  1046   *
743501a6aa7553 Neil Armstrong 2021-06-28  1047   * Returns the number of copied bytes.
743501a6aa7553 Neil Armstrong 2021-06-28  1048   *
743501a6aa7553 Neil Armstrong 2021-06-28  1049   **/
743501a6aa7553 Neil Armstrong 2021-06-28 @1050  size_t sg_copy_from_io(struct scatterlist *sgl, unsigned int nents,
743501a6aa7553 Neil Armstrong 2021-06-28  1051  		       const void *buf, size_t buflen)
743501a6aa7553 Neil Armstrong 2021-06-28  1052  {
743501a6aa7553 Neil Armstrong 2021-06-28  1053  	return sg_copy_io(sgl, nents, (void __iomem *)buf, buflen, 0, false);
743501a6aa7553 Neil Armstrong 2021-06-28  1054  }
743501a6aa7553 Neil Armstrong 2021-06-28  1055  EXPORT_SYMBOL(sg_copy_from_io);
743501a6aa7553 Neil Armstrong 2021-06-28  1056  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 25612 bytes --]

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

end of thread, other threads:[~2021-06-28 20:14 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 12:34 [PATCH RFC 0/2] scatterlist: add I/O variant of sg_pcopy & sg_copy and use them Neil Armstrong
2021-06-28 12:34 ` Neil Armstrong
2021-06-28 12:34 ` Neil Armstrong
2021-06-28 12:34 ` [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy Neil Armstrong
2021-06-28 12:34   ` Neil Armstrong
2021-06-28 12:34   ` Neil Armstrong
2021-06-28 13:40   ` Robin Murphy
2021-06-28 13:40     ` Robin Murphy
2021-06-28 13:40     ` Robin Murphy
2021-06-28 12:34 ` [PATCH RFC 2/2] mmc: meson-gx: use sg_copy_to/from_io instead of local version Neil Armstrong
2021-06-28 12:34   ` Neil Armstrong
2021-06-28 12:34   ` Neil Armstrong
2021-06-28 13:44   ` Robin Murphy
2021-06-28 13:44     ` Robin Murphy
2021-06-28 13:44     ` Robin Murphy
2021-06-28 17:09 [PATCH RFC 1/2] scatterlist: add I/O variant of sg_pcopy & sg_copy kernel test robot
2021-06-28 20:14 kernel test robot

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.