From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754367AbbFRJds (ORCPT ); Thu, 18 Jun 2015 05:33:48 -0400 Received: from down.free-electrons.com ([37.187.137.238]:57341 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754240AbbFRJdd (ORCPT ); Thu, 18 Jun 2015 05:33:33 -0400 Date: Thu, 18 Jun 2015 11:33:24 +0200 From: Boris Brezillon To: Russell King - ARM Linux Cc: Herbert Xu , Lior Amsalem , Andrew Lunn , Nadav Haklai , Mark Rutland , Tawfik Bayouk , Eran Ben-Avi , Jason Gunthorpe , Sebastian Hesselbarth , devicetree@vger.kernel.org, Jason Cooper , Pawel Moll , Ian Campbell , Arnaud Ebalard , Rob Herring , Gregory CLEMENT , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Kumar Gala , Imre Kaloz , "David S. Miller" Subject: Re: [PATCH v6 05/14] crypto: marvell/CESA: add TDMA support Message-ID: <20150618113324.2d469103@bbrezillon> In-Reply-To: <20150618090400.GG7557@n2100.arm.linux.org.uk> References: <1434527142-3609-1-git-send-email-boris.brezillon@free-electrons.com> <1434527142-3609-6-git-send-email-boris.brezillon@free-electrons.com> <20150617095001.GA11538@gondor.apana.org.au> <20150618090400.GG7557@n2100.arm.linux.org.uk> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Russel, On Thu, 18 Jun 2015 10:04:00 +0100 Russell King - ARM Linux wrote: > On Wed, Jun 17, 2015 at 05:50:01PM +0800, Herbert Xu wrote: > > On Wed, Jun 17, 2015 at 09:45:33AM +0200, Boris Brezillon wrote: > > > > > > + ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents, > > > + DMA_TO_DEVICE); > > > + if (!ret) > > > + return -ENOMEM; > > > + > > > + creq->src_nents = ret; > > > > DMA-API-HOWTO says that you must retain the original nents and > > use it when you call dma_unmap_sg. So I'm afraid one more repost > > is needed :) > > It's worse than that... You're right on that point, but there's an > additional point. > > If dma_map_sg() coalesces scatterlist entries, then ret will be smaller > than src_nents, and ret indicates how many scatterlist entries to be > walked during DMA - you should not use src_nents for that. I couldn't > see where the driver used that information. In fact, the driver seems > to be capable of walking more than src_nents/ret numbers of scatterlist > entries: it just keeps going with sg_next() until it hits the end of > the allocated scatterlist. Yes, I realized that, and I never used the value returned by dma_map_sg() to walk the scatterlist anyway: I was using the sg_next() and sg->length value (which I replaced by sg_dma_len() in v7 as suggested by Herbert). So the ->src_nents assignment to dma_map_sg() return value was just a silly mistake caused by an uncareful read of the DMA-API-HOWTO. Am I missing something else ? Best Regards, Boris -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Brezillon Subject: Re: [PATCH v6 05/14] crypto: marvell/CESA: add TDMA support Date: Thu, 18 Jun 2015 11:33:24 +0200 Message-ID: <20150618113324.2d469103@bbrezillon> References: <1434527142-3609-1-git-send-email-boris.brezillon@free-electrons.com> <1434527142-3609-6-git-send-email-boris.brezillon@free-electrons.com> <20150617095001.GA11538@gondor.apana.org.au> <20150618090400.GG7557@n2100.arm.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Herbert Xu , Lior Amsalem , Andrew Lunn , Nadav Haklai , Mark Rutland , Tawfik Bayouk , Eran Ben-Avi , Jason Gunthorpe , Sebastian Hesselbarth , devicetree@vger.kernel.org, Jason Cooper , Pawel Moll , Ian Campbell , Arnaud Ebalard , Rob Herring , Gregory CLEMENT , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Kumar Gala , Imre Kaloz , "David S. Miller" Return-path: Received: from down.free-electrons.com ([37.187.137.238]:57341 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754240AbbFRJdd (ORCPT ); Thu, 18 Jun 2015 05:33:33 -0400 In-Reply-To: <20150618090400.GG7557@n2100.arm.linux.org.uk> Sender: linux-crypto-owner@vger.kernel.org List-ID: Hi Russel, On Thu, 18 Jun 2015 10:04:00 +0100 Russell King - ARM Linux wrote: > On Wed, Jun 17, 2015 at 05:50:01PM +0800, Herbert Xu wrote: > > On Wed, Jun 17, 2015 at 09:45:33AM +0200, Boris Brezillon wrote: > > > > > > + ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents, > > > + DMA_TO_DEVICE); > > > + if (!ret) > > > + return -ENOMEM; > > > + > > > + creq->src_nents = ret; > > > > DMA-API-HOWTO says that you must retain the original nents and > > use it when you call dma_unmap_sg. So I'm afraid one more repost > > is needed :) > > It's worse than that... You're right on that point, but there's an > additional point. > > If dma_map_sg() coalesces scatterlist entries, then ret will be smaller > than src_nents, and ret indicates how many scatterlist entries to be > walked during DMA - you should not use src_nents for that. I couldn't > see where the driver used that information. In fact, the driver seems > to be capable of walking more than src_nents/ret numbers of scatterlist > entries: it just keeps going with sg_next() until it hits the end of > the allocated scatterlist. Yes, I realized that, and I never used the value returned by dma_map_sg() to walk the scatterlist anyway: I was using the sg_next() and sg->length value (which I replaced by sg_dma_len() in v7 as suggested by Herbert). So the ->src_nents assignment to dma_map_sg() return value was just a silly mistake caused by an uncareful read of the DMA-API-HOWTO. Am I missing something else ? Best Regards, Boris -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Brezillon Subject: Re: [PATCH v6 05/14] crypto: marvell/CESA: add TDMA support Date: Thu, 18 Jun 2015 11:33:24 +0200 Message-ID: <20150618113324.2d469103@bbrezillon> References: <1434527142-3609-1-git-send-email-boris.brezillon@free-electrons.com> <1434527142-3609-6-git-send-email-boris.brezillon@free-electrons.com> <20150617095001.GA11538@gondor.apana.org.au> <20150618090400.GG7557@n2100.arm.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150618090400.GG7557@n2100.arm.linux.org.uk> Sender: linux-crypto-owner@vger.kernel.org To: Russell King - ARM Linux Cc: Herbert Xu , Lior Amsalem , Andrew Lunn , Nadav Haklai , Mark Rutland , Tawfik Bayouk , Eran Ben-Avi , Jason Gunthorpe , Sebastian Hesselbarth , devicetree@vger.kernel.org, Jason Cooper , Pawel Moll , Ian Campbell , Arnaud Ebalard , Rob Herring , Gregory CLEMENT , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Kumar Gala , Imre Kaloz , "David S. Miller" List-Id: devicetree@vger.kernel.org Hi Russel, On Thu, 18 Jun 2015 10:04:00 +0100 Russell King - ARM Linux wrote: > On Wed, Jun 17, 2015 at 05:50:01PM +0800, Herbert Xu wrote: > > On Wed, Jun 17, 2015 at 09:45:33AM +0200, Boris Brezillon wrote: > > > > > > + ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents, > > > + DMA_TO_DEVICE); > > > + if (!ret) > > > + return -ENOMEM; > > > + > > > + creq->src_nents = ret; > > > > DMA-API-HOWTO says that you must retain the original nents and > > use it when you call dma_unmap_sg. So I'm afraid one more repost > > is needed :) > > It's worse than that... You're right on that point, but there's an > additional point. > > If dma_map_sg() coalesces scatterlist entries, then ret will be smaller > than src_nents, and ret indicates how many scatterlist entries to be > walked during DMA - you should not use src_nents for that. I couldn't > see where the driver used that information. In fact, the driver seems > to be capable of walking more than src_nents/ret numbers of scatterlist > entries: it just keeps going with sg_next() until it hits the end of > the allocated scatterlist. Yes, I realized that, and I never used the value returned by dma_map_sg() to walk the scatterlist anyway: I was using the sg_next() and sg->length value (which I replaced by sg_dma_len() in v7 as suggested by Herbert). So the ->src_nents assignment to dma_map_sg() return value was just a silly mistake caused by an uncareful read of the DMA-API-HOWTO. Am I missing something else ? Best Regards, Boris -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: boris.brezillon@free-electrons.com (Boris Brezillon) Date: Thu, 18 Jun 2015 11:33:24 +0200 Subject: [PATCH v6 05/14] crypto: marvell/CESA: add TDMA support In-Reply-To: <20150618090400.GG7557@n2100.arm.linux.org.uk> References: <1434527142-3609-1-git-send-email-boris.brezillon@free-electrons.com> <1434527142-3609-6-git-send-email-boris.brezillon@free-electrons.com> <20150617095001.GA11538@gondor.apana.org.au> <20150618090400.GG7557@n2100.arm.linux.org.uk> Message-ID: <20150618113324.2d469103@bbrezillon> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Russel, On Thu, 18 Jun 2015 10:04:00 +0100 Russell King - ARM Linux wrote: > On Wed, Jun 17, 2015 at 05:50:01PM +0800, Herbert Xu wrote: > > On Wed, Jun 17, 2015 at 09:45:33AM +0200, Boris Brezillon wrote: > > > > > > + ret = dma_map_sg(cesa_dev->dev, req->src, creq->src_nents, > > > + DMA_TO_DEVICE); > > > + if (!ret) > > > + return -ENOMEM; > > > + > > > + creq->src_nents = ret; > > > > DMA-API-HOWTO says that you must retain the original nents and > > use it when you call dma_unmap_sg. So I'm afraid one more repost > > is needed :) > > It's worse than that... You're right on that point, but there's an > additional point. > > If dma_map_sg() coalesces scatterlist entries, then ret will be smaller > than src_nents, and ret indicates how many scatterlist entries to be > walked during DMA - you should not use src_nents for that. I couldn't > see where the driver used that information. In fact, the driver seems > to be capable of walking more than src_nents/ret numbers of scatterlist > entries: it just keeps going with sg_next() until it hits the end of > the allocated scatterlist. Yes, I realized that, and I never used the value returned by dma_map_sg() to walk the scatterlist anyway: I was using the sg_next() and sg->length value (which I replaced by sg_dma_len() in v7 as suggested by Herbert). So the ->src_nents assignment to dma_map_sg() return value was just a silly mistake caused by an uncareful read of the DMA-API-HOWTO. Am I missing something else ? Best Regards, Boris -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com