WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Re: APIC rework

To: "Zhang, Xiantao" <xiantao.zhang@xxxxxxxxx>
Subject: Re: [Xen-devel] Re: APIC rework
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Thu, 12 Nov 2009 15:51:09 -0800
Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, "Han, Weidong" <weidong.han@xxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Delivery-date: Thu, 12 Nov 2009 15:51:33 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4AFB5E1F.7020709@xxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <4AB431AD.1030205@xxxxxxxx> <h9d738$5qa$3@xxxxxxxxxxxxx> <4ABA8179.8060801@xxxxxxxx> <706158FABBBA044BAD4FE898A02E4BC201C9A17871@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <706158FABBBA044BAD4FE898A02E4BC201C9A17A0A@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <706158FABBBA044BAD4FE898A02E4BC201C9AC7ED0@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <4AC54350.7040909@xxxxxxxx> <706158FABBBA044BAD4FE898A02E4BC201C9AC8A88@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <4AD75A0B.9020508@xxxxxxxx> <706158FABBBA044BAD4FE898A02E4BC201C9BD87FA@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <4AFB5B1A.4050204@xxxxxxxx> <4AFB5E1F.7020709@xxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Lightning/1.0pre Thunderbird/3.0b4
On 11/11/09 17:00, Jeremy Fitzhardinge wrote:
> On 11/11/09 16:47, Jeremy Fitzhardinge wrote:
>   
>> For now I've applied your current patch to the branch
>> xen/dom0/apic-xiantao, rooted on the last xen/master branch where it
>> applies cleanly.
>>   
>>     
> And xen/master-xiantao is my attempt to merge it into master.  It turned
> out less complex than I'd thought, but I haven't tested it yet.
>   

And it works, at least for simple stuff (haven't tried passthrough or
MSI yet).

Keir, how do you feel about this change for Xen?

x86: Change the interface physdev_map_pirq to support new dom0.

It also keeps compatibility with old dom0. 

Signed-off-by: Xiantao Zhang <xiantao.zhang@xxxxxxxxx>

diff -r 8f81bdd57afe xen/arch/x86/irq.c
--- a/xen/arch/x86/irq.c        Thu Sep 03 09:51:37 2009 +0100
+++ b/xen/arch/x86/irq.c        Thu Sep 24 15:36:19 2009 +0800
@@ -55,6 +55,11 @@ DEFINE_PER_CPU(vector_irq_t, vector_irq)
 
 DEFINE_PER_CPU(struct cpu_user_regs *, __irq_regs);
 
+int check_irq_status(int irq)
+{
+    return irq_status[irq] != IRQ_UNUSED ? 1 : 0;
+}
+
 /* Must be called when irq disabled */
 void lock_vector_lock(void)
 {
@@ -588,6 +593,9 @@ int setup_irq(unsigned int irq, struct i
     desc->depth   = 0;
     desc->status &= ~IRQ_DISABLED;
     desc->handler->startup(irq);
+
+    if ( !check_irq_status(irq) )
+        irq_status[irq] = IRQ_USED;
 
     spin_unlock_irqrestore(&desc->lock,flags);
 
@@ -1277,6 +1285,8 @@ int map_domain_pirq(
 
     ASSERT(spin_is_locked(&pcidevs_lock));
     ASSERT(spin_is_locked(&d->event_lock));
+    
+    desc = irq_to_desc(irq);
 
     if ( !IS_PRIV(current->domain) )
         return -EPERM;
@@ -1288,6 +1298,13 @@ int map_domain_pirq(
         return -EINVAL;
     }
 
+    if ( desc->action )
+    {
+        dprintk(XENLOG_G_WARNING, "Attempt to map in-use IRQ by Xen,"
+                        " irq:%d!\n", irq);
+        return 0;
+    }
+
     old_irq = domain_pirq_to_irq(d, pirq);
     old_pirq = domain_irq_to_pirq(d, irq);
 
@@ -1307,7 +1324,6 @@ int map_domain_pirq(
         return ret;
     }
 
-    desc = irq_to_desc(irq);
 
     if ( type == MAP_PIRQ_TYPE_MSI )
     {
diff -r 8f81bdd57afe xen/arch/x86/physdev.c
--- a/xen/arch/x86/physdev.c    Thu Sep 03 09:51:37 2009 +0100
+++ b/xen/arch/x86/physdev.c    Thu Sep 24 15:45:17 2009 +0800
@@ -30,7 +30,7 @@ static int physdev_map_pirq(struct physd
 static int physdev_map_pirq(struct physdev_map_pirq *map)
 {
     struct domain *d;
-    int pirq, irq, ret = 0;
+    int pirq = 0, irq, ret = 0;
     struct msi_info _msi;
     void *map_data = NULL;
 
@@ -55,23 +55,28 @@ static int physdev_map_pirq(struct physd
     switch ( map->type )
     {
         case MAP_PIRQ_TYPE_GSI:
-            if ( map->index < 0 || map->index >= nr_irqs_gsi )
+        {
+            int gsi, triggering, polarity;
+            
+            gsi = map->index & 0xffff;
+            triggering = !!(map->index & (1 << 16));
+            polarity = !!(map->index & (1 << 24));
+            irq = pirq = map->pirq;
+            
+            if ( gsi < 0 || gsi >= nr_irqs_gsi )
             {
-                dprintk(XENLOG_G_ERR, "dom%d: map invalid irq %d\n",
-                        d->domain_id, map->index);
+                dprintk(XENLOG_G_ERR, "dom%d: map invalid gsi %d\n",
+                        d->domain_id, gsi);
                 ret = -EINVAL;
                 goto free_domain;
             }
-            irq = domain_pirq_to_irq(current->domain, map->index);
-            if ( !irq )
-            {
-                dprintk(XENLOG_G_ERR, "dom%d: map pirq with incorrect irq!\n",
-                        d->domain_id);
-                ret = -EINVAL;
-                goto free_domain;
-            }
-            break;
-
+            if ( !check_irq_status(irq) ) {
+                mp_register_gsi(gsi, triggering, polarity);
+                printk("Register gsi:%d for dom:%d, irq:%d\n", gsi,
+                      d->domain_id, irq);
+            }
+            break;
+        }
         case MAP_PIRQ_TYPE_MSI:
             irq = map->index;
             if ( irq == -1 )
@@ -103,7 +108,6 @@ static int physdev_map_pirq(struct physd
     spin_lock(&pcidevs_lock);
     /* Verify or get pirq. */
     spin_lock(&d->event_lock);
-    pirq = domain_irq_to_pirq(d, irq);
     if ( map->pirq < 0 )
     {
         if ( pirq )
diff -r 8f81bdd57afe xen/include/asm-x86/irq.h
--- a/xen/include/asm-x86/irq.h Thu Sep 03 09:51:37 2009 +0100
+++ b/xen/include/asm-x86/irq.h Sat Sep 05 16:09:07 2009 +0800
@@ -123,6 +123,8 @@ int __assign_irq_vector(int irq, struct 
 
 int bind_irq_vector(int irq, int vector, cpumask_t domain);
 
+int check_irq_status(int irq);
+
 #define domain_pirq_to_irq(d, pirq) ((d)->arch.pirq_irq[pirq])
 #define domain_irq_to_pirq(d, irq) ((d)->arch.irq_pirq[irq])
 

        J


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>