From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261384AbTKIVMN (ORCPT ); Sun, 9 Nov 2003 16:12:13 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261460AbTKIVMN (ORCPT ); Sun, 9 Nov 2003 16:12:13 -0500 Received: from ns.virtualhost.dk ([195.184.98.160]:50664 "EHLO virtualhost.dk") by vger.kernel.org with ESMTP id S261384AbTKIVMM (ORCPT ); Sun, 9 Nov 2003 16:12:12 -0500 Date: Sun, 9 Nov 2003 22:12:11 +0100 From: Jens Axboe To: Alan Stern Cc: linux-kernel@vger.kernel.org Subject: Re: How to allocate pages for a scatter-gather buffer? Message-ID: <20031109211211.GS2831@suse.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 09 2003, Alan Stern wrote: > Jens: > > Thanks for your help in tracking down that problem with the usb-storage > sddr09 driver. > > Now a slightly different question. Suppose I want to allocate some pages > as a scatter-gather buffer for I/O to a device. I've got the device's > dma_mask; what's the right way to convert that to a GFP bitmask for > alloc_pages() or get_free_pages()? This is a bit problematic, unfortunately... There really is no good way to do this, the best you can do is approximate. > Also, assuming I'll have to use memcpy() to transfer data into or out of > the scatter-gather buffer (so it will have to get a kernel virtual mapping > at some point), am I better off using alloc_pages() followed by > kmap_atomic()/kunmap_atomic() or get_free_pages()? Or even kmalloc()? My suggestion would be to do page allocations (not kmalloc()). With kmap that'll work just fine for you, and it's easy to extend to just use the right gfp mask if/when we ever get something that works for this. -- Jens Axboe