From mboxrd@z Thu Jan 1 00:00:00 1970 From: Russell King - ARM Linux Subject: Re: [PATCH 2/4] scatterlist: add sg_alloc_table_from_buf() helper Date: Thu, 31 Mar 2016 15:14:13 +0100 Message-ID: <20160331141412.GK19428@n2100.arm.linux.org.uk> References: <1459427384-21374-1-git-send-email-boris.brezillon@free-electrons.com> <1459427384-21374-3-git-send-email-boris.brezillon@free-electrons.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: David Woodhouse , Brian Norris , linux-mtd@lists.infradead.org, Andrew Morton , Dave Gordon , linux-crypto@vger.kernel.org, Herbert Xu , Vinod Koul , Richard Weinberger , Joerg Roedel , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Vignesh R , linux-mm@kvack.org, iommu@lists.linux-foundation.org, Mark Brown , Hans Verkuil , Laurent Pinchart , dmaengine@vger.kernel.org, Dan Williams , linux-media@vger.kernel.org, "David S. Miller" , linux-arm-kernel@lists.infradead.org, Mauro Carvalho Chehab To: Boris Brezillon Return-path: Received: from pandora.arm.linux.org.uk ([78.32.30.218]:44795 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751500AbcCaOOn (ORCPT ); Thu, 31 Mar 2016 10:14:43 -0400 Content-Disposition: inline In-Reply-To: <1459427384-21374-3-git-send-email-boris.brezillon@free-electrons.com> Sender: linux-crypto-owner@vger.kernel.org List-ID: On Thu, Mar 31, 2016 at 02:29:42PM +0200, Boris Brezillon wrote: > sg_alloc_table_from_buf() provides an easy solution to create an sg_table > from a virtual address pointer. This function takes care of dealing with > vmallocated buffers, buffer alignment, or DMA engine limitations (maximum > DMA transfer size). Please note that the DMA API does not take account of coherency of memory regions other than non-high/lowmem - there are specific extensions to deal with this. What this means is that having an API that takes any virtual address pointer, converts it to a scatterlist which is then DMA mapped, is unsafe. It'll be okay for PIPT and non-aliasing VIPT cache architectures, but for other cache architectures this will hide this problem and make review harder. -- RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by kanga.kvack.org (Postfix) with ESMTP id EF2AE6B007E for ; Thu, 31 Mar 2016 10:15:01 -0400 (EDT) Received: by mail-wm0-f47.google.com with SMTP id p65so227248713wmp.1 for ; Thu, 31 Mar 2016 07:15:01 -0700 (PDT) Received: from pandora.arm.linux.org.uk (pandora.arm.linux.org.uk. [2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by mx.google.com with ESMTPS id h133si12652445wmf.124.2016.03.31.07.15.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 31 Mar 2016 07:15:00 -0700 (PDT) Date: Thu, 31 Mar 2016 15:14:13 +0100 From: Russell King - ARM Linux Subject: Re: [PATCH 2/4] scatterlist: add sg_alloc_table_from_buf() helper Message-ID: <20160331141412.GK19428@n2100.arm.linux.org.uk> References: <1459427384-21374-1-git-send-email-boris.brezillon@free-electrons.com> <1459427384-21374-3-git-send-email-boris.brezillon@free-electrons.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1459427384-21374-3-git-send-email-boris.brezillon@free-electrons.com> Sender: owner-linux-mm@kvack.org List-ID: To: Boris Brezillon Cc: David Woodhouse , Brian Norris , linux-mtd@lists.infradead.org, Andrew Morton , Dave Gordon , linux-crypto@vger.kernel.org, Herbert Xu , Vinod Koul , Richard Weinberger , Joerg Roedel , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Vignesh R , linux-mm@kvack.org, iommu@lists.linux-foundation.org, Mark Brown , Hans Verkuil , Laurent Pinchart , dmaengine@vger.kernel.org, Dan Williams , linux-media@vger.kernel.org, "David S. Miller" , linux-arm-kernel@lists.infradead.org, Mauro Carvalho Chehab On Thu, Mar 31, 2016 at 02:29:42PM +0200, Boris Brezillon wrote: > sg_alloc_table_from_buf() provides an easy solution to create an sg_table > from a virtual address pointer. This function takes care of dealing with > vmallocated buffers, buffer alignment, or DMA engine limitations (maximum > DMA transfer size). Please note that the DMA API does not take account of coherency of memory regions other than non-high/lowmem - there are specific extensions to deal with this. What this means is that having an API that takes any virtual address pointer, converts it to a scatterlist which is then DMA mapped, is unsafe. It'll be okay for PIPT and non-aliasing VIPT cache architectures, but for other cache architectures this will hide this problem and make review harder. -- RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: linux@arm.linux.org.uk (Russell King - ARM Linux) Date: Thu, 31 Mar 2016 15:14:13 +0100 Subject: [PATCH 2/4] scatterlist: add sg_alloc_table_from_buf() helper In-Reply-To: <1459427384-21374-3-git-send-email-boris.brezillon@free-electrons.com> References: <1459427384-21374-1-git-send-email-boris.brezillon@free-electrons.com> <1459427384-21374-3-git-send-email-boris.brezillon@free-electrons.com> Message-ID: <20160331141412.GK19428@n2100.arm.linux.org.uk> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Thu, Mar 31, 2016 at 02:29:42PM +0200, Boris Brezillon wrote: > sg_alloc_table_from_buf() provides an easy solution to create an sg_table > from a virtual address pointer. This function takes care of dealing with > vmallocated buffers, buffer alignment, or DMA engine limitations (maximum > DMA transfer size). Please note that the DMA API does not take account of coherency of memory regions other than non-high/lowmem - there are specific extensions to deal with this. What this means is that having an API that takes any virtual address pointer, converts it to a scatterlist which is then DMA mapped, is unsafe. It'll be okay for PIPT and non-aliasing VIPT cache architectures, but for other cache architectures this will hide this problem and make review harder. -- RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.