From: Matthew Garrett <mjg@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, matt.fleming@intel.com, Matthew Garrett <mjg@redhat.com>
Subject: [PATCH 3/3] x86: Handle broken Broadcom UEFI driver on Apple hardware
Date: Wed, 23 May 2012 14:08:46 -0400 [thread overview]
Message-ID: <1337796526-3649-3-git-send-email-mjg@redhat.com> (raw)
In-Reply-To: <1337796526-3649-1-git-send-email-mjg@redhat.com>
The Broadcom driver in some UEFI Apple systems will continue DMAing into
RAM even after we've exited the firmware. Simply turning off the busmaster
bits results in the hardware hanging, so instead we put it in D3.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
arch/x86/kernel/early-quirks.c | 48 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index dcf4bcf..9c243c0 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -200,6 +200,52 @@ static void __init ati_bugs_contd(int num, int slot, int func)
}
#endif
+/*
+ * Some Apple systems leave the Broadcom wifi hardware DMAing after
+ * leaving the firmware. We're still safe at this point since boot
+ * services regions are reserved, so we can quiesce the hardware by
+ * putting it in D3 and let it be safely brought back up again later
+ */
+static void __init apple_bcm_bug(int num, int slot, int func)
+{
+ u16 pm_state, subvendor;
+ u8 id, pm = 0, pos = PCI_CAPABILITY_LIST;
+ int ttl = 48;
+
+ subvendor = read_pci_config_16(num, slot, func,
+ PCI_SUBSYSTEM_VENDOR_ID);
+
+ if (subvendor != PCI_VENDOR_ID_APPLE)
+ return;
+
+ while (ttl--) {
+ pos = read_pci_config_byte(num, slot, func, pos);
+ if (pos < 0x40)
+ break;
+
+ pos &= ~3;
+
+ id = read_pci_config_byte(num, slot, func, pos);
+ if (id == 0xff)
+ break;
+
+ if (id == PCI_CAP_ID_PM) {
+ pm = pos;
+ break;
+ }
+ pos += 1;
+ }
+
+ if (pm) {
+ pm_state = read_pci_config_16(num, slot, func,
+ pm + PCI_PM_CTRL);
+ pm_state &= ~PCI_PM_CTRL_STATE_MASK;
+ pm_state |= 0x3;
+ write_pci_config_16(num, slot, func, pm + PCI_PM_CTRL,
+ pm_state);
+ }
+}
+
#define QFLAG_APPLY_ONCE 0x1
#define QFLAG_APPLIED 0x2
#define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED)
@@ -226,6 +272,8 @@ static struct chipset early_qrk[] __initdata = {
PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs },
{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd },
+ { PCI_VENDOR_ID_BROADCOM, PCI_ANY_ID,
+ PCI_CLASS_NETWORK_OTHER, PCI_ANY_ID, 0, apple_bcm_bug },
{}
};
--
1.7.10.2
next prev parent reply other threads:[~2012-05-23 18:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-23 18:08 [PATCH 1/3] x86: Expand EFI GOP handle search Matthew Garrett
2012-05-23 18:08 ` [PATCH 2/3] x86: Allow early PCI quirks to trigger on bus 1 Matthew Garrett
2012-05-23 18:08 ` Matthew Garrett [this message]
2012-05-23 20:21 ` [PATCH 1/3] x86: Expand EFI GOP handle search Matt Fleming
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=1337796526-3649-3-git-send-email-mjg@redhat.com \
--to=mjg@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.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
all inboxes | Powered by JetHome®