From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Scatter-Gather buffer allocation before running on HDSP-MADI ? Date: Fri, 10 Oct 2003 14:06:59 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <16254.61960.840856.972245@seneca.iemnet> <1065460748.3f81a40c61063@iem.at> <16258.59662.729091.684464@seneca.iemnet> <1065776616.3f8675e8b202e@iem.at> Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: Errors-To: alsa-devel-admin@lists.sourceforge.net List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: Jaroslav Kysela Cc: ritsch@iem.at, alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Fri, 10 Oct 2003 13:57:10 +0200 (CEST), Jaroslav wrote: > > On Fri, 10 Oct 2003, Takashi Iwai wrote: > > > At Fri, 10 Oct 2003 11:03:36 +0200 (CEST), > > ritsch@iem.at wrote: > > > > > > Hello, > > > > > > > > > the hdsp-madi card with the hdspm driver seems to work now. > > > so I want do a clean out of the code: > > > > > > I asking how should I do this: > > > > > > > > at least I have to allocate one page more = 4194304+4096, to get no > > > > > Segmentation fault, but that could be the hardware too, since hdsp > > > > > also needs one page more ? > > > > > > > > the SG-buffer allocation size is aligned (round up) to PAGE_SIZE. > > > > (note that PAGE_SIZE is not always 4K byte on other architectures.) > > > > > > > > > > Ok on my i386 architecture I have 4k pages and > > > the rme card needs 4k buffers. > > > > > > So how to code this that it works on all architectures getting > > > a SG Buf with 4k buffers. > > > > > > Do I have to do something by doing preallocation ? > > > > on linux, the least page size is 4K byte (so far, all architectures > > are so). thus, simply do a loop like > > Nope. Old alpha arch has 8K pages. well, i wrote "least" size in the above :) in fact, ia64 can have up to 64kb pages (configurable). the page size is equal with or greater than 4k. and since the size is power of two, the kernel page is always aligned (at least) to 4k boundary. > > offset = 0; /* bytes */ > > while (offset < total_size) { > > dma_addr_t addr = snd_sgbuf_get_addr(sgbuf, offset); > > map_this_addr_to_my_hw_table(addr); > > offset += 4096; /* 4k */ > > I suggest to use PAGE_SIZE define here. no, it must be 4096 (or better to define other const), which corresponds to the page size of the sound card. the point of the code above is: - the hardware page size is 4k byte independent from archs. - you can use snd_sgbuf_get_addr() macro to retrieve the physical address of each 4k page regardless of the kernel page size. Takashi ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects. See the people who have HELPED US provide better services: Click here: http://sourceforge.net/supporters.php