diff mbox

[RFC,05/11] crypto: caam - Add cache coherency support to Freescale CAAM scatterlist implementation

Message ID 1434412379-11623-6-git-send-email-vicki.milhoan@freescale.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show

Commit Message

Victoria Milhoan June 15, 2015, 11:52 p.m. UTC
Add cache coherency support to the CAAM scatterlist implementation.

Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
---
 drivers/crypto/caam/sg_sw_sec4.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Herbert Xu June 16, 2015, 6:04 a.m. UTC | #1
On Mon, Jun 15, 2015 at 04:52:53PM -0700, Victoria Milhoan wrote:
>
> @@ -91,9 +91,14 @@ static int dma_map_sg_chained(struct device *dev, struct scatterlist *sg,
>  {
>  	if (unlikely(chained)) {
>  		int i;
> +	struct scatterlist *tsg = sg;
> +
> +	/* We use a local copy of the sg pointer to avoid moving the
> +	 * head of the list pointed to by sg as we wall the list.
> +	 */
>  		for (i = 0; i < nents; i++) {
> -			dma_map_sg(dev, sg, 1, dir);
> -			sg = sg_next(sg);
> +			dma_map_sg(dev, tsg, 1, dir);
> +			tsg = scatterwalk_sg_next(tsg);

Please do not use scatterwalk_sg_next as it is obsolete and is
otherwise identical to sg_next.

Cheers,
Steffen Trumtrar June 17, 2015, 7:44 a.m. UTC | #2
On Mon, Jun 15, 2015 at 04:52:53PM -0700, Victoria Milhoan wrote:
> Add cache coherency support to the CAAM scatterlist implementation.
> 
> Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
> ---
>  drivers/crypto/caam/sg_sw_sec4.h | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/crypto/caam/sg_sw_sec4.h b/drivers/crypto/caam/sg_sw_sec4.h
> index 6365585..6730b01 100644
> --- a/drivers/crypto/caam/sg_sw_sec4.h
> +++ b/drivers/crypto/caam/sg_sw_sec4.h
> @@ -91,9 +91,14 @@ static int dma_map_sg_chained(struct device *dev, struct scatterlist *sg,
>  {
>  	if (unlikely(chained)) {
>  		int i;
> +	struct scatterlist *tsg = sg;
> +
> +	/* We use a local copy of the sg pointer to avoid moving the
> +	 * head of the list pointed to by sg as we wall the list.
> +	 */
>  		for (i = 0; i < nents; i++) {
> -			dma_map_sg(dev, sg, 1, dir);
> -			sg = sg_next(sg);
> +			dma_map_sg(dev, tsg, 1, dir);
> +			tsg = scatterwalk_sg_next(tsg);
>  		}
>  	} else {
>  		dma_map_sg(dev, sg, nents, dir);
> @@ -106,6 +111,9 @@ static int dma_unmap_sg_chained(struct device *dev, struct scatterlist *sg,
>  				unsigned int nents, enum dma_data_direction dir,
>  				bool chained)
>  {
> +	if ((dir == DMA_FROM_DEVICE) || (dir == DMA_BIDIRECTIONAL))
> +		dma_sync_sg_for_cpu(dev, sg, nents, dir);
> +
>  	if (unlikely(chained)) {
>  		int i;
>  		for (i = 0; i < nents; i++) {

You don't need to sync here, because you unmap it directly afterwards.

Regards,
Steffen
diff mbox

Patch

diff --git a/drivers/crypto/caam/sg_sw_sec4.h b/drivers/crypto/caam/sg_sw_sec4.h
index 6365585..6730b01 100644
--- a/drivers/crypto/caam/sg_sw_sec4.h
+++ b/drivers/crypto/caam/sg_sw_sec4.h
@@ -91,9 +91,14 @@  static int dma_map_sg_chained(struct device *dev, struct scatterlist *sg,
 {
 	if (unlikely(chained)) {
 		int i;
+	struct scatterlist *tsg = sg;
+
+	/* We use a local copy of the sg pointer to avoid moving the
+	 * head of the list pointed to by sg as we wall the list.
+	 */
 		for (i = 0; i < nents; i++) {
-			dma_map_sg(dev, sg, 1, dir);
-			sg = sg_next(sg);
+			dma_map_sg(dev, tsg, 1, dir);
+			tsg = scatterwalk_sg_next(tsg);
 		}
 	} else {
 		dma_map_sg(dev, sg, nents, dir);
@@ -106,6 +111,9 @@  static int dma_unmap_sg_chained(struct device *dev, struct scatterlist *sg,
 				unsigned int nents, enum dma_data_direction dir,
 				bool chained)
 {
+	if ((dir == DMA_FROM_DEVICE) || (dir == DMA_BIDIRECTIONAL))
+		dma_sync_sg_for_cpu(dev, sg, nents, dir);
+
 	if (unlikely(chained)) {
 		int i;
 		for (i = 0; i < nents; i++) {