From: Simon Horman Subject: Re: [PATCH] [IOEMU] Fix wrong INTx for pass-through device Date: Thu, 31 Dec 2009 17:45:37 +1100 Message-ID: <20091231064531.GB12237@verge.net.au> References: <4B38589B.8060307@intel.com> <8686c3cd0912280633u27839f56k74abcd73fb041e4@mail.gmail.com> <4B394BCB.30607@intel.com> <20091229020128.GG10172@verge.net.au> <8686c3cd0912290051t76c771fdq15314f25287d3973@mail.gmail.com> <4B39C4DE.8050103@intel.com> <8686c3cd0912300020n1284bf0ele160985f5118aad4@mail.gmail.com> <20091231043241.GA30174@verge.net.au> <4B3C3FC3.40301@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="cWoXeonUoKmBZSoM" Return-path: Content-Disposition: inline In-Reply-To: <4B3C3FC3.40301@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "Zhai, Edwin" Cc: Tom Rotenberg , Xen Developers , Ian Jackson List-Id: xen-devel@lists.xenproject.org --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Dec 31, 2009 at 02:08:03PM +0800, Zhai, Edwin wrote: > Simon/Tom, > We have 3 optinos: > A. always INTA > B. always physical INTx > C. INTA if virtual function is 0, physical INTx for otherwise. > > Difference of option B and C is that guest will see a function 0 on > a single function device is linked to a PIN rather than INTA, say > assign 0:1a.7 to guest as 0:4.0. Most of OS should handle this. so > I'm okay with both. > > For option A, I'm not sure the issue for the multiple-function > device. Can we assign a multiple function device to a guest as it > is? E.g. assign physical 0:a.0/0:a.1to guest as 0:4.0/0:4.1. In this > way, with option A, there are performance issue when injecting intr > as they share same virtual GSI. Yes, the ability to make assignments like that is the crux of the multi-function work that I did earlier in the year. And the idea of not always using INTA was to avoid the performance penalty of reusing the virtual GSI. > If we can't do this now, I think option A is also good. Is any > specific reason that we change to C? Does some specific multiple > function driver assumes specific pin other than INTA? ... so A isn't such a good option (it was before and thats what was used). I think that I chose C when I added multi-function because it avoided introducing any incompatibility for single-function pass-through. But at this point I think C just introduces complexity, so I now prefer B. > BTW, pls. send your patch in attachment as I couldn't get it from > your mail:( Sure. --cWoXeonUoKmBZSoM Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pci_read_intx.patch" qemu-xen: pass-through: always use hw intx pass-through: always use hw intx and always get it from the same place Cc: Tom Rotenberg Cc: Edwin Zhai Signed-off-by: Simon Horman Index: ioemu-remote/hw/pass-through.c =================================================================== --- ioemu-remote.orig/hw/pass-through.c 2009-12-31 13:10:06.000000000 +0900 +++ ioemu-remote/hw/pass-through.c 2009-12-31 13:24:20.000000000 +0900 @@ -2710,7 +2710,7 @@ static uint32_t pt_status_reg_init(struc static uint32_t pt_irqpin_reg_init(struct pt_dev *ptdev, struct pt_reg_info_tbl *reg, uint32_t real_offset) { - return ptdev->dev.config[real_offset]; + return pci_read_intx(ptdev); } /* initialize BAR */ @@ -4471,6 +4471,11 @@ int pt_init(PCIBus *e_bus) return 0; } +static uint8_t pci_read_intx(struct pt_dev *ptdev) +{ + return pci_read_byte(ptdev->pci_dev, PCI_INTERRUPT_PIN); +} + /* The PCI Local Bus Specification, Rev. 3.0, * Section 6.2.4 Miscellaneous Registers, pp 223 * outlines 5 valid values for the intertupt pin (intx). @@ -4499,9 +4504,9 @@ int pt_init(PCIBus *e_bus) * 4 | 3 | INTD# * any other value | 0 | This should never happen, log error message */ -static uint8_t pci_read_intx(struct pt_dev *ptdev) +uint8_t pci_intx(struct pt_dev *ptdev) { - uint8_t r_val = pci_read_byte(ptdev->pci_dev, PCI_INTERRUPT_PIN); + uint8_t r_val = pci_read_intx(ptdev); PT_LOG("intx=%i\n", r_val); if (r_val < 1 || r_val > 4) @@ -4517,14 +4522,3 @@ static uint8_t pci_read_intx(struct pt_d return r_val; } - -/* - * For virtual function 0, always use INTA#, - * otherwise use the hardware value - */ -uint8_t pci_intx(struct pt_dev *ptdev) -{ - if (!PCI_FUNC(ptdev->dev.devfn)) - return 0; - return pci_read_intx(ptdev); -} --cWoXeonUoKmBZSoM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --cWoXeonUoKmBZSoM--