Skip to content

Commit f21c179

Browse files
debox1jwrdegoede
authored andcommitted
platform/x86/intel/vsec: Rework early hardware code
In the Intel VSEC PCI driver, use a new VSEC_QUIRK_EARLY_HW flag in driver_data to indicate the need for early hardware quirks in auxiliary devices. Remove the separate PCI ID list maintained by the Intel PMT auxiliary driver. Cc: Srinivas Pandruvada <srinivas.pandruvada@intel.com> Signed-off-by: David E. Box <david.e.box@linux.intel.com> Signed-off-by: Gayatri Kammela <gayatri.kammela@linux.intel.com> Link: https://lore.kernel.org/r/20220629221334.434307-2-gayatri.kammela@linux.intel.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 9a1aac8 commit f21c179

File tree

3 files changed

+39
-41
lines changed

3 files changed

+39
-41
lines changed

drivers/platform/x86/intel/pmt/class.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,16 @@
2020
#define PMT_XA_MAX INT_MAX
2121
#define PMT_XA_LIMIT XA_LIMIT(PMT_XA_START, PMT_XA_MAX)
2222

23-
/*
24-
* Early implementations of PMT on client platforms have some
25-
* differences from the server platforms (which use the Out Of Band
26-
* Management Services Module OOBMSM). This list tracks those
27-
* platforms as needed to handle those differences. Newer client
28-
* platforms are expected to be fully compatible with server.
29-
*/
30-
static const struct pci_device_id pmt_telem_early_client_pci_ids[] = {
31-
{ PCI_VDEVICE(INTEL, 0x467d) }, /* ADL */
32-
{ PCI_VDEVICE(INTEL, 0x490e) }, /* DG1 */
33-
{ PCI_VDEVICE(INTEL, 0x9a0d) }, /* TGL */
34-
{ }
35-
};
36-
3723
bool intel_pmt_is_early_client_hw(struct device *dev)
3824
{
39-
struct pci_dev *parent = to_pci_dev(dev->parent);
25+
struct intel_vsec_device *ivdev = dev_to_ivdev(dev);
4026

41-
return !!pci_match_id(pmt_telem_early_client_pci_ids, parent);
27+
/*
28+
* Early implementations of PMT on client platforms have some
29+
* differences from the server platforms (which use the Out Of Band
30+
* Management Services Module OOBMSM).
31+
*/
32+
return !!(ivdev->info->quirks & VSEC_QUIRK_EARLY_HW);
4233
}
4334
EXPORT_SYMBOL_GPL(intel_pmt_is_early_client_hw);
4435

drivers/platform/x86/intel/vsec.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ struct intel_vsec_header {
5454
u32 offset;
5555
};
5656

57-
/* Platform specific data */
58-
struct intel_vsec_platform_info {
59-
struct intel_vsec_header **capabilities;
60-
unsigned long quirks;
61-
};
62-
6357
enum intel_vsec_id {
6458
VSEC_ID_TELEMETRY = 2,
6559
VSEC_ID_WATCHER = 3,
@@ -169,10 +163,11 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in
169163
}
170164

171165
static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *header,
172-
unsigned long quirks)
166+
struct intel_vsec_platform_info *info)
173167
{
174168
struct intel_vsec_device *intel_vsec_dev;
175169
struct resource *res, *tmp;
170+
unsigned long quirks = info->quirks;
176171
int i;
177172

178173
if (!intel_vsec_allowed(header->id) || intel_vsec_disabled(header->id, quirks))
@@ -216,7 +211,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
216211
intel_vsec_dev->pcidev = pdev;
217212
intel_vsec_dev->resource = res;
218213
intel_vsec_dev->num_resources = header->num_entries;
219-
intel_vsec_dev->quirks = quirks;
214+
intel_vsec_dev->info = info;
220215

221216
if (header->id == VSEC_ID_SDSI)
222217
intel_vsec_dev->ida = &intel_vsec_sdsi_ida;
@@ -226,14 +221,15 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
226221
return intel_vsec_add_aux(pdev, intel_vsec_dev, intel_vsec_name(header->id));
227222
}
228223

229-
static bool intel_vsec_walk_header(struct pci_dev *pdev, unsigned long quirks,
230-
struct intel_vsec_header **header)
224+
static bool intel_vsec_walk_header(struct pci_dev *pdev,
225+
struct intel_vsec_platform_info *info)
231226
{
227+
struct intel_vsec_header **header = info->capabilities;
232228
bool have_devices = false;
233229
int ret;
234230

235231
for ( ; *header; header++) {
236-
ret = intel_vsec_add_dev(pdev, *header, quirks);
232+
ret = intel_vsec_add_dev(pdev, *header, info);
237233
if (ret)
238234
dev_info(&pdev->dev, "Could not add device for DVSEC id %d\n",
239235
(*header)->id);
@@ -244,7 +240,8 @@ static bool intel_vsec_walk_header(struct pci_dev *pdev, unsigned long quirks,
244240
return have_devices;
245241
}
246242

247-
static bool intel_vsec_walk_dvsec(struct pci_dev *pdev, unsigned long quirks)
243+
static bool intel_vsec_walk_dvsec(struct pci_dev *pdev,
244+
struct intel_vsec_platform_info *info)
248245
{
249246
bool have_devices = false;
250247
int pos = 0;
@@ -283,7 +280,7 @@ static bool intel_vsec_walk_dvsec(struct pci_dev *pdev, unsigned long quirks)
283280
pci_read_config_dword(pdev, pos + PCI_DVSEC_HEADER2, &hdr);
284281
header.id = PCI_DVSEC_HEADER2_ID(hdr);
285282

286-
ret = intel_vsec_add_dev(pdev, &header, quirks);
283+
ret = intel_vsec_add_dev(pdev, &header, info);
287284
if (ret)
288285
continue;
289286

@@ -293,7 +290,8 @@ static bool intel_vsec_walk_dvsec(struct pci_dev *pdev, unsigned long quirks)
293290
return have_devices;
294291
}
295292

296-
static bool intel_vsec_walk_vsec(struct pci_dev *pdev, unsigned long quirks)
293+
static bool intel_vsec_walk_vsec(struct pci_dev *pdev,
294+
struct intel_vsec_platform_info *info)
297295
{
298296
bool have_devices = false;
299297
int pos = 0;
@@ -327,7 +325,7 @@ static bool intel_vsec_walk_vsec(struct pci_dev *pdev, unsigned long quirks)
327325
header.tbir = INTEL_DVSEC_TABLE_BAR(table);
328326
header.offset = INTEL_DVSEC_TABLE_OFFSET(table);
329327

330-
ret = intel_vsec_add_dev(pdev, &header, quirks);
328+
ret = intel_vsec_add_dev(pdev, &header, info);
331329
if (ret)
332330
continue;
333331

@@ -341,25 +339,24 @@ static int intel_vsec_pci_probe(struct pci_dev *pdev, const struct pci_device_id
341339
{
342340
struct intel_vsec_platform_info *info;
343341
bool have_devices = false;
344-
unsigned long quirks = 0;
345342
int ret;
346343

347344
ret = pcim_enable_device(pdev);
348345
if (ret)
349346
return ret;
350347

351348
info = (struct intel_vsec_platform_info *)id->driver_data;
352-
if (info)
353-
quirks = info->quirks;
349+
if (!info)
350+
return -EINVAL;
354351

355-
if (intel_vsec_walk_dvsec(pdev, quirks))
352+
if (intel_vsec_walk_dvsec(pdev, info))
356353
have_devices = true;
357354

358-
if (intel_vsec_walk_vsec(pdev, quirks))
355+
if (intel_vsec_walk_vsec(pdev, info))
359356
have_devices = true;
360357

361358
if (info && (info->quirks & VSEC_QUIRK_NO_DVSEC) &&
362-
intel_vsec_walk_header(pdev, quirks, info->capabilities))
359+
intel_vsec_walk_header(pdev, info))
363360
have_devices = true;
364361

365362
if (!have_devices)
@@ -370,7 +367,8 @@ static int intel_vsec_pci_probe(struct pci_dev *pdev, const struct pci_device_id
370367

371368
/* TGL info */
372369
static const struct intel_vsec_platform_info tgl_info = {
373-
.quirks = VSEC_QUIRK_NO_WATCHER | VSEC_QUIRK_NO_CRASHLOG | VSEC_QUIRK_TABLE_SHIFT,
370+
.quirks = VSEC_QUIRK_NO_WATCHER | VSEC_QUIRK_NO_CRASHLOG |
371+
VSEC_QUIRK_TABLE_SHIFT | VSEC_QUIRK_EARLY_HW,
374372
};
375373

376374
/* DG1 info */
@@ -390,7 +388,7 @@ static struct intel_vsec_header *dg1_capabilities[] = {
390388

391389
static const struct intel_vsec_platform_info dg1_info = {
392390
.capabilities = dg1_capabilities,
393-
.quirks = VSEC_QUIRK_NO_DVSEC,
391+
.quirks = VSEC_QUIRK_NO_DVSEC | VSEC_QUIRK_EARLY_HW,
394392
};
395393

396394
#define PCI_DEVICE_ID_INTEL_VSEC_ADL 0x467d
@@ -400,7 +398,7 @@ static const struct intel_vsec_platform_info dg1_info = {
400398
static const struct pci_device_id intel_vsec_pci_ids[] = {
401399
{ PCI_DEVICE_DATA(INTEL, VSEC_ADL, &tgl_info) },
402400
{ PCI_DEVICE_DATA(INTEL, VSEC_DG1, &dg1_info) },
403-
{ PCI_DEVICE_DATA(INTEL, VSEC_OOBMSM, NULL) },
401+
{ PCI_DEVICE_DATA(INTEL, VSEC_OOBMSM, &(struct intel_vsec_platform_info) {}) },
404402
{ PCI_DEVICE_DATA(INTEL, VSEC_TGL, &tgl_info) },
405403
{ }
406404
};

drivers/platform/x86/intel/vsec.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@ enum intel_vsec_quirks {
2020

2121
/* DVSEC not present (provided in driver data) */
2222
VSEC_QUIRK_NO_DVSEC = BIT(3),
23+
24+
/* Platforms requiring quirk in the auxiliary driver */
25+
VSEC_QUIRK_EARLY_HW = BIT(4),
26+
};
27+
28+
/* Platform specific data */
29+
struct intel_vsec_platform_info {
30+
struct intel_vsec_header **capabilities;
31+
unsigned long quirks;
2332
};
2433

2534
struct intel_vsec_device {
2635
struct auxiliary_device auxdev;
2736
struct pci_dev *pcidev;
2837
struct resource *resource;
2938
struct ida *ida;
30-
unsigned long quirks;
39+
struct intel_vsec_platform_info *info;
3140
int num_resources;
3241
};
3342

0 commit comments

Comments
 (0)