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: Fri, 12 Dec 2008 13:15:13 -0600 Message-ID: <4942B841.6010900@codemonkey.ws> References: 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 rn-out-0910.google.com ([64.233.170.190]:11169 "EHLO rn-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750888AbYLLTPS (ORCPT ); Fri, 12 Dec 2008 14:15:18 -0500 Received: by rn-out-0910.google.com with SMTP id k40so1438643rnd.17 for ; Fri, 12 Dec 2008 11:15:17 -0800 (PST) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Andrea Arcangeli wrote: > From: Andrea Arcangeli > > Add can_dma and post_dma methods needed before/after direct IO to guest > physical memory. > I think any API based on a can_dma abstraction is wrong. The write_post_dma thing is equally wrong. The concept of "dma" that you're introducing is not correct. The DMA API should have the following properties: 1) You attempt to map a physical address. This effectively is a lock or pin operation. a) In the process of this, you get a virtual address that you can manipulate. 2) You do your IO to the virtual address 3) You indicate how much of the memory you have dirtied 4) You unmap or unlock that memory region. The virtual address is now no longer valid. 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); 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