* [Intel-gfx] [PATCH] drm/i915: Sanitycheck PCI BARs on probe
@ 2022-01-20 11:30 Piorkowski, Piotr
2022-01-20 12:30 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for " Patchwork
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Piorkowski, Piotr @ 2022-01-20 11:30 UTC (permalink / raw)
To: intel-gfx
From: Piotr Piórkowski <piotr.piorkowski@intel.com>
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.
Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
---
drivers/gpu/drm/i915/i915_pci.c | 33 +++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_pci_config.h | 5 ++++
2 files changed, 38 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index 8261b6455747..ad60c69d9dd8 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -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;
diff --git a/drivers/gpu/drm/i915/intel_pci_config.h b/drivers/gpu/drm/i915/intel_pci_config.h
index 12cd9d4f23de..c08fd5d48ada 100644
--- a/drivers/gpu/drm/i915/intel_pci_config.h
+++ b/drivers/gpu/drm/i915/intel_pci_config.h
@@ -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
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Sanitycheck PCI BARs on probe
2022-01-20 11:30 [Intel-gfx] [PATCH] drm/i915: Sanitycheck PCI BARs on probe Piorkowski, Piotr
@ 2022-01-20 12:30 ` Patchwork
2022-05-19 22:29 ` [Intel-gfx] [PATCH] " Lucas De Marchi
2022-05-20 7:40 ` Jani Nikula
2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2022-01-20 12:30 UTC (permalink / raw)
To: Piorkowski, Piotr; +Cc: intel-gfx
[-- Attachment #1: Type: text/plain, Size: 7932 bytes --]
== 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@kms_addfb_basic@addfb25-framebuffer-vs-set-tiling.html
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/amd_cs_nop@sync-fork-compute0.html
* 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@basic-busy@bcs0.html
* 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@basic-s3@smem.html
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-tgl-1115g4/igt@gem_exec_suspend@basic-s3@smem.html
* 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@gem_huc_copy@huc-copy.html
* 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@gem_lmem_swapping@basic.html
* 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@gem_lmem_swapping@parallel-random-engines.html
* 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@live@hangcheck.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/bat-dg1-5/igt@i915_selftest@live@hangcheck.html
- 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@live@hangcheck.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-hsw-4770/igt@i915_selftest@live@hangcheck.html
* 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@kms_chamelium@dp-edid-read.html
* 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@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d.html
* 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@prime_vgem@basic-userptr.html
* 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@runner@aborted.html
- bat-adlp-4: NOTRUN -> [FAIL][19] ([i915#4312])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/bat-adlp-4/igt@runner@aborted.html
#### 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@live@hangcheck.html
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-snb-2600/igt@i915_selftest@live@hangcheck.html
* 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@kms_frontbuffer_tracking@basic.html
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22038/fi-cml-u2/igt@kms_frontbuffer_tracking@basic.html
* 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
[-- Attachment #2: Type: text/html, Size: 9606 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Sanitycheck PCI BARs on probe
2022-01-20 11:30 [Intel-gfx] [PATCH] drm/i915: Sanitycheck PCI BARs on probe Piorkowski, Piotr
2022-01-20 12:30 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for " Patchwork
@ 2022-05-19 22:29 ` Lucas De Marchi
2022-05-20 7:40 ` Jani Nikula
2 siblings, 0 replies; 5+ messages in thread
From: Lucas De Marchi @ 2022-05-19 22:29 UTC (permalink / raw)
To: Piorkowski, Piotr; +Cc: intel-gfx, Matthew Auld
On Thu, Jan 20, 2022 at 12:30:49PM +0100, Piorkowski, Piotr wrote:
>From: Piotr Piórkowski <piotr.piorkowski@intel.com>
>
>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.
>
>Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
>Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
>Cc: Jani Nikula <jani.nikula@linux.intel.com>
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?
Acked-by: Lucas De Marchi <lucas.demarchi@intel.com>
thanks
Lucas De Marchi
>---
> drivers/gpu/drm/i915/i915_pci.c | 33 +++++++++++++++++++++++++
> drivers/gpu/drm/i915/intel_pci_config.h | 5 ++++
> 2 files changed, 38 insertions(+)
>
>diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
>index 8261b6455747..ad60c69d9dd8 100644
>--- a/drivers/gpu/drm/i915/i915_pci.c
>+++ b/drivers/gpu/drm/i915/i915_pci.c
>@@ -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;
>diff --git a/drivers/gpu/drm/i915/intel_pci_config.h b/drivers/gpu/drm/i915/intel_pci_config.h
>index 12cd9d4f23de..c08fd5d48ada 100644
>--- a/drivers/gpu/drm/i915/intel_pci_config.h
>+++ b/drivers/gpu/drm/i915/intel_pci_config.h
>@@ -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
>--
>2.25.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Sanitycheck PCI BARs on probe
2022-01-20 11:30 [Intel-gfx] [PATCH] drm/i915: Sanitycheck PCI BARs on probe Piorkowski, Piotr
2022-01-20 12:30 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for " Patchwork
2022-05-19 22:29 ` [Intel-gfx] [PATCH] " Lucas De Marchi
@ 2022-05-20 7:40 ` Jani Nikula
2022-05-20 8:07 ` Piotr Piórkowski
2 siblings, 1 reply; 5+ messages in thread
From: Jani Nikula @ 2022-05-20 7:40 UTC (permalink / raw)
To: Piorkowski, Piotr, intel-gfx
On Thu, 20 Jan 2022, "Piorkowski, Piotr" <piotr.piorkowski@intel.com> wrote:
> From: Piotr Piórkowski <piotr.piorkowski@intel.com>
>
> 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.
>
> Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_pci.c | 33 +++++++++++++++++++++++++
> drivers/gpu/drm/i915/intel_pci_config.h | 5 ++++
> 2 files changed, 38 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> index 8261b6455747..ad60c69d9dd8 100644
> --- a/drivers/gpu/drm/i915/i915_pci.c
> +++ b/drivers/gpu/drm/i915/i915_pci.c
> @@ -29,6 +29,8 @@
> #include "i915_drv.h"
> #include "i915_pci.h"
>
Superfluous blank line.
> +#include "intel_pci_config.h"
Please put the includes together and sort.
> +
> #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;
We don't usually bother with const for non-pointer local variables.
> +
> + 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;
> diff --git a/drivers/gpu/drm/i915/intel_pci_config.h b/drivers/gpu/drm/i915/intel_pci_config.h
> index 12cd9d4f23de..c08fd5d48ada 100644
> --- a/drivers/gpu/drm/i915/intel_pci_config.h
> +++ b/drivers/gpu/drm/i915/intel_pci_config.h
> @@ -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.
> +
> /* BSM in include/drm/i915_drm.h */
>
> #define MCHBAR_I915 0x44
--
Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Sanitycheck PCI BARs on probe
2022-05-20 7:40 ` Jani Nikula
@ 2022-05-20 8:07 ` Piotr Piórkowski
0 siblings, 0 replies; 5+ messages in thread
From: Piotr Piórkowski @ 2022-05-20 8:07 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx
Jani Nikula <jani.nikula@linux.intel.com> wrote on pią [2022-maj-20 10:40:01 +0300]:
> On Thu, 20 Jan 2022, "Piorkowski, Piotr" <piotr.piorkowski@intel.com> wrote:
> > From: Piotr Piórkowski <piotr.piorkowski@intel.com>
> >
> > 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.
> >
> > Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
> > Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > ---
> > drivers/gpu/drm/i915/i915_pci.c | 33 +++++++++++++++++++++++++
> > drivers/gpu/drm/i915/intel_pci_config.h | 5 ++++
> > 2 files changed, 38 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> > index 8261b6455747..ad60c69d9dd8 100644
> > --- a/drivers/gpu/drm/i915/i915_pci.c
> > +++ b/drivers/gpu/drm/i915/i915_pci.c
> > @@ -29,6 +29,8 @@
> > #include "i915_drv.h"
> > #include "i915_pci.h"
> >
>
> Superfluous blank line.
>
> > +#include "intel_pci_config.h"
>
> Please put the includes together and sort.
>
ok
> > +
> > #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;
>
> We don't usually bother with const for non-pointer local variables.
ok
>
> > +
> > + 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;
> > diff --git a/drivers/gpu/drm/i915/intel_pci_config.h b/drivers/gpu/drm/i915/intel_pci_config.h
> > index 12cd9d4f23de..c08fd5d48ada 100644
> > --- a/drivers/gpu/drm/i915/intel_pci_config.h
> > +++ b/drivers/gpu/drm/i915/intel_pci_config.h
> > @@ -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.
>
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
> BR,
> Jani.
>
>
> > +
> > /* BSM in include/drm/i915_drm.h */
> >
> > #define MCHBAR_I915 0x44
>
> --
> Jani Nikula, Intel Open Source Graphics Center
--
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-05-20 8:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 11:30 [Intel-gfx] [PATCH] drm/i915: Sanitycheck PCI BARs on probe Piorkowski, Piotr
2022-01-20 12:30 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for " Patchwork
2022-05-19 22:29 ` [Intel-gfx] [PATCH] " Lucas De Marchi
2022-05-20 7:40 ` Jani Nikula
2022-05-20 8:07 ` Piotr Piórkowski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.