From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH 2 of 5] add can_dma/post_dma for direct IO Date: Sat, 13 Dec 2008 16:47:07 -0600 Message-ID: <49443B6B.3030907@codemonkey.ws> References: <4942B841.6010900@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Gerd Hoffmann , qemu-devel@nongnu.org, kvm@vger.kernel.org, avi@redhat.com, chrisw@redhat.com To: Andrea Arcangeli Return-path: Received: from yx-out-2324.google.com ([74.125.44.29]:2641 "EHLO yx-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751585AbYLMWrN (ORCPT ); Sat, 13 Dec 2008 17:47:13 -0500 Received: by yx-out-2324.google.com with SMTP id 8so903783yxm.1 for ; Sat, 13 Dec 2008 14:47:11 -0800 (PST) In-Reply-To: <4942B841.6010900@codemonkey.ws> Sender: kvm-owner@vger.kernel.org List-ID: Anthony Liguori wrote: > > This could correspond to a: > > void *cpu_physical_memory_map(target_phys_addr_t addr, ram_addr_t > size, int is_write); > > void cpu_physical_memory_unmap(target_physical_addr_t addr, ram_addr_t > size, void *mapping, int is_dirty); A really nice touch here, and note this is optional and can be a follow up series later, would be to use the mapping itself to encode the physical address and size so the signatures were: void *cpu_physical_memory_map(target_phys_addr_t addr, ram_addr_t size, int flags); void cpu_physical_memory_unmap(void *mapping); flags could be PHYS_MAP_READ and/or PHYS_MAP_WRITE. In unmap, you could check to see if the address is in phys_ram_base ... phys_ram_size. If so, you can get the physical address. If you maintained a list of mappings, you could then search the list of mappings based on the physical address and check the flags to see if a flush was required. If you also stored the address in the list, you could search on unmap if the address was not in phys_ram_base .. phys_ram_size (which implies a bounce buffer). Another potential optimization would be to provide a mechanism to explicitly set the dirty range of a physical mapping. For instance: cpu_physical_memory_map_set_dirty(void *start, ram_addr_t size); That would let you only copy the data that actually needed to. I think we can probably ignore this later optimization for a while though. Regards, Anthony Liguori > The whole dma.c thing should not exist. If we're going to introduce a > higher level API, it should be a PCI DMA API. > > Something like virtio could use this API directly seeing as it doesn't > really live on a PCI bus in real life. > > Regards, > > Anthony Liguori >