From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54585 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAnIj-00036r-4Z for qemu-devel@nongnu.org; Tue, 26 Oct 2010 13:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PAnIh-0002nW-Qc for qemu-devel@nongnu.org; Tue, 26 Oct 2010 13:27:09 -0400 Received: from mail-qy0-f180.google.com ([209.85.216.180]:57159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PAnIh-0002nR-ON for qemu-devel@nongnu.org; Tue, 26 Oct 2010 13:27:07 -0400 Received: by qyk8 with SMTP id 8so3264711qyk.4 for ; Tue, 26 Oct 2010 10:27:06 -0700 (PDT) Message-ID: <4CC70F65.7050506@codemonkey.ws> Date: Tue, 26 Oct 2010 12:27:01 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/2] Type-safe ioport callbacks References: <1287934469-16624-1-git-send-email-avi@redhat.com> <1287934469-16624-2-git-send-email-avi@redhat.com> <4CC55554.4060103@redhat.com> <4CC68BE1.5010207@redhat.com> <4CC70D5D.4020109@redhat.com> In-Reply-To: <4CC70D5D.4020109@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Blue Swirl , qemu-devel@nongnu.org, kvm@vger.kernel.org On 10/26/2010 12:18 PM, Avi Kivity wrote: > On 10/26/2010 05:09 PM, Blue Swirl wrote: >> On Tue, Oct 26, 2010 at 8:05 AM, Avi Kivity wrote: >> > On 10/25/2010 08:38 PM, Blue Swirl wrote: >> >> >> >> > >> >> > I don't really see why we need registration; >> cpu_register_io() takes >> >> > function pointers, a size, and an opaque, and gives an >> integer handle >> >> > in >> >> > return. With the IOPort object approach, you set up the >> IOPort with >> >> > function pointers, size is implied, and the opaque is derived >> using >> >> > container_of(); the handle is simply the address of the object. >> >> >> >> With the handle, we can separate setting up the structures at device >> >> level, and mapping the object using only the handle at bus or other >> >> higher level. Can this be done with the object approach? >> > >> > I believe so. The handle is simply an indirect pointer, no? >> >> Yes, but then the object should also contain size information. That >> should not be needed for mapping at higher level. > > Sorry, I don't follow your meaning. > > When I said "size is implied" I meant that the IOPort object has a > separate function pointer for sizes 1, 2, and 4, so it > ioport_register() doesn't need a size parameter. But I don't see how > that relates to your comment. Yeah, I don't think it makes sense to combine "this is how to dispatch I/O" with "this is a region of I/O address space". I think an IORegion should contain an IOPort structure though. I think the name needs rethinking. Maybe: struct PortIOHandler; struct MemoryIOHandler; And it would be good to add a memory callback to this series too. Regards, Anthony Liguori >> >> The purpose of that patch series was to perform the separation >> for PCI >> >> BARs. I wasn't so happy with the series, so I never pushed. >> > >> > In fact I think an IOPort is even more suitable; if we need >> additional >> > attributes we can use a derived object: >> > >> > struct PCIIOPort { >> > IOPort ioport; >> > /* additional fields */ >> > }; >> >> One issue with my series was that it would be great if the devices >> just had some BAR structures (used by PCI layer to map the devices) >> inside PCI/qdev structures, but I invented that too late. Maybe this >> can be addressed in your design? > > It looks to be orthogonal. It would be great to have a BAR object; > that object can then use your API, my API, or the existing API. >