summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt
diff options
context:
space:
mode:
authorLukas Wunner <lukas@wunner.de>2017-08-01 08:10:41 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-08-03 17:26:22 -0400
commit630b3aff8a51c90ef15b59c9560ac35e40e7ec09 (patch)
treebeaf70e4289cdc2a931d5c6d6e54e94dadb5b127 /drivers/thunderbolt
parent16f73eb02d7e1765ccab3d2018e0bd98eb93d973 (diff)
treewide: Consolidate Apple DMI checks
We're about to amend ACPI bus scan with DMI checks whether we're running on a Mac to support Apple device properties in AML. The DMI checks are performed for every single device, adding overhead for everything x86 that isn't Apple, which is the majority. Rafael and Andy therefore request to perform the DMI match only once and cache the result. Outside of ACPI various other Apple DMI checks exist and it seems reasonable to use the cached value there as well. Rafael, Andy and Darren suggest performing the DMI check in arch code and making it available with a header in include/linux/platform_data/x86/. To this end, add early_platform_quirks() to arch/x86/kernel/quirks.c to perform the DMI check and invoke it from setup_arch(). Switch over all existing Apple DMI checks, thereby fixing two deficiencies: * They are now #defined to false on non-x86 arches and can thus be optimized away if they're located in cross-arch code. * Some of them only match "Apple Inc." but not "Apple Computer, Inc.", which is used by BIOSes released between January 2006 (when the first x86 Macs started shipping) and January 2007 (when the company name changed upon introduction of the iPhone). Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Suggested-by: Darren Hart <dvhart@infradead.org> Signed-off-by: Lukas Wunner <lukas@wunner.de> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r--drivers/thunderbolt/icm.c13
-rw-r--r--drivers/thunderbolt/tb.c4
2 files changed, 6 insertions, 11 deletions
diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c
index 8ee340290219..17eba072e1ed 100644
--- a/drivers/thunderbolt/icm.c
+++ b/drivers/thunderbolt/icm.c
@@ -13,9 +13,9 @@
13 */ 13 */
14 14
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/dmi.h>
17#include <linux/mutex.h> 16#include <linux/mutex.h>
18#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/platform_data/x86/apple.h>
19#include <linux/sizes.h> 19#include <linux/sizes.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/workqueue.h> 21#include <linux/workqueue.h>
@@ -102,11 +102,6 @@ static inline u64 get_route(u32 route_hi, u32 route_lo)
102 return (u64)route_hi << 32 | route_lo; 102 return (u64)route_hi << 32 | route_lo;
103} 103}
104 104
105static inline bool is_apple(void)
106{
107 return dmi_match(DMI_BOARD_VENDOR, "Apple Inc.");
108}
109
110static bool icm_match(const struct tb_cfg_request *req, 105static bool icm_match(const struct tb_cfg_request *req,
111 const struct ctl_pkg *pkg) 106 const struct ctl_pkg *pkg)
112{ 107{
@@ -176,7 +171,7 @@ static int icm_request(struct tb *tb, const void *request, size_t request_size,
176 171
177static bool icm_fr_is_supported(struct tb *tb) 172static bool icm_fr_is_supported(struct tb *tb)
178{ 173{
179 return !is_apple(); 174 return !x86_apple_machine;
180} 175}
181 176
182static inline int icm_fr_get_switch_index(u32 port) 177static inline int icm_fr_get_switch_index(u32 port)
@@ -517,7 +512,7 @@ static bool icm_ar_is_supported(struct tb *tb)
517 * Starting from Alpine Ridge we can use ICM on Apple machines 512 * Starting from Alpine Ridge we can use ICM on Apple machines
518 * as well. We just need to reset and re-enable it first. 513 * as well. We just need to reset and re-enable it first.
519 */ 514 */
520 if (!is_apple()) 515 if (!x86_apple_machine)
521 return true; 516 return true;
522 517
523 /* 518 /*
@@ -1004,7 +999,7 @@ static int icm_start(struct tb *tb)
1004 * don't provide images publicly either. To be on the safe side 999 * don't provide images publicly either. To be on the safe side
1005 * prevent root switch NVM upgrade on Macs for now. 1000 * prevent root switch NVM upgrade on Macs for now.
1006 */ 1001 */
1007 tb->root_switch->no_nvm_upgrade = is_apple(); 1002 tb->root_switch->no_nvm_upgrade = x86_apple_machine;
1008 1003
1009 ret = tb_switch_add(tb->root_switch); 1004 ret = tb_switch_add(tb->root_switch);
1010 if (ret) 1005 if (ret)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 1b02ca0b6129..0b22ad9d68b4 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -7,7 +7,7 @@
7#include <linux/slab.h> 7#include <linux/slab.h>
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/dmi.h> 10#include <linux/platform_data/x86/apple.h>
11 11
12#include "tb.h" 12#include "tb.h"
13#include "tb_regs.h" 13#include "tb_regs.h"
@@ -453,7 +453,7 @@ struct tb *tb_probe(struct tb_nhi *nhi)
453 struct tb_cm *tcm; 453 struct tb_cm *tcm;
454 struct tb *tb; 454 struct tb *tb;
455 455
456 if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc.")) 456 if (!x86_apple_machine)
457 return NULL; 457 return NULL;
458 458
459 tb = tb_domain_alloc(nhi, sizeof(*tcm)); 459 tb = tb_domain_alloc(nhi, sizeof(*tcm));