diff mbox

[Xen-devel,v1,08/21] x86/xen/MSI: Use MSI chip framework to configure MSI/MSI-X irq

Message ID 1409911806-10519-9-git-send-email-wangyijing@huawei.com
State New
Headers show

Commit Message

wangyijing Sept. 5, 2014, 10:09 a.m. UTC
Use MSI chip framework instead of arch MSI functions to configure
MSI/MSI-X irq. So we can manage MSI/MSI-X irq in a unified framework.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/x86/pci/xen.c |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)

Comments

David Vrabel Sept. 5, 2014, 2:29 p.m. UTC | #1
On 05/09/14 11:09, Yijing Wang wrote:
> Use MSI chip framework instead of arch MSI functions to configure
> MSI/MSI-X irq. So we can manage MSI/MSI-X irq in a unified framework.
[...]
> --- a/arch/x86/pci/xen.c
> +++ b/arch/x86/pci/xen.c
[...]
> @@ -418,9 +430,9 @@ int __init pci_xen_init(void)
>  #endif
>  
>  #ifdef CONFIG_PCI_MSI
> -	x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
> -	x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
> -	x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
> +	xen_msi_chip.setup_irqs = xen_setup_msi_irqs;
> +	xen_msi_chip.teardown_irqs = xen_teardown_msi_irqs;
> +	x86_msi_chip = &xen_msi_chip;
>  	msi_chip.irq_mask = xen_nop_msi_mask;
>  	msi_chip.irq_unmask = xen_nop_msi_mask;

Why have these not been changed to set the x86_msi_chip.mask/unmask
fields instead?

David
wangyijing Sept. 9, 2014, 2:06 a.m. UTC | #2
On 2014/9/5 22:29, David Vrabel wrote:
> On 05/09/14 11:09, Yijing Wang wrote:
>> Use MSI chip framework instead of arch MSI functions to configure
>> MSI/MSI-X irq. So we can manage MSI/MSI-X irq in a unified framework.
> [...]
>> --- a/arch/x86/pci/xen.c
>> +++ b/arch/x86/pci/xen.c
> [...]
>> @@ -418,9 +430,9 @@ int __init pci_xen_init(void)
>>  #endif
>>  
>>  #ifdef CONFIG_PCI_MSI
>> -	x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
>> -	x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
>> -	x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
>> +	xen_msi_chip.setup_irqs = xen_setup_msi_irqs;
>> +	xen_msi_chip.teardown_irqs = xen_teardown_msi_irqs;
>> +	x86_msi_chip = &xen_msi_chip;
>>  	msi_chip.irq_mask = xen_nop_msi_mask;
>>  	msi_chip.irq_unmask = xen_nop_msi_mask;
> 
> Why have these not been changed to set the x86_msi_chip.mask/unmask
> fields instead?

Hi David, x86_msi_chip here is struct msi_chip data type, used to configure MSI/MSI-X
irq. msi_chip above is struct irq_chip data type, represent the MSI irq controller. They are
not the same object. Their name easily confusing people.

Defined in arch/x86/kernel/apic/io_apic.c
/*
 * IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices,
 * which implement the MSI or MSI-X Capability Structure.
 */
static struct irq_chip msi_chip = {
	.name			= "PCI-MSI",
	.irq_unmask		= unmask_msi_irq,
	.irq_mask		= mask_msi_irq,
	.irq_ack		= ack_apic_edge,
	.irq_set_affinity	= msi_set_affinity,
	.irq_retrigger		= ioapic_retrigger_irq,
};


Defined in arch/x86/kernel/apic/io_apic.c, introduced in patch 7/21
struct msi_chip apic_msi_chip = {
	.setup_irqs = native_setup_msi_irqs,
	.teardown_irq = native_teardown_msi_irq,
};
[...]
struct msi_chip *x86_msi_chip = &apic_msi_chip;


Thanks!
Yijing.

> 
> David
> 
> .
>
David Vrabel Sept. 10, 2014, 12:38 p.m. UTC | #3
On 09/09/14 03:06, Yijing Wang wrote:
> On 2014/9/5 22:29, David Vrabel wrote:
>> On 05/09/14 11:09, Yijing Wang wrote:
>>> Use MSI chip framework instead of arch MSI functions to configure
>>> MSI/MSI-X irq. So we can manage MSI/MSI-X irq in a unified framework.
>> [...]
>>> --- a/arch/x86/pci/xen.c
>>> +++ b/arch/x86/pci/xen.c
>> [...]
>>> @@ -418,9 +430,9 @@ int __init pci_xen_init(void)
>>>  #endif
>>>  
>>>  #ifdef CONFIG_PCI_MSI
>>> -	x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
>>> -	x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
>>> -	x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
>>> +	xen_msi_chip.setup_irqs = xen_setup_msi_irqs;
>>> +	xen_msi_chip.teardown_irqs = xen_teardown_msi_irqs;
>>> +	x86_msi_chip = &xen_msi_chip;
>>>  	msi_chip.irq_mask = xen_nop_msi_mask;
>>>  	msi_chip.irq_unmask = xen_nop_msi_mask;
>>
>> Why have these not been changed to set the x86_msi_chip.mask/unmask
>> fields instead?
> 
> Hi David, x86_msi_chip here is struct msi_chip data type, used to configure MSI/MSI-X
> irq. msi_chip above is struct irq_chip data type, represent the MSI irq controller. They are
> not the same object. Their name easily confusing people.

Ok, it all makes sense now.

Acked-by: David Vrabel <david.vrabel@citrix.com>

David
Konrad Rzeszutek Wilk Sept. 10, 2014, 2:59 p.m. UTC | #4
On Wed, Sep 10, 2014 at 01:38:25PM +0100, David Vrabel wrote:
> On 09/09/14 03:06, Yijing Wang wrote:
> > On 2014/9/5 22:29, David Vrabel wrote:
> >> On 05/09/14 11:09, Yijing Wang wrote:
> >>> Use MSI chip framework instead of arch MSI functions to configure
> >>> MSI/MSI-X irq. So we can manage MSI/MSI-X irq in a unified framework.
> >> [...]
> >>> --- a/arch/x86/pci/xen.c
> >>> +++ b/arch/x86/pci/xen.c
> >> [...]
> >>> @@ -418,9 +430,9 @@ int __init pci_xen_init(void)
> >>>  #endif
> >>>  
> >>>  #ifdef CONFIG_PCI_MSI
> >>> -	x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
> >>> -	x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
> >>> -	x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
> >>> +	xen_msi_chip.setup_irqs = xen_setup_msi_irqs;
> >>> +	xen_msi_chip.teardown_irqs = xen_teardown_msi_irqs;
> >>> +	x86_msi_chip = &xen_msi_chip;
> >>>  	msi_chip.irq_mask = xen_nop_msi_mask;
> >>>  	msi_chip.irq_unmask = xen_nop_msi_mask;
> >>
> >> Why have these not been changed to set the x86_msi_chip.mask/unmask
> >> fields instead?
> > 
> > Hi David, x86_msi_chip here is struct msi_chip data type, used to configure MSI/MSI-X
> > irq. msi_chip above is struct irq_chip data type, represent the MSI irq controller. They are
> > not the same object. Their name easily confusing people.
> 
> Ok, it all makes sense now.
> 
> Acked-by: David Vrabel <david.vrabel@citrix.com>

You can also add 'Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>'

on the whole series - I ran it through on Xen and on baremetal with a mix of 32/64 builds.

Oh, and also Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> the Xen parts.

> 
> David
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
wangyijing Sept. 11, 2014, 1:27 a.m. UTC | #5
On 2014/9/10 20:38, David Vrabel wrote:
> On 09/09/14 03:06, Yijing Wang wrote:
>> On 2014/9/5 22:29, David Vrabel wrote:
>>> On 05/09/14 11:09, Yijing Wang wrote:
>>>> Use MSI chip framework instead of arch MSI functions to configure
>>>> MSI/MSI-X irq. So we can manage MSI/MSI-X irq in a unified framework.
>>> [...]
>>>> --- a/arch/x86/pci/xen.c
>>>> +++ b/arch/x86/pci/xen.c
>>> [...]
>>>> @@ -418,9 +430,9 @@ int __init pci_xen_init(void)
>>>>  #endif
>>>>  
>>>>  #ifdef CONFIG_PCI_MSI
>>>> -	x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
>>>> -	x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
>>>> -	x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
>>>> +	xen_msi_chip.setup_irqs = xen_setup_msi_irqs;
>>>> +	xen_msi_chip.teardown_irqs = xen_teardown_msi_irqs;
>>>> +	x86_msi_chip = &xen_msi_chip;
>>>>  	msi_chip.irq_mask = xen_nop_msi_mask;
>>>>  	msi_chip.irq_unmask = xen_nop_msi_mask;
>>>
>>> Why have these not been changed to set the x86_msi_chip.mask/unmask
>>> fields instead?
>>
>> Hi David, x86_msi_chip here is struct msi_chip data type, used to configure MSI/MSI-X
>> irq. msi_chip above is struct irq_chip data type, represent the MSI irq controller. They are
>> not the same object. Their name easily confusing people.
> 
> Ok, it all makes sense now.
> 
> Acked-by: David Vrabel <david.vrabel@citrix.com>

Thanks!

> 
> David
> 
> .
>
wangyijing Sept. 11, 2014, 1:28 a.m. UTC | #6
On 2014/9/10 22:59, Konrad Rzeszutek Wilk wrote:
> On Wed, Sep 10, 2014 at 01:38:25PM +0100, David Vrabel wrote:
>> On 09/09/14 03:06, Yijing Wang wrote:
>>> On 2014/9/5 22:29, David Vrabel wrote:
>>>> On 05/09/14 11:09, Yijing Wang wrote:
>>>>> Use MSI chip framework instead of arch MSI functions to configure
>>>>> MSI/MSI-X irq. So we can manage MSI/MSI-X irq in a unified framework.
>>>> [...]
>>>>> --- a/arch/x86/pci/xen.c
>>>>> +++ b/arch/x86/pci/xen.c
>>>> [...]
>>>>> @@ -418,9 +430,9 @@ int __init pci_xen_init(void)
>>>>>  #endif
>>>>>  
>>>>>  #ifdef CONFIG_PCI_MSI
>>>>> -	x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
>>>>> -	x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
>>>>> -	x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
>>>>> +	xen_msi_chip.setup_irqs = xen_setup_msi_irqs;
>>>>> +	xen_msi_chip.teardown_irqs = xen_teardown_msi_irqs;
>>>>> +	x86_msi_chip = &xen_msi_chip;
>>>>>  	msi_chip.irq_mask = xen_nop_msi_mask;
>>>>>  	msi_chip.irq_unmask = xen_nop_msi_mask;
>>>>
>>>> Why have these not been changed to set the x86_msi_chip.mask/unmask
>>>> fields instead?
>>>
>>> Hi David, x86_msi_chip here is struct msi_chip data type, used to configure MSI/MSI-X
>>> irq. msi_chip above is struct irq_chip data type, represent the MSI irq controller. They are
>>> not the same object. Their name easily confusing people.
>>
>> Ok, it all makes sense now.
>>
>> Acked-by: David Vrabel <david.vrabel@citrix.com>
> 
> You can also add 'Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>'
> 
> on the whole series - I ran it through on Xen and on baremetal with a mix of 32/64 builds.
> 
> Oh, and also Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> the Xen parts.

Thanks very much for your test and review!

Thanks!
Yijing.

> 
>>
>> David
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xen.org
>> http://lists.xen.org/xen-devel
> 
> .
>
diff mbox

Patch

diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 84c2fce..e669ee4 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -376,6 +376,11 @@  static void xen_initdom_restore_msi_irqs(struct pci_dev *dev)
 }
 #endif
 
+static void xen_teardown_msi_irq(unsigned int irq)
+{
+	xen_destroy_irq(irq);
+}
+
 static void xen_teardown_msi_irqs(struct pci_dev *dev)
 {
 	struct msi_desc *msidesc;
@@ -385,19 +390,26 @@  static void xen_teardown_msi_irqs(struct pci_dev *dev)
 		xen_pci_frontend_disable_msix(dev);
 	else
 		xen_pci_frontend_disable_msi(dev);
-
-	/* Free the IRQ's and the msidesc using the generic code. */
-	default_teardown_msi_irqs(dev);
-}
-
-static void xen_teardown_msi_irq(unsigned int irq)
-{
-	xen_destroy_irq(irq);
+
+	list_for_each_entry(msidesc, &dev->msi_list, list) {
+		int i, nvec;
+		if (msidesc->irq == 0)
+			continue;
+		if (msidesc->nvec_used)
+			nvec = msidesc->nvec_used;
+		else
+			nvec = 1 << msidesc->msi_attrib.multiple;
+		for (i = 0; i < nvec; i++)
+			xen_teardown_msi_irq(msidesc->irq + i);
+	}
 }
 
 void xen_nop_msi_mask(struct irq_data *data)
 {
 }
+
+struct msi_chip xen_msi_chip;
+
 #endif
 
 int __init pci_xen_init(void)
@@ -418,9 +430,9 @@  int __init pci_xen_init(void)
 #endif
 
 #ifdef CONFIG_PCI_MSI
-	x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
-	x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
-	x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
+	xen_msi_chip.setup_irqs = xen_setup_msi_irqs;
+	xen_msi_chip.teardown_irqs = xen_teardown_msi_irqs;
+	x86_msi_chip = &xen_msi_chip;
 	msi_chip.irq_mask = xen_nop_msi_mask;
 	msi_chip.irq_unmask = xen_nop_msi_mask;
 #endif
@@ -441,8 +453,9 @@  int __init pci_xen_hvm_init(void)
 #endif
 
 #ifdef CONFIG_PCI_MSI
-	x86_msi.setup_msi_irqs = xen_hvm_setup_msi_irqs;
-	x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
+	xen_msi_chip.setup_irqs = xen_hvm_setup_msi_irqs;
+	xen_msi_chip.teardown_irq = xen_teardown_msi_irq;
+	x86_msi_chip = &xen_msi_chip;
 #endif
 	return 0;
 }
@@ -499,9 +512,10 @@  int __init pci_xen_initial_domain(void)
 	int irq;
 
 #ifdef CONFIG_PCI_MSI
-	x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs;
-	x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
-	x86_msi.restore_msi_irqs = xen_initdom_restore_msi_irqs;
+	xen_msi_chip.setup_irqs = xen_initdom_setup_msi_irqs;
+	xen_msi_chip.teardown_irq = xen_teardown_msi_irq;
+	xen_msi_chip.restore_irqs = xen_initdom_restore_msi_irqs;
+	x86_msi_chip = &xen_msi_chip;
 	msi_chip.irq_mask = xen_nop_msi_mask;
 	msi_chip.irq_unmask = xen_nop_msi_mask;
 #endif