Skip to contentSkip to conversation

drm/i915: Sanitycheck PCI BARs on probe

PATCH In review Piorkowski, Piotr 4 participants 5 messages Jan 20, 2022 – May 20, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Sanitycheck PCI BARs on probe

From: Piotr Piórkowski <[email protected]>

For proper operation of i915 we need usable PCI BARs:
- GTTMMADDR BAR 0 (1 for GEN2)
- GFXMEM BAR 2.
Lets check before we start the i915 probe that these BARs are set, and that they have a size greater than 0.

Cc Michal Wajdeczko <[email protected]>
Cc Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/i915_pci.c         | 33 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_pci_config.h |  5 ++++
 2 files changed, 38 insertions(+)
drivers/gpu/drm/i915/i915_pci.c +33 -0
index 8261b6455747..ad60c69d9dd8 100644
@@ -29,6 +29,8 @@
 #include "i915_drv.h"
 #include "i915_pci.h"
 
+#include "intel_pci_config.h"
+
 #define PLATFORM(x) .platform = (x)
 #define GEN(x) \
 	.graphics.ver = (x), \
@@ -1181,6 +1183,34 @@ static bool force_probe(u16 device_id, const char *devices)
 	return ret;
 }
 
+static bool __pci_resource_valid(struct pci_dev *pdev, int bar)
+{
+	if (!pci_resource_flags(pdev, bar))
+		return false;
+
+	if (pci_resource_flags(pdev, bar) & IORESOURCE_UNSET)
+		return false;
+
+	if (!pci_resource_len(pdev, bar))
+		return false;
+
+	return true;
+}
+
+static bool intel_bars_valid(struct pci_dev *pdev, struct intel_device_info *intel_info)
+{
+	const int gttmmaddr_bar = intel_info->graphics.ver == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR;
+	const int gfxmem_bar = GFXMEM_BAR;
+
+	if (!__pci_resource_valid(pdev, gttmmaddr_bar))
+		return false;
+
+	if (!__pci_resource_valid(pdev, gfxmem_bar))
+		return false;
+
+	return true;
+}
+
 static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	struct intel_device_info *intel_info =
@@ -1206,6 +1236,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (PCI_FUNC(pdev->devfn))
 		return -ENODEV;
 
+	if (!intel_bars_valid(pdev, intel_info))
+		return -ENODEV;
+
 	/* Detect if we need to wait for other drivers early on */
 	if (intel_modeset_probe_defer(pdev))
 		return -EPROBE_DEFER;
drivers/gpu/drm/i915/intel_pci_config.h +5 -0
index 12cd9d4f23de..c08fd5d48ada 100644
@@ -6,6 +6,11 @@
 #ifndef __INTEL_PCI_CONFIG_H__
 #define __INTEL_PCI_CONFIG_H__
 
+/* PCI BARs */
+#define GTTMMADR_BAR				0
+#define GEN2_GTTMMADR_BAR			1
+#define GFXMEM_BAR				2
+
 /* BSM in include/drm/i915_drm.h */
 
 #define MCHBAR_I915				0x44
Signature · 1 line
2.25.1
#1 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Sanitycheck PCI BARs on probe

== Series Details ==

== Series Details ==

Series: drm/i915: Sanitycheck PCI BARs on probe
URL : https://patchwork.freedesktop.org/series/99094/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_11111 -> Patchwork_22038
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_22038 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_22038, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/index.html

Participating hosts (48 -> 44)
------------------------------

Additional (2): fi-kbl-soraka bat-adlp-4
Missing (6): shard-tglu fi-bsw-cyan fi-icl-u2 shard-rkl shard-dg1 fi-bdw-samus

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_22038:

### IGT changes ###

#### Possible regressions ####

* igt@kms_addfb_basic@addfb25-framebuffer-vs-set-tiling:
- bat-adlp-4: NOTRUN -> [DMESG-WARN][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/bat-adlp-4/igt@[email protected]

Known issues
------------

Here are the changes found in Patchwork_22038 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@amdgpu/amd_cs_nop@sync-fork-compute0:
- fi-snb-2600: NOTRUN -> [SKIP][2] ([fdo#109271]) +17 similar issues
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-snb-2600/igt@amdgpu/[email protected]

* igt@gem_exec_fence@basic-busy@bcs0:
- fi-kbl-soraka: NOTRUN -> [SKIP][3] ([fdo#109271]) +8 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-kbl-soraka/igt@gem_exec_fence@[email protected]

* igt@gem_exec_suspend@basic-s3@smem:
- fi-tgl-1115g4: [PASS][4] -> [FAIL][5] ([i915#1888])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11111/fi-tgl-1115g4/igt@gem_exec_suspend@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-tgl-1115g4/igt@gem_exec_suspend@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-kbl-soraka: NOTRUN -> [SKIP][6] ([fdo#109271] / [i915#2190])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-kbl-soraka/igt@[email protected]

* igt@gem_lmem_swapping@basic:
- bat-adlp-4: NOTRUN -> [SKIP][7] ([i915#4613]) +3 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/bat-adlp-4/igt@[email protected]

* igt@gem_lmem_swapping@parallel-random-engines:
- fi-kbl-soraka: NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#4613]) +3 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-kbl-soraka/igt@[email protected]

* igt@gem_tiled_pread_basic:
- bat-adlp-4: NOTRUN -> [SKIP][9] ([i915#3282])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/bat-adlp-4/igt@gem_tiled_pread_basic.html

* igt@i915_selftest@live@gt_pm:
- fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][10] ([i915#1886] / [i915#2291])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html

* igt@i915_selftest@live@hangcheck:
- bat-dg1-5: [PASS][11] -> [DMESG-FAIL][12] ([i915#4494])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11111/bat-dg1-5/igt@i915_selftest@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/bat-dg1-5/igt@i915_selftest@[email protected]
- fi-hsw-4770: [PASS][13] -> [INCOMPLETE][14] ([i915#4785])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11111/fi-hsw-4770/igt@i915_selftest@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-hsw-4770/igt@i915_selftest@[email protected]

* igt@kms_chamelium@dp-edid-read:
- fi-kbl-soraka: NOTRUN -> [SKIP][15] ([fdo#109271] / [fdo#111827]) +8 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-kbl-soraka/igt@[email protected]

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d:
- fi-kbl-soraka: NOTRUN -> [SKIP][16] ([fdo#109271] / [i915#533])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-kbl-soraka/igt@[email protected]

* igt@prime_vgem@basic-userptr:
- fi-skl-6600u: NOTRUN -> [SKIP][17] ([fdo#109271]) +18 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-skl-6600u/igt@[email protected]

* igt@runner@aborted:
- fi-hsw-4770: NOTRUN -> [FAIL][18] ([fdo#109271] / [i915#1436] / [i915#4312])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-hsw-4770/igt@[email protected]
- bat-adlp-4: NOTRUN -> [FAIL][19] ([i915#4312])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/bat-adlp-4/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@hangcheck:
- fi-snb-2600: [INCOMPLETE][20] ([i915#3921]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11111/fi-snb-2600/igt@i915_selftest@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-snb-2600/igt@i915_selftest@[email protected]

* igt@kms_frontbuffer_tracking@basic:
- fi-cml-u2: [DMESG-WARN][22] ([i915#4269]) -> [PASS][23]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11111/fi-cml-u2/igt@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-cml-u2/igt@[email protected]

* igt@kms_psr@primary_page_flip:
- fi-skl-6600u: [FAIL][24] ([i915#4547]) -> [PASS][25]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11111/fi-skl-6600u/igt@kms_psr@primary_page_flip.html
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-skl-6600u/igt@kms_psr@primary_page_flip.html

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
[i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886
[i915#1888]: https://gitlab.freedesktop.org/drm/intel/issues/1888
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2291]: https://gitlab.freedesktop.org/drm/intel/issues/2291
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3921]: https://gitlab.freedesktop.org/drm/intel/issues/3921
[i915#4269]: https://gitlab.freedesktop.org/drm/intel/issues/4269
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4494]: https://gitlab.freedesktop.org/drm/intel/issues/4494
[i915#4547]: https://gitlab.freedesktop.org/drm/intel/issues/4547
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4785]: https://gitlab.freedesktop.org/drm/intel/issues/4785
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533

Build changes
-------------

* Linux: CI_DRM_11111 -> Patchwork_22038

CI-20190529: 20190529
CI_DRM_11111: fe44f8bdb12374a6168cb561834eb714097f5e5f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6329: 38f656fdd61119105ecfa2c4dac157cd7dcad204 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_22038: 7039a907c8b869cc4f279793654a088a752d095e @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

7039a907c8b8 drm/i915: Sanitycheck PCI BARs on probe

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/index.html

Acked-by on v1 1/1
#2 lore raw
In reply to Piorkowski, Piotr
Quoted 11 lines · Piotr

From: Piotr Piórkowski <[email protected]>

For proper operation of i915 we need usable PCI BARs:
- GTTMMADDR BAR 0 (1 for GEN2)
- GFXMEM BAR 2.
Lets check before we start the i915 probe that these BARs are set, and that they have a size greater than 0.

Cc Michal Wajdeczko <[email protected]>
Cc Jani Nikula <[email protected]>

This sounds reasonable to me... should catch issues in which the BIOS didn't assign resources properly, PCI subsystem tried to reassign them and we ended up left withou a BAR.

+Matt Auld who is working on small BAR recovery... slightly related. Does this look ok?

thanks
Lucas De Marchi

Quoted 82 lines

---
drivers/gpu/drm/i915/i915_pci.c | 33 +++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_pci_config.h | 5 ++++

2 files changed, 38 insertions(+)
drivers/gpu/drm/i915/i915_pci.c +33 -0
index 8261b6455747..ad60c69d9dd8 100644
@@ -29,6 +29,8 @@
 #include "i915_drv.h"
 #include "i915_pci.h"
 
+#include "intel_pci_config.h"
+
 #define PLATFORM(x) .platform = (x)
 #define GEN(x) \
 	.graphics.ver = (x), \
@@ -1181,6 +1183,34 @@ static bool force_probe(u16 device_id, const char *devices)
 	return ret;
 }
 
+static bool __pci_resource_valid(struct pci_dev *pdev, int bar)
+{
+	if (!pci_resource_flags(pdev, bar))
+		return false;
+
+	if (pci_resource_flags(pdev, bar) & IORESOURCE_UNSET)
+		return false;
+
+	if (!pci_resource_len(pdev, bar))
+		return false;
+
+	return true;
+}
+
+static bool intel_bars_valid(struct pci_dev *pdev, struct intel_device_info *intel_info)
+{
+	const int gttmmaddr_bar = intel_info->graphics.ver == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR;
+	const int gfxmem_bar = GFXMEM_BAR;
+
+	if (!__pci_resource_valid(pdev, gttmmaddr_bar))
+		return false;
+
+	if (!__pci_resource_valid(pdev, gfxmem_bar))
+		return false;
+
+	return true;
+}
+
 static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	struct intel_device_info *intel_info =
@@ -1206,6 +1236,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (PCI_FUNC(pdev->devfn))
 		return -ENODEV;
 
+	if (!intel_bars_valid(pdev, intel_info))
+		return -ENODEV;
+
 	/* Detect if we need to wait for other drivers early on */
 	if (intel_modeset_probe_defer(pdev))
 		return -EPROBE_DEFER;
drivers/gpu/drm/i915/intel_pci_config.h +5 -0
index 12cd9d4f23de..c08fd5d48ada 100644
@@ -6,6 +6,11 @@
 #ifndef __INTEL_PCI_CONFIG_H__
 #define __INTEL_PCI_CONFIG_H__
 
+/* PCI BARs */
+#define GTTMMADR_BAR				0
+#define GEN2_GTTMMADR_BAR			1
+#define GFXMEM_BAR				2
+
 /* BSM in include/drm/i915_drm.h */
 
 #define MCHBAR_I915				0x44
Signature · 1 line
2.25.1
maintainer
#3 lore raw
In reply to Piorkowski, Piotr
Quoted 21 lines · Piotr

From: Piotr Piórkowski <[email protected]>

For proper operation of i915 we need usable PCI BARs:
- GTTMMADDR BAR 0 (1 for GEN2)
- GFXMEM BAR 2.
Lets check before we start the i915 probe that these BARs are set, and that they have a size greater than 0.

Cc Michal Wajdeczko <[email protected]>
Cc Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/i915_pci.c         | 33 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_pci_config.h |  5 ++++
 2 files changed, 38 insertions(+)
drivers/gpu/drm/i915/i915_pci.c +0 -0
index 8261b6455747..ad60c69d9dd8 100644

drivers/gpu/drm/i915/i915_pci.c line 31

Quoted 3 lines
drivers/gpu/drm/i915/i915_pci.c +0 -0
@@ -29,6 +29,8 @@
 #include "i915_drv.h"
 #include "i915_pci.h"
 

Superfluous blank line.

drivers/gpu/drm/i915/i915_pci.c line 32

Quoted 1 line
drivers/gpu/drm/i915/i915_pci.c +1 -0
+#include "intel_pci_config.h"

Please put the includes together and sort.

Quoted 16 lines
drivers/gpu/drm/i915/i915_pci.c +9 -0
+
 #define PLATFORM(x) .platform = (x)
 #define GEN(x) \
 	.graphics.ver = (x), \
@@ -1181,6 +1183,34 @@ static bool force_probe(u16 device_id, const char *devices)
 	return ret;
 }
 
+static bool __pci_resource_valid(struct pci_dev *pdev, int bar)
+{
+	if (!pci_resource_flags(pdev, bar))
+		return false;
+
+	if (pci_resource_flags(pdev, bar) & IORESOURCE_UNSET)
+		return false;
+

drivers/gpu/drm/i915/i915_pci.c static bool force_probe(u16 device_id, const char *devices) · line 1203

Quoted 10 lines
drivers/gpu/drm/i915/i915_pci.c +10 -0
+	if (!pci_resource_len(pdev, bar))
+		return false;
+
+	return true;
+}
+
+static bool intel_bars_valid(struct pci_dev *pdev, struct intel_device_info *intel_info)
+{
+	const int gttmmaddr_bar = intel_info->graphics.ver == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR;
+	const int gfxmem_bar = GFXMEM_BAR;

We don't usually bother with const for non-pointer local variables.

Quoted 28 lines
drivers/gpu/drm/i915/i915_pci.c +13 -0
+
+	if (!__pci_resource_valid(pdev, gttmmaddr_bar))
+		return false;
+
+	if (!__pci_resource_valid(pdev, gfxmem_bar))
+		return false;
+
+	return true;
+}
+
 static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	struct intel_device_info *intel_info =
@@ -1206,6 +1236,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (PCI_FUNC(pdev->devfn))
 		return -ENODEV;
 
+	if (!intel_bars_valid(pdev, intel_info))
+		return -ENODEV;
+
 	/* Detect if we need to wait for other drivers early on */
 	if (intel_modeset_probe_defer(pdev))
 		return -EPROBE_DEFER;
drivers/gpu/drm/i915/intel_pci_config.h +0 -0
index 12cd9d4f23de..c08fd5d48ada 100644

drivers/gpu/drm/i915/intel_pci_config.h line 12

Quoted 7 lines
drivers/gpu/drm/i915/intel_pci_config.h +4 -0
@@ -6,6 +6,11 @@
 #ifndef __INTEL_PCI_CONFIG_H__
 #define __INTEL_PCI_CONFIG_H__
 
+/* PCI BARs */
+#define GTTMMADR_BAR				0
+#define GEN2_GTTMMADR_BAR			1
+#define GFXMEM_BAR				2

Is anyone outside of intel_pci_config.c going to need these? They could be there if not.

BR,
Jani.

Quoted 4 lines
drivers/gpu/drm/i915/intel_pci_config.h +1 -0
+
 /* BSM in include/drm/i915_drm.h */
 
 #define MCHBAR_I915				0x44
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
#4 lore raw

Jani Nikula <[email protected]> wrote on pią [2022-maj-20 10:40:01 +0300]:

Quoted 28 lines · Piotr
Quoted 21 lines

From: Piotr Piórkowski <[email protected]>

For proper operation of i915 we need usable PCI BARs:
- GTTMMADDR BAR 0 (1 for GEN2)
- GFXMEM BAR 2.
Lets check before we start the i915 probe that these BARs are set, and that they have a size greater than 0.

Cc Michal Wajdeczko <[email protected]>
Cc Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/i915_pci.c         | 33 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_pci_config.h |  5 ++++
 2 files changed, 38 insertions(+)
drivers/gpu/drm/i915/i915_pci.c +0 -0
index 8261b6455747..ad60c69d9dd8 100644

drivers/gpu/drm/i915/i915_pci.c line 31

Quoted 3 lines
drivers/gpu/drm/i915/i915_pci.c +0 -0
@@ -29,6 +29,8 @@
 #include "i915_drv.h"
 #include "i915_pci.h"
 

Superfluous blank line.

Quoted 4 lines

drivers/gpu/drm/i915/i915_pci.c line 32

Quoted 1 line
drivers/gpu/drm/i915/i915_pci.c +1 -0
+#include "intel_pci_config.h"

Please put the includes together and sort.

ok

Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/i915/i915_pci.c +13 -0
+
 #define PLATFORM(x) .platform = (x)
 #define GEN(x) \
 	.graphics.ver = (x), \
@@ -1181,6 +1183,34 @@ static bool force_probe(u16 device_id, const char *devices)
 	return ret;
 }
 
+static bool __pci_resource_valid(struct pci_dev *pdev, int bar)
+{
+	if (!pci_resource_flags(pdev, bar))
+		return false;
+
+	if (pci_resource_flags(pdev, bar) & IORESOURCE_UNSET)
+		return false;
+
+	if (!pci_resource_len(pdev, bar))
+		return false;
+
+	return true;
Quoted 8 lines

drivers/gpu/drm/i915/i915_pci.c static bool force_probe(u16 device_id, const char *devices) · line 1203

Quoted 6 lines
drivers/gpu/drm/i915/i915_pci.c +6 -0
+}
+
+static bool intel_bars_valid(struct pci_dev *pdev, struct intel_device_info *intel_info)
+{
+	const int gttmmaddr_bar = intel_info->graphics.ver == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR;
+	const int gfxmem_bar = GFXMEM_BAR;

We don't usually bother with const for non-pointer local variables.

ok

Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/i915/i915_pci.c +13 -0
+
+	if (!__pci_resource_valid(pdev, gttmmaddr_bar))
+		return false;
+
+	if (!__pci_resource_valid(pdev, gfxmem_bar))
+		return false;
+
+	return true;
+}
+
 static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	struct intel_device_info *intel_info =
@@ -1206,6 +1236,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (PCI_FUNC(pdev->devfn))
 		return -ENODEV;
 
+	if (!intel_bars_valid(pdev, intel_info))
+		return -ENODEV;
+
 	/* Detect if we need to wait for other drivers early on */
 	if (intel_modeset_probe_defer(pdev))
 		return -EPROBE_DEFER;
drivers/gpu/drm/i915/intel_pci_config.h +0 -0
index 12cd9d4f23de..c08fd5d48ada 100644
@@ -6,6 +6,11 @@
 #ifndef __INTEL_PCI_CONFIG_H__
 #define __INTEL_PCI_CONFIG_H__
 
Quoted 8 lines

drivers/gpu/drm/i915/intel_pci_config.h line 12

Quoted 4 lines
drivers/gpu/drm/i915/intel_pci_config.h +4 -0
+/* PCI BARs */
+#define GTTMMADR_BAR				0
+#define GEN2_GTTMMADR_BAR			1
+#define GFXMEM_BAR				2

Is anyone outside of intel_pci_config.c going to need these? They could be there if not.

We could use this in all i915. There are lots of places where we use BAR numbers instead of constants when operating on pci resources.
E.g. all intel_pci_resource calls, or directs calls pci_resource_start and pci_resource_len.
For now, we use two ( and an exception for gen2) BARs in i915,
but there may be more in the future.
It may be useful to organize this.

Thanks for review!
Piotr

Quoted 11 lines

BR,
Jani.

Quoted 4 lines
drivers/gpu/drm/i915/intel_pci_config.h +1 -0
+
 /* BSM in include/drm/i915_drm.h */
 
 #define MCHBAR_I915				0x44
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center