From patchwork Tue Aug 3 20:57:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 116859 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o73KwCFR011435 for ; Tue, 3 Aug 2010 20:58:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757691Ab0HCU5u (ORCPT ); Tue, 3 Aug 2010 16:57:50 -0400 Received: from mail-gw0-f46.google.com ([74.125.83.46]:37943 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756543Ab0HCU5t (ORCPT ); Tue, 3 Aug 2010 16:57:49 -0400 Received: by gwb20 with SMTP id 20so1743748gwb.19 for ; Tue, 03 Aug 2010 13:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; bh=1S1qHYLDsS88eEUV0vGfn4Muhuokj5by4rR/Wad5l/k=; b=BdC6auWhmgbIj5pDf2RpubS/vMLw14ARfhGABueZTqlpyRtjltVpgoXPKzYOUwXbjK D++Pvykkyz2FxEp4YWx882vJiQ3w7Y5dxQx0Km6N08OD8YWRZO9SByqXnhNFuPQluTsc L1qbyhHaIt/kB4BrstSAfyboMXQUEs6UyN6qQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=d0BDSjltRj4HjwwycZEsEq7e9tlL4k0LxiDJqmLqdLHgcf6CuI9xicWiHTrecHKcI7 ViIUmd8ixterI3L4cbyULL1pyEPKA1AG2Gs1tAmgm8S55brh1DBaX11QpIOJwD3dIiHS GdHnCMa9/vAr3iBVMadaeMsqqrVTuf3o20xmc= MIME-Version: 1.0 Received: by 10.151.145.16 with SMTP id x16mr4086027ybn.342.1280869068082; Tue, 03 Aug 2010 13:57:48 -0700 (PDT) Received: by 10.150.11.20 with HTTP; Tue, 3 Aug 2010 13:57:48 -0700 (PDT) In-Reply-To: <201008031659.58736.tvrtko.ursulin@sophos.com> References: <201008031028.57263.tvrtko.ursulin@sophos.com> <201008031557.04613.tvrtko.ursulin@sophos.com> <201008031617.21418.tvrtko.ursulin@sophos.com> <201008031659.58736.tvrtko.ursulin@sophos.com> Date: Tue, 3 Aug 2010 13:57:48 -0700 X-Google-Sender-Auth: 9Kso7WUhxV_xBWycqt-vDQM578o Message-ID: Subject: Re: 2.6.35 hangs on early boot in KVM From: Yinghai Lu To: Tvrtko Ursulin Cc: Avi Kivity , "linux-kernel@vger.kernel.org" , KVM list , "Eric W. Biederman" Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 03 Aug 2010 20:58:13 +0000 (UTC) [PATCH] x86: check if apic/pin is shared with legacy one fix system that external device that have io apic on apic0/pin(0-15) also for the io apic out of order system: <6>ACPI: IOAPIC (id[0x10] address[0xfecff000] gsi_base[0]) <6>IOAPIC[0]: apic_id 16, version 0, address 0xfecff000, GSI 0-2 <6>ACPI: IOAPIC (id[0x0f] address[0xfec00000] gsi_base[3]) <6>IOAPIC[1]: apic_id 15, version 0, address 0xfec00000, GSI 3-38 <6>ACPI: IOAPIC (id[0x0e] address[0xfec01000] gsi_base[39]) <6>IOAPIC[2]: apic_id 14, version 0, address 0xfec01000, GSI 39-74 <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 1 global_irq 4 dfl dfl) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 5 dfl dfl) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 3 global_irq 6 dfl dfl) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 4 global_irq 7 dfl dfl) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 6 global_irq 9 dfl dfl) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 7 global_irq 10 dfl dfl) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 8 global_irq 11 low edge) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 12 dfl dfl) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 12 global_irq 15 dfl dfl) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 13 global_irq 16 dfl dfl) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 14 global_irq 17 low edge) <6>ACPI: INT_SRC_OVR (bus 0 bus_irq 15 global_irq 18 dfl dfl) after this patch will get apic0, pin0, GSI 0: irq 0+75 apic0, pin1, GSI 1: irq 1+75 apic0, pin2, GSI 2: irq 2 apic1, pin0, GSI 3: irq 3+75 apic1, pin5, GSI 8: irq 8+75 apic1, pin10,GSI 13: irq 13+75 apic1, pin11,GSI 14: irq 14+75 because mp_config_acpi_legacy_irqs will put apic0, pin2, irq2 in mp_irqs... so pin_2_irq_legacy will report 2. irq_to_gsi will still report 2. so it is right. gsi_to_irq will report 2. for 0, 1, 3, 8, 13, 14: still right Signed-off-by: Yinghai Lu --- arch/x86/kernel/apic/io_apic.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) Index: linux-2.6/arch/x86/kernel/apic/io_apic.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/apic/io_apic.c +++ linux-2.6/arch/x86/kernel/apic/io_apic.c @@ -1013,6 +1013,28 @@ static inline int irq_trigger(int idx) return MPBIOS_trigger(idx); } +static int pin_2_irq_leagcy(int apic, int pin) +{ + int i; + + for (i = 0; i < mp_irq_entries; i++) { + int bus = mp_irqs[i].srcbus; + + if (!test_bit(bus, mp_bus_not_pci)) + continue; + + if (mp_ioapics[apic].apicid != mp_irqs[i].dstapic) + continue; + + if (mp_irqs[i].dstirq != pin) + continue; + + return mp_irqs[i].srcbusirq; + } + + return -1; +} + static int pin_2_irq(int idx, int apic, int pin) { int irq; @@ -1029,10 +1051,13 @@ static int pin_2_irq(int idx, int apic, } else { u32 gsi = mp_gsi_routing[apic].gsi_base + pin; - if (gsi >= NR_IRQS_LEGACY) + if (gsi >= NR_IRQS_LEGACY) { irq = gsi; - else - irq = gsi_top + gsi; + } else { + irq = pin_2_irq_legacy(apic, pin); + if (irq < 0) + irq = gsi_top + gsi; + } } #ifdef CONFIG_X86_32