From patchwork Thu Nov 8 16:26:36 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: 994994 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 42rTFg1QQ9z9sBh; Fri, 9 Nov 2018 03:27:03 +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 1gKn90-0006sw-Df; Thu, 08 Nov 2018 16:26:58 +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 1gKn8y-0006sW-Jz for kernel-team@lists.ubuntu.com; Thu, 08 Nov 2018 16:26:56 +0000 Received: from mail-qk1-f200.google.com ([209.85.222.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gKn8y-0004Fa-Ag for kernel-team@lists.ubuntu.com; Thu, 08 Nov 2018 16:26:56 +0000 Received: by mail-qk1-f200.google.com with SMTP id u20-v6so38388639qka.21 for ; Thu, 08 Nov 2018 08:26:56 -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=WJ6jZzSi97pYrUWlVhy7LvJwYqBzw0lOfOUtoSx+i/M=; b=MAMpsokfvSj88mNeqE8qeCS7/FWqwxtf5X4tCQtV7pacWLmdnNMQ5K7lSEllbKQkOb 5hWMkpsKIjUCVs+H6SG5JWvYFyaIsMfaNF3rcjNe6zU9f84cNUWDBCiEcy+iTAFqUWAk HsQ2xsdl3JMG9wLhI/gUfRLUE/Lod67av160G2zfQltWjpymvwKefs3hXh8MUYKS56Dq JnbCglSPxF8Xm1/mQE5mXQFxFBdPNjRC149SVLx8ObNmLL1IgEG4o6ePZISodCZLu6Si LThnZwsiY5bAFdWnkiZScQNBZ2CSEBapxBPFG3PRF8i1qXxKuElHzci/lrucLKIWNPAf hayQ== X-Gm-Message-State: AGRZ1gJ5Ya4KeKd9g5QRrIOASMhNw0vQ1s85HrcNbqfoL24YdKLVF0rR dLXPeL8eIyJ0Bdo2EdEHqXQc04YFN6tR8Hy00llMUvaKDcEeD0FO8mNcdNUAyRlVPNq5o06iut/ uVOBqmF2mvC6xcBcIaYWP9uU/zlBfGcU1sQ1kdvGQ0g== X-Received: by 2002:a37:5b47:: with SMTP id p68mr4660864qkb.299.1541694415364; Thu, 08 Nov 2018 08:26:55 -0800 (PST) X-Google-Smtp-Source: AJdET5d0cN3HYLJ0jqrEyuipyzFMxPvrx7yfylPm1ci4Wj1IlZ8MmSlKoo0aokqzEq9UfM8iPWexQQ== X-Received: by 2002:a37:5b47:: with SMTP id p68mr4660843qkb.299.1541694415131; Thu, 08 Nov 2018 08:26:55 -0800 (PST) Received: from localhost.localdomain ([179.159.57.206]) by smtp.gmail.com with ESMTPSA id t186-v6sm2211225qkd.54.2018.11.08.08.26.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 08:26:54 -0800 (PST) From: Mauricio Faria de Oliveira To: kernel-team@lists.ubuntu.com Subject: [SRU C][PATCH v2 1/3] UBUNTU: SAUCE: x86/PCI: Export find_cap() to be used in early PCI code Date: Thu, 8 Nov 2018 14:26:36 -0200 Message-Id: <20181108162638.17137-2-mfo@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181108162638.17137-1-mfo@canonical.com> References: <20181108162638.17137-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 e1084f71a295..3f5b5158bbd7 100644 --- a/arch/x86/include/asm/pci-direct.h +++ b/arch/x86/include/asm/pci-direct.h @@ -10,6 +10,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 2c4d5ece7456..365fcc37b2a2 100644 --- a/arch/x86/kernel/aperture_64.c +++ b/arch/x86/kernel/aperture_64.c @@ -120,32 +120,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) { @@ -234,8 +208,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 e5f753cbb1c3..c082b530ee2d 100644 --- a/arch/x86/pci/early.c +++ b/arch/x86/pci/early.c @@ -51,6 +51,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)) ==