From patchwork Thu Nov 8 14:38:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauricio Faria de Oliveira X-Patchwork-Id: 994912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42rQsK1FKhz9s3q; Fri, 9 Nov 2018 01:39:17 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gKlSg-0001cl-9g; Thu, 08 Nov 2018 14:39:10 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gKlSe-0001cN-Tr for kernel-team@lists.ubuntu.com; Thu, 08 Nov 2018 14:39:08 +0000 Received: from mail-qk1-f198.google.com ([209.85.222.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gKlSe-0005bG-K9 for kernel-team@lists.ubuntu.com; Thu, 08 Nov 2018 14:39:08 +0000 Received: by mail-qk1-f198.google.com with SMTP id n68so37592003qkn.8 for ; Thu, 08 Nov 2018 06:39:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9oKLOoEIjg7iv7/PVBkZEtRsSqH3xbfsZLy+t02ayEM=; b=s9FmJs5+1UlSUzapf3gr+FwcKdae9SPCeAiyx+5Hxp9V+lSo7hftmmeBC6D8Eaynxl uUHfv8Nc9yaCD5vJ80pHC1dtZsbL41K6d5k7colNhC4ay/0KqnukWJA0cVhQ5tynaw9H 2oTlbbpsIFRRJmQyKJW2kA9NiDg7gStZVeT7Y3FP5NYNqo7lauCPTLVQBm5p34CZlL05 FEythLxzz128AfeMo2y1AMvBlO6SSZQJDlFGiykClNHbP5nldhmKg7hyQwW3hjSPWmwP 9a/gYyRfXWWfsF72Pbahdt47avd9Cr+Kx9Xlh0Lfauc4shsRjGxWj9S0s2FN1kgiM9M+ 1ESw== X-Gm-Message-State: AGRZ1gLMUOnSCFTAes1UUGwp78dEnzf5BkLDy1yIh5TVtJSuWbHPE9i4 vCSCR9Zz4rgn/+lRdkK7ZjsMPfXd+HxTjxE0lxTuvnFR7hyX3GgO6YB+LZhlQYyEUHsG3BtWVId Dqz/riIW84XouPtIJNi8q4mQqItYBQMmQgE9SouzxWA== X-Received: by 2002:a37:bc44:: with SMTP id m65mr4274543qkf.52.1541687947693; Thu, 08 Nov 2018 06:39:07 -0800 (PST) X-Google-Smtp-Source: AJdET5ca+BqOvqrA5SzUlBn2MeV47yud2rah9dNb+IF8/jIeHKIQ/L5cpcNX60nu1w8P23e5otckWQ== X-Received: by 2002:a37:bc44:: with SMTP id m65mr4274526qkf.52.1541687947497; Thu, 08 Nov 2018 06:39:07 -0800 (PST) Received: from localhost.localdomain ([179.159.57.206]) by smtp.gmail.com with ESMTPSA id v50sm3116971qtc.7.2018.11.08.06.39.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:39:07 -0800 (PST) From: Mauricio Faria de Oliveira To: kernel-team@lists.ubuntu.com Subject: [SRU X][PATCH v2 1/3] UBUNTU: SAUCE: x86/PCI: Export find_cap() to be used in early PCI code Date: Thu, 8 Nov 2018 12:38:49 -0200 Message-Id: <20181108143851.15758-2-mfo@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181108143851.15758-1-mfo@canonical.com> References: <20181108143851.15758-1-mfo@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gpiccoli@canonical.com MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "Guilherme G. Piccoli" BugLink: https://bugs.launchpad.net/bugs/1797990 This patch exports (and renames) the function find_cap() to be used in the early PCI quirk code, by the next patch. This is being moved out from AGP code to generic early-PCI code since it's not AGP-specific and can be used for any PCI device. No functional changes intended. Signed-off-by: Guilherme G. Piccoli Signed-off-by: Mauricio Faria de Oliveira --- arch/x86/include/asm/pci-direct.h | 1 + arch/x86/kernel/aperture_64.c | 30 ++---------------------------- arch/x86/pci/early.c | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/arch/x86/include/asm/pci-direct.h b/arch/x86/include/asm/pci-direct.h index b1e7a45d868a..c5a8edf2dc8b 100644 --- a/arch/x86/include/asm/pci-direct.h +++ b/arch/x86/include/asm/pci-direct.h @@ -9,6 +9,7 @@ extern u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset); extern u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset); extern u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset); +extern u32 pci_early_find_cap(int bus, int slot, int func, int cap); extern void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset, u32 val); extern void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val); extern void write_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset, u16 val); diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c index 6e85f713641d..cabb09540662 100644 --- a/arch/x86/kernel/aperture_64.c +++ b/arch/x86/kernel/aperture_64.c @@ -91,32 +91,6 @@ static u32 __init allocate_aperture(void) } -/* Find a PCI capability */ -static u32 __init find_cap(int bus, int slot, int func, int cap) -{ - int bytes; - u8 pos; - - if (!(read_pci_config_16(bus, slot, func, PCI_STATUS) & - PCI_STATUS_CAP_LIST)) - return 0; - - pos = read_pci_config_byte(bus, slot, func, PCI_CAPABILITY_LIST); - for (bytes = 0; bytes < 48 && pos >= 0x40; bytes++) { - u8 id; - - pos &= ~3; - id = read_pci_config_byte(bus, slot, func, pos+PCI_CAP_LIST_ID); - if (id == 0xff) - break; - if (id == cap) - return pos; - pos = read_pci_config_byte(bus, slot, func, - pos+PCI_CAP_LIST_NEXT); - } - return 0; -} - /* Read a standard AGPv3 bridge header */ static u32 __init read_agp(int bus, int slot, int func, int cap, u32 *order) { @@ -205,8 +179,8 @@ static u32 __init search_agp_bridge(u32 *order, int *valid_agp) case PCI_CLASS_BRIDGE_HOST: case PCI_CLASS_BRIDGE_OTHER: /* needed? */ /* AGP bridge? */ - cap = find_cap(bus, slot, func, - PCI_CAP_ID_AGP); + cap = pci_early_find_cap(bus, slot, + func, PCI_CAP_ID_AGP); if (!cap) break; *valid_agp = 1; diff --git a/arch/x86/pci/early.c b/arch/x86/pci/early.c index d1067d539bee..354c50788aae 100644 --- a/arch/x86/pci/early.c +++ b/arch/x86/pci/early.c @@ -50,6 +50,31 @@ void write_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset, u16 val) outw(val, 0xcfc + (offset&2)); } +u32 pci_early_find_cap(int bus, int slot, int func, int cap) +{ + int bytes; + u8 pos; + + if (!(read_pci_config_16(bus, slot, func, PCI_STATUS) & + PCI_STATUS_CAP_LIST)) + return 0; + + pos = read_pci_config_byte(bus, slot, func, PCI_CAPABILITY_LIST); + for (bytes = 0; bytes < 48 && pos >= 0x40; bytes++) { + u8 id; + + pos &= ~3; + id = read_pci_config_byte(bus, slot, func, pos+PCI_CAP_LIST_ID); + if (id == 0xff) + break; + if (id == cap) + return pos; + pos = read_pci_config_byte(bus, slot, func, + pos+PCI_CAP_LIST_NEXT); + } + return 0; +} + int early_pci_allowed(void) { return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) ==