From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZMp0-0002Gx-66 for qemu-devel@nongnu.org; Mon, 06 May 2013 10:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZMoz-0006pU-1J for qemu-devel@nongnu.org; Mon, 06 May 2013 10:55:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZMoy-0006pK-Ii for qemu-devel@nongnu.org; Mon, 06 May 2013 10:55:20 -0400 Message-ID: <5187C436.7020403@redhat.com> Date: Mon, 06 May 2013 16:54:46 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <71c94383d7247e68bfbd45786227844e37f330ce.1367849167.git.jan.kiszka@siemens.com> <5187C08A.9060702@redhat.com> <5187C388.8070202@siemens.com> In-Reply-To: <5187C388.8070202@siemens.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC][PATCH 09/15] memory: Introduce address_space_lookup_region List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Liu Ping Fan , qemu-devel , =?ISO-8859-15?Q?Andreas_F=E4rbe?= =?ISO-8859-15?Q?r?= Il 06/05/2013 16:51, Jan Kiszka ha scritto: > On 2013-05-06 16:39, Paolo Bonzini wrote: >> Il 06/05/2013 16:26, Jan Kiszka ha scritto: >>> This new service so far only replaces phys_page_find as public API. In a >>> follow-up step, it will return the effective memory region for the >>> specified address, i.e. after resolving what are currently sub-pages. >>> Moreover, it will also once encapsulate locking and reference counting >>> when we introduce BQL-free dispatching. >> >> In my IOMMU rebase I have a similar function: >> >> /* address_space_translate: translate an address range into an address space >> * into a MemoryRegionSection and an address range into that section. >> * >> * @as: #AddressSpace to be accessed >> * @addr: address within that address space >> * @xlat: pointer to address within the returned memory region section's >> * #MemoryRegion. >> * @len: pointer to length >> * @is_write: indicates the transfer direction >> */ >> MemoryRegionSection *address_space_translate(AddressSpace *as, hwaddr addr, >> hwaddr *xlat, hwaddr *len, >> bool is_write); >> >> It wraps (actually, replaces) both phys_page_find and >> memory_region_section_addr. > > Good, looks like we are heading in similar directions. What is the > purpose of len? When does is_write matter? Both matter when adding the IOMMU. is_write is needed to check for permissions, and len because the translation will be valid for one page only (not for the full size of the MemoryRegion. I can implement address_space_translate on top of address_space_lookup_region and include your next patch too, so we're fine here. Paolo > In a later step, this should become something like > address_space_get_region_ref (to be paired with memory_region_unref, > once done). So this one also takes care of incrementing the reference > counter or acquiring the BQL, as necessary. Currently, it asks the > caller to specify if the BQL is already held, but that will change. > > Jan >