summaryrefslogtreecommitdiff
path: root/drivers/iommu/amd/quirks.c
blob: 5120ce4fdce326b6b59185d66e7ba8cb146bf4d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* SPDX-License-Identifier: GPL-2.0-only */

/*
 * Quirks for AMD IOMMU
 *
 * Copyright (C) 2019 Kai-Heng Feng <kai.heng.feng@canonical.com>
 */

#ifdef CONFIG_DMI
#include <linux/dmi.h>

#include "amd_iommu.h"

#define IVHD_SPECIAL_IOAPIC		1

struct ivrs_quirk_entry {
	u8 id;
	u16 devid;
};

enum {
	DELL_INSPIRON_7375 = 0,
	DELL_LATITUDE_5495,
	LENOVO_IDEAPAD_330S_15ARR,
};

static const struct ivrs_quirk_entry ivrs_ioapic_quirks[][3] __initconst = {
	/* ivrs_ioapic[4]=00:14.0 ivrs_ioapic[5]=00:00.2 */
	[DELL_INSPIRON_7375] = {
		{ .id = 4, .devid = 0xa0 },
		{ .id = 5, .devid = 0x2 },
		{}
	},
	/* ivrs_ioapic[4]=00:14.0 */
	[DELL_LATITUDE_5495] = {
		{ .id = 4, .devid = 0xa0 },
		{}
	},
	/* ivrs_ioapic[32]=00:14.0 */
	[LENOVO_IDEAPAD_330S_15ARR] = {
		{ .id = 32, .devid = 0xa0 },
		{}
	},
	{}
};

static int __init ivrs_ioapic_quirk_cb(const struct dmi_system_id *d)
{
	const struct ivrs_quirk_entry *i;

	for (i = d->driver_data; i->id != 0 && i->devid != 0; i++)
		add_special_device(IVHD_SPECIAL_IOAPIC, i->id, (u16 *)&i->devid, 0);

	return 0;
}

static const struct dmi_system_id ivrs_quirks[] __initconst = {
	{
		.callback = ivrs_ioapic_quirk_cb,
		.ident = "Dell Inspiron 7375",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
			DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7375"),
		},
		.driver_data = (void *)&ivrs_ioapic_quirks[DELL_INSPIRON_7375],
	},
	{
		.callback = ivrs_ioapic_quirk_cb,
		.ident = "Dell Latitude 5495",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
			DMI_MATCH(DMI_PRODUCT_NAME, "Latitude 5495"),
		},
		.driver_data = (void *)&ivrs_ioapic_quirks[DELL_LATITUDE_5495],
	},
	{
		/*
		 * Acer Aspire A315-41 requires the very same workaround as
		 * Dell Latitude 5495
		 */
		.callback = ivrs_ioapic_quirk_cb,
		.ident = "Acer Aspire A315-41",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire A315-41"),
		},
		.driver_data = (void *)&ivrs_ioapic_quirks[DELL_LATITUDE_5495],
	},
	{
		.callback = ivrs_ioapic_quirk_cb,
		.ident = "Lenovo ideapad 330S-15ARR",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
			DMI_MATCH(DMI_PRODUCT_NAME, "81FB"),
		},
		.driver_data = (void *)&ivrs_ioapic_quirks[LENOVO_IDEAPAD_330S_15ARR],
	},
	{}
};

void __init amd_iommu_apply_ivrs_quirks(void)
{
	dmi_check_system(ivrs_quirks);
}
#endif