From owner-svn-src-stable-12@freebsd.org Wed Apr 1 15:59:37 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 427302BF68C; Wed, 1 Apr 2020 15:59:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48srVb476Nz4Q1P; Wed, 1 Apr 2020 15:59:35 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 19C5027D2C; Wed, 1 Apr 2020 15:59:27 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 031FxQCe098272; Wed, 1 Apr 2020 15:59:26 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 031FxQLs098271; Wed, 1 Apr 2020 15:59:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202004011559.031FxQLs098271@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 1 Apr 2020 15:59:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r359516 - stable/12/sys/x86/x86 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/x86/x86 X-SVN-Commit-Revision: 359516 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2020 15:59:37 -0000 Author: kib Date: Wed Apr 1 15:59:26 2020 New Revision: 359516 URL: https://svnweb.freebsd.org/changeset/base/359516 Log: MFC r359092: Stop (trying to) renumber io apics. Modified: stable/12/sys/x86/x86/io_apic.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/x86/x86/io_apic.c ============================================================================== --- stable/12/sys/x86/x86/io_apic.c Wed Apr 1 15:57:14 2020 (r359515) +++ stable/12/sys/x86/x86/io_apic.c Wed Apr 1 15:59:26 2020 (r359516) @@ -95,7 +95,8 @@ struct ioapic_intsrc { struct ioapic { struct pic io_pic; u_int io_id:8; /* logical ID */ - u_int io_apic_id:8; + u_int io_apic_id:8; /* Id as enumerated by MADT */ + u_int io_hw_apic_id:8; /* Content of APIC ID register */ u_int io_intbase:8; /* System Interrupt base */ u_int io_numintr:8; u_int io_haseoi:1; @@ -635,15 +636,12 @@ ioapic_create(vm_paddr_t addr, int32_t apic_id, int in io->pci_wnd = NULL; mtx_lock_spin(&icu_lock); io->io_id = next_id++; - io->io_apic_id = ioapic_read(apic, IOAPIC_ID) >> APIC_ID_SHIFT; - if (apic_id != -1 && io->io_apic_id != apic_id) { - ioapic_write(apic, IOAPIC_ID, apic_id << APIC_ID_SHIFT); - mtx_unlock_spin(&icu_lock); - io->io_apic_id = apic_id; - printf("ioapic%u: Changing APIC ID to %d\n", io->io_id, - apic_id); - } else - mtx_unlock_spin(&icu_lock); + io->io_hw_apic_id = ioapic_read(apic, IOAPIC_ID) >> APIC_ID_SHIFT; + io->io_apic_id = apic_id == -1 ? io->io_hw_apic_id : apic_id; + mtx_unlock_spin(&icu_lock); + if (io->io_hw_apic_id != apic_id) + printf("ioapic%u: MADT APIC ID %d != hw id %d\n", io->io_id, + apic_id, io->io_hw_apic_id); if (intbase == -1) { intbase = next_ioapic_base; printf("ioapic%u: Assuming intbase of %d\n", io->io_id, @@ -1018,14 +1016,14 @@ ioapic_pci_attach(device_t dev) } /* Then by apic id */ STAILQ_FOREACH(io, &ioapic_list, io_next) { - if (io->io_apic_id == apic_id) + if (io->io_hw_apic_id == apic_id) goto found; } mtx_unlock_spin(&icu_lock); if (bootverbose) device_printf(dev, - "cannot match pci bar apic id %d against MADT\n", - apic_id); + "cannot match pci bar apic id %d against MADT, BAR0 %#jx\n", + apic_id, (uintmax_t)rman_get_start(res)); fail: bus_release_resource(dev, SYS_RES_MEMORY, rid, res); return (ENXIO); @@ -1038,13 +1036,13 @@ found: io->pci_dev = dev; io->pci_wnd = res; if (bootverbose && (io->io_paddr != (vm_paddr_t)rman_get_start(res) || - io->io_apic_id != apic_id)) { + io->io_hw_apic_id != apic_id)) { device_printf(dev, "pci%d:%d:%d:%d pci BAR0@%jx id %d " - "MADT id %d paddr@%jx\n", + "MADT id %d hw id %d paddr@%jx\n", pci_get_domain(dev), pci_get_bus(dev), pci_get_slot(dev), pci_get_function(dev), (uintmax_t)rman_get_start(res), apic_id, - io->io_apic_id, (uintmax_t)io->io_paddr); + io->io_apic_id, io->io_hw_apic_id, (uintmax_t)io->io_paddr); } mtx_unlock_spin(&icu_lock); return (0);