From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43023 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDIxf-0006EB-L0 for qemu-devel@nongnu.org; Tue, 02 Nov 2010 11:39:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDIxd-0007Fl-AV for qemu-devel@nongnu.org; Tue, 02 Nov 2010 11:39:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDIxc-0007FX-Uw for qemu-devel@nongnu.org; Tue, 02 Nov 2010 11:39:45 -0400 Date: Tue, 2 Nov 2010 17:39:43 +0200 From: "Michael S. Tsirkin" Message-ID: <20101102153943.GA32448@redhat.com> References: <20101102053544.10424.42769.stgit@s20.home> <20101102053751.10424.7525.stgit@s20.home> <20101102092508.GA3390@redhat.com> <1288706438.3045.7.camel@x201> <20101102140736.GB29373@redhat.com> <1288707790.3045.18.camel@x201> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1288707790.3045.18.camel@x201> Subject: [Qemu-devel] Re: [PATCH 3/3] msi: Store the capability size in PCIDevice List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: yamahata@valinux.co.jp, qemu-devel@nongnu.org On Tue, Nov 02, 2010 at 08:23:10AM -0600, Alex Williamson wrote: > On Tue, 2010-11-02 at 16:07 +0200, Michael S. Tsirkin wrote: > > On Tue, Nov 02, 2010 at 08:00:38AM -0600, Alex Williamson wrote: > > > On Tue, 2010-11-02 at 11:25 +0200, Michael S. Tsirkin wrote: > > > > On Mon, Nov 01, 2010 at 11:37:53PM -0600, Alex Williamson wrote: > > > > > Avoid needing to get the MSI capability flags every time we need to > > > > > check the capability length. This also makes it accessible outside > > > > > of msi.c, making it easier for users to filter config space writes > > > > > using msi_cap and msi_cap_size. > > > > > > > > I think for this last use-case, we are better off with returning a > > > > boolean from msi_write_config which tells us whether the write is in > > > > range. This has the advantage in that it will also work well for other > > > > capabilities. Or second best, if that is insufficient for some reason, > > > > export an msi_cap_size function. > > > > > > Returning whether the write was in range isn't enough. For device > > > assignment, I need to know whether the capability was enabled or > > > disabled. This currently means checking the enable state before and > > > after calling msi_write_config and doing the appropriate backend setup. > > > > Sounds good. Why does this mean you need the capability size? > > bool was_enabled = msi_enabled(dev); > > msi_write_config(..) > > if (was_enabled != msi_enabled(dev)) { > > } > > Because this code makes me sad... > > bool msi_was_enabled, msix_was_enabled, msi_is_enabled, msix_is_enabled; > > msi_was_enabled = msi_enabled(dev); > msix_was_enabled = msix_enabled(dev); > > pci_default_write_config(... > msi_write_config(... > msix_write_config(... > > msi_is_enabled = msi_enabled(dev); > msix_is_enabled = msix_enabled(dev); > > if (msi_was_enabled && !msi_is_enabled) > disable_msi(... > if (!msi_was_enabled && msi_is_enabled) > enable_msi(... > if (msix_was_enabled && !msix_is_enabled) > disable_msi(... > if (!msix_was_enabled && msix_is_enabled) > enable_msix(... > > Confining msi tests to an msi related write and msix tests to an msix > related write makes me slightly happier. I really think we need > callbacks though so common msi/msix code can figure out if we've made a > transition. > > Alex This is what we have in qemu-kvm for vhost now, and the code turned out to be terribly hard to get right. I would rather not repeat that, and I would love to rip out the callbacks we have now, too. One approach would be to simply fold the handling of irqfds into msix.c. Having said all that, I really don't understand why does VFIO force you to figure out that e.g. msix was enabled/disabled. Can we not get the config write and simply call write() on VFIO? That is an interface that makes sense to me. > > > I think the only way I could blindly call the msi/x write config > > > routines is if we init the capability with enable/disable callbacks. > > > I'd be ok with an msi_cap_size function if we don't want to go that far > > > too. What do you prefer? Thanks, > >