From: "Guilherme G. Piccoli" <gpiccoli@canonical.com>
To: linux-pci@vger.kernel.org, kexec@lists.infradead.org, x86@kernel.org
Cc: linux-kernel@vger.kernel.org, bhelgaas@google.com,
dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
hpa@zytor.com, andi@firstfloor.org, lukas@wunner.de,
billy.olsen@canonical.com, cascardo@canonical.com,
ddstreet@canonical.com, fabiomirmar@canonical.com,
gavin.guo@canonical.com, gpiccoli@canonical.com,
jay.vosburgh@canonical.com, kernel@gpiccoli.net,
mfo@canonical.com, shan.gavin@linux.alibaba.com
Subject: [PATCH 2/3] x86/PCI: Export find_cap() to be used in early PCI code
Date: Thu, 18 Oct 2018 15:37:20 -0300 [thread overview]
Message-ID: <20181018183721.27467-2-gpiccoli@canonical.com> (raw)
In-Reply-To: <20181018183721.27467-1-gpiccoli@canonical.com>
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 <gpiccoli@canonical.com>
---
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 94597a3cf3d0..813996305bf5 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 f5fc953e5848..f1ba9d781b52 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)) ==
--
2.19.0
next prev parent reply other threads:[~2018-10-18 18:37 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-18 18:37 [PATCH 1/3] x86/quirks: Scan all busses for early PCI quirks Guilherme G. Piccoli
2018-10-18 18:37 ` Guilherme G. Piccoli [this message]
2018-10-18 18:37 ` [PATCH 3/3] x86/quirks: Add parameter to clear MSIs early on boot Guilherme G. Piccoli
2018-10-18 20:08 ` Sinan Kaya
2018-10-18 20:13 ` Guilherme G. Piccoli
2018-10-18 20:30 ` Sinan Kaya
2018-10-22 19:44 ` Guilherme G. Piccoli
2018-10-18 22:15 ` [PATCH 1/3] x86/quirks: Scan all busses for early PCI quirks Bjorn Helgaas
2018-10-22 20:35 ` Guilherme G. Piccoli
2018-10-23 17:03 ` Bjorn Helgaas
2020-11-06 13:14 ` Guilherme G. Piccoli
2020-11-13 16:46 ` Bjorn Helgaas
2020-11-13 23:31 ` Thomas Gleixner
2020-11-13 23:40 ` Thomas Gleixner
2020-11-14 20:39 ` Bjorn Helgaas
2020-11-14 20:58 ` Thomas Gleixner
2020-11-14 21:22 ` Bjorn Helgaas
2020-11-15 14:05 ` Eric W. Biederman
2020-11-15 14:29 ` Eric W. Biederman
2020-11-15 15:11 ` Thomas Gleixner
2020-11-15 17:01 ` Lukas Wunner
2020-11-15 19:18 ` Thomas Gleixner
2020-11-15 20:46 ` Eric W. Biederman
2020-11-16 20:31 ` Guilherme G. Piccoli
2020-11-16 21:45 ` Eric W. Biederman
2020-11-16 21:49 ` Guilherme Piccoli
2020-11-17 0:19 ` Bjorn Helgaas
2020-11-17 1:06 ` Eric W. Biederman
2020-11-17 9:53 ` Thomas Gleixner
2020-11-17 12:19 ` David Woodhouse
2020-11-17 19:34 ` Thomas Gleixner
2020-11-17 22:25 ` Eric W. Biederman
2020-11-17 12:04 ` Guilherme Piccoli
2020-11-18 21:05 ` Bjorn Helgaas
2020-11-18 22:36 ` Guilherme Piccoli
2020-11-30 20:20 ` Bjorn Helgaas
2020-12-14 18:32 ` Guilherme Piccoli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181018183721.27467-2-gpiccoli@canonical.com \
--to=gpiccoli@canonical.com \
--cc=andi@firstfloor.org \
--cc=bhe@redhat.com \
--cc=bhelgaas@google.com \
--cc=billy.olsen@canonical.com \
--cc=bp@alien8.de \
--cc=cascardo@canonical.com \
--cc=ddstreet@canonical.com \
--cc=dyoung@redhat.com \
--cc=fabiomirmar@canonical.com \
--cc=gavin.guo@canonical.com \
--cc=hpa@zytor.com \
--cc=jay.vosburgh@canonical.com \
--cc=kernel@gpiccoli.net \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mfo@canonical.com \
--cc=mingo@redhat.com \
--cc=shan.gavin@linux.alibaba.com \
--cc=tglx@linutronix.de \
--cc=vgoyal@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).