Skip to contentSkip to conversation

drm: Move struct drm_device.pdev to legacy

PATCH Superseded Thomas Zimmermann 3 participants 9 messages Apr 27, 2021

Subsystems (3)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

v7 cover drm: Move struct drm_device.pdev to legacy

V7 of the patchset fixes some bitrot in the intel driver.

The pdev field in struct drm_device points to a PCI device structure and goes back to UMS-only days when all DRM drivers were for PCI devices. Meanwhile we also support USB, SPI and platform devices. Each of those uses the generic device stored in struct drm_device.dev.

To reduce duplication and remove the special case of PCI, this patchset converts all modesetting drivers from pdev to dev and makes pdev a field for legacy UMS drivers.

For PCI devices, the pointer in struct drm_device.dev can be upcasted to struct pci_device; or tested for PCI with dev_is_pci(). In several places the code can use the dev field directly.

After converting all drivers and the DRM core, the pdev fields becomes only relevant for legacy drivers. In a later patchset, we may want to convert these as well and remove pdev entirely.

v7:
* fix instances of pdev that have benn added under i915/
v6:
* also remove assignment in i915/selftests in later patch (Chris)
v5:
* remove assignment in later patch (Chris)
v4:
* merged several patches
* moved core changes into separate patch
* vmwgfx build fix
v3:
* merged several patches
* fix one pdev reference in nouveau (Jeremy)
* rebases
v2:
* move whitespace fixes into separate patches (Alex, Sam)
* move i915 gt/ and gvt/ changes into separate patches (Joonas)

Thomas Zimmermann (4):
drm/i915/gt: Remove reference to struct drm_device.pdev drm/i915: Remove reference to struct drm_device.pdev drm/i915: Don't assign to struct drm_device.pdev
drm: Move struct drm_device.pdev to legacy section

 drivers/gpu/drm/i915/gt/intel_region_lmem.c      | 2 +-
 drivers/gpu/drm/i915/i915_drv.c                  | 1 -
 drivers/gpu/drm/i915/intel_runtime_pm.h          | 2 +-
 drivers/gpu/drm/i915/selftests/mock_gem_device.c | 1 -
 include/drm/drm_device.h                         | 6 +++---
 5 files changed, 5 insertions(+), 7 deletions(-)

--
2.31.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#1 lore raw

PATCH v7 1/4 drm/i915/gt: Remove reference to struct drm_device.pdev

References to struct drm_device.pdev should be used any longer as the field will be moved into the struct's legacy section. Add a fix for the rsp commit.

Fixes a50ca39fbd01 ("drm/i915: setup the LMEM region")
Cc Lucas De Marchi <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Matthew Auld <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Mika Kuoppala <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Venkata Sandeep Dhanalakota <[email protected]>
Cc "Michał Winiarski" <[email protected]>
---
 drivers/gpu/drm/i915/gt/intel_region_lmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_region_lmem.c +1 -1
index be6f2c8f5184..73fceb0c25fc 100644
@@ -177,7 +177,7 @@ static struct intel_memory_region *setup_lmem(struct intel_gt *gt)
 {
 	struct drm_i915_private *i915 = gt->i915;
 	struct intel_uncore *uncore = gt->uncore;
-	struct pci_dev *pdev = i915->drm.pdev;
+	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
 	struct intel_memory_region *mem;
 	resource_size_t io_start;
 	resource_size_t lmem_size;
Signature · 6 lines
2.31.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author maintainer
#2 lore raw

PATCH v7 2/4 drm/i915: Remove reference to struct drm_device.pdev

In reply to Thomas Zimmermann

References to struct drm_device.pdev should be used any longer as the field will be moved into the struct's legacy section. Fix a rsp comment.

---
 drivers/gpu/drm/i915/intel_runtime_pm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_runtime_pm.h +1 -1
index 1e4ddd11c12b..183ea2b187fe 100644
@@ -49,7 +49,7 @@ enum i915_drm_suspend_mode {
  */
 struct intel_runtime_pm {
 	atomic_t wakeref_count;
-	struct device *kdev; /* points to i915->drm.pdev->dev */
+	struct device *kdev; /* points to i915->drm.dev */
 	bool available;
 	bool suspended;
 	bool irqs_enabled;
Signature · 6 lines
2.31.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author maintainer
#3 lore raw

PATCH v7 3/4 drm/i915: Don't assign to struct drm_device.pdev

In reply to Thomas Zimmermann

Using struct drm_device.pdev is deprecated. Don't assign it. Users should upcast from struct drm_device.dev.

v6:
* also fix the assignment in selftests in this patch (Chris)

---
 drivers/gpu/drm/i915/i915_drv.c                  | 1 -
 drivers/gpu/drm/i915/selftests/mock_gem_device.c | 1 -
 2 files changed, 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +0 -1
index 785dcf20c77b..db513f93f0f5 100644
@@ -758,7 +758,6 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (IS_ERR(i915))
 		return i915;
 
-	i915->drm.pdev = pdev;
 	pci_set_drvdata(pdev, i915);
 
 	/* Device parameters start as a copy of module parameters. */
drivers/gpu/drm/i915/selftests/mock_gem_device.c +0 -1
index 2ffc763fe90d..cf40004bc92a 100644
@@ -146,7 +146,6 @@ struct drm_i915_private *mock_gem_device(void)
 	}
 
 	pci_set_drvdata(pdev, i915);
-	i915->drm.pdev = pdev;
 
 	dev_pm_domain_set(&pdev->dev, &pm_domain);
 	pm_runtime_enable(&pdev->dev);
Signature · 6 lines
2.31.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#4 lore raw

PATCH v7 4/4 drm: Move struct drm_device.pdev to legacy section

In reply to Thomas Zimmermann

Struct drm_device.pdev is being moved to legacy status as only legacy DRM drivers use it. A possible follow-up patchset could remove pdev entirely.

v4:
* rebased

---
 include/drm/drm_device.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/drm/drm_device.h +3 -3
index d647223e8390..c5a195676e8f 100644
@@ -279,9 +279,6 @@ struct drm_device {
 	/** @agp: AGP data */
 	struct drm_agp_head *agp;
 
-	/** @pdev: PCI device structure */
-	struct pci_dev *pdev;
-
 	/** @num_crtcs: Number of CRTCs on this device */
 	unsigned int num_crtcs;
 
@@ -324,6 +321,9 @@ struct drm_device {
 	/* List of devices per driver for stealth attach cleanup */
 	struct list_head legacy_dev_list;
 
+	/* PCI device structure */
+	struct pci_dev *pdev;
+
 #ifdef __alpha__
 	/** @hose: PCI hose, only used on ALPHA platforms. */
 	struct pci_controller *hose;
Signature · 6 lines
2.31.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Reviewed-by on the v7 series
#5 lore raw
In reply to Thomas Zimmermann
Quoted 11 lines · Thomas Zimmermann

V7 of the patchset fixes some bitrot in the intel driver.

The pdev field in struct drm_device points to a PCI device structure and goes back to UMS-only days when all DRM drivers were for PCI devices. Meanwhile we also support USB, SPI and platform devices. Each of those uses the generic device stored in struct drm_device.dev.

To reduce duplication and remove the special case of PCI, this patchset converts all modesetting drivers from pdev to dev and makes pdev a field for legacy UMS drivers.

Quoted 7 lines

For PCI devices, the pointer in struct drm_device.dev can be upcasted to struct pci_device; or tested for PCI with dev_is_pci(). In several places the code can use the dev field directly.

After converting all drivers and the DRM core, the pdev fields becomes only relevant for legacy drivers. In a later patchset, we may want to convert these as well and remove pdev entirely.

On the series,

How should we merge these?

Quoted 35 lines

v7:
* fix instances of pdev that have benn added under i915/
v6:
* also remove assignment in i915/selftests in later patch (Chris)
v5:
* remove assignment in later patch (Chris)
v4:
* merged several patches
* moved core changes into separate patch
* vmwgfx build fix
v3:
* merged several patches
* fix one pdev reference in nouveau (Jeremy)
* rebases
v2:
* move whitespace fixes into separate patches (Alex, Sam)
* move i915 gt/ and gvt/ changes into separate patches (Joonas)

Thomas Zimmermann (4):
drm/i915/gt: Remove reference to struct drm_device.pdev drm/i915: Remove reference to struct drm_device.pdev drm/i915: Don't assign to struct drm_device.pdev
drm: Move struct drm_device.pdev to legacy section

 drivers/gpu/drm/i915/gt/intel_region_lmem.c      | 2 +-
 drivers/gpu/drm/i915/i915_drv.c                  | 1 -
 drivers/gpu/drm/i915/intel_runtime_pm.h          | 2 +-
 drivers/gpu/drm/i915/selftests/mock_gem_device.c | 1 -
 include/drm/drm_device.h                         | 6 +++---
 5 files changed, 5 insertions(+), 7 deletions(-)

--
2.31.1

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#6 lore raw

Hi Jani

Am 27.04.21 um 14:04 schrieb Jani Nikula:

Quoted 20 lines · Thomas Zimmermann
Quoted 11 lines

V7 of the patchset fixes some bitrot in the intel driver.

The pdev field in struct drm_device points to a PCI device structure and goes back to UMS-only days when all DRM drivers were for PCI devices. Meanwhile we also support USB, SPI and platform devices. Each of those uses the generic device stored in struct drm_device.dev.

To reduce duplication and remove the special case of PCI, this patchset converts all modesetting drivers from pdev to dev and makes pdev a field for legacy UMS drivers.

Quoted 7 lines

For PCI devices, the pointer in struct drm_device.dev can be upcasted to struct pci_device; or tested for PCI with dev_is_pci(). In several places the code can use the dev field directly.

After converting all drivers and the DRM core, the pdev fields becomes only relevant for legacy drivers. In a later patchset, we may want to convert these as well and remove pdev entirely.

Quoted 5 lines

On the series,

How should we merge these?

Thanks for the quick reply.

There is another pdev patch that I just sent out. [1] It has to go into the intel tree. After it landed, I want to get this patchset into drm-misc-next ASAP. Otherwise, drm-tip would stop building.

This should fix things in the correct order and finally remove pdev for current drivers.

Best regards
Thomas

[1] https://lore.kernel.org/dri-devel/[email protected]/T/#u

Quoted 39 lines
Quoted 38 lines

v7:
* fix instances of pdev that have benn added under i915/
v6:
* also remove assignment in i915/selftests in later patch (Chris)
v5:
* remove assignment in later patch (Chris)
v4:
* merged several patches
* moved core changes into separate patch
* vmwgfx build fix
v3:
* merged several patches
* fix one pdev reference in nouveau (Jeremy)
* rebases
v2:
* move whitespace fixes into separate patches (Alex, Sam)
* move i915 gt/ and gvt/ changes into separate patches (Joonas)

Thomas Zimmermann (4):
drm/i915/gt: Remove reference to struct drm_device.pdev drm/i915: Remove reference to struct drm_device.pdev drm/i915: Don't assign to struct drm_device.pdev
drm: Move struct drm_device.pdev to legacy section

  drivers/gpu/drm/i915/gt/intel_region_lmem.c      | 2 +-
  drivers/gpu/drm/i915/i915_drv.c                  | 1 -
  drivers/gpu/drm/i915/intel_runtime_pm.h          | 2 +-
  drivers/gpu/drm/i915/selftests/mock_gem_device.c | 1 -
  include/drm/drm_device.h                         | 6 +++---
  5 files changed, 5 insertions(+), 7 deletions(-)

--
2.31.1

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer Acked-by
#7 lore raw
Quoted 27 lines · Thomas Zimmermann

Hi Jani

Am 27.04.21 um 14:04 schrieb Jani Nikula:

Quoted 24 lines · Thomas Zimmermann
Quoted 11 lines

V7 of the patchset fixes some bitrot in the intel driver.

The pdev field in struct drm_device points to a PCI device structure and goes back to UMS-only days when all DRM drivers were for PCI devices. Meanwhile we also support USB, SPI and platform devices. Each of those uses the generic device stored in struct drm_device.dev.

To reduce duplication and remove the special case of PCI, this patchset converts all modesetting drivers from pdev to dev and makes pdev a field for legacy UMS drivers.

Quoted 7 lines

For PCI devices, the pointer in struct drm_device.dev can be upcasted to struct pci_device; or tested for PCI with dev_is_pci(). In several places the code can use the dev field directly.

After converting all drivers and the DRM core, the pdev fields becomes only relevant for legacy drivers. In a later patchset, we may want to convert these as well and remove pdev entirely.

On the series,

Quoted 7 lines
Quoted 1 line

How should we merge these?

Thanks for the quick reply.

There is another pdev patch that I just sent out. [1] It has to go into the intel tree. After it landed, I want to get this patchset into drm-misc-next ASAP. Otherwise, drm-tip would stop building.

On merging the series via drm-misc-next,

Quoted 49 lines

This should fix things in the correct order and finally remove pdev for current drivers.

Best regards
Thomas

[1]
https://lore.kernel.org/dri-devel/[email protected]/T/#u

Quoted 39 lines
Quoted 38 lines

v7:
* fix instances of pdev that have benn added under i915/
v6:
* also remove assignment in i915/selftests in later patch (Chris)
v5:
* remove assignment in later patch (Chris)
v4:
* merged several patches
* moved core changes into separate patch
* vmwgfx build fix
v3:
* merged several patches
* fix one pdev reference in nouveau (Jeremy)
* rebases
v2:
* move whitespace fixes into separate patches (Alex, Sam)
* move i915 gt/ and gvt/ changes into separate patches (Joonas)

Thomas Zimmermann (4):
drm/i915/gt: Remove reference to struct drm_device.pdev drm/i915: Remove reference to struct drm_device.pdev drm/i915: Don't assign to struct drm_device.pdev
drm: Move struct drm_device.pdev to legacy section

  drivers/gpu/drm/i915/gt/intel_region_lmem.c      | 2 +-
  drivers/gpu/drm/i915/i915_drv.c                  | 1 -
  drivers/gpu/drm/i915/intel_runtime_pm.h          | 2 +-
  drivers/gpu/drm/i915/selftests/mock_gem_device.c | 1 -
  include/drm/drm_device.h                         | 6 +++---
  5 files changed, 5 insertions(+), 7 deletions(-)

--
2.31.1

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for drm: Move struct drm_device.pdev to legacy (rev7)

In reply to Thomas Zimmermann
== Series Details ==

== Series Details ==

Series: drm: Move struct drm_device.pdev to legacy (rev7)
URL : https://patchwork.freedesktop.org/series/84205/
State : failure

== Summary ==

CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
CC [M] drivers/gpu/drm/i915/gem/i915_gem_stolen.o
drivers/gpu/drm/i915/gem/i915_gem_stolen.c: In function ‘i915_gem_stolen_lmem_setup’:
drivers/gpu/drm/i915/gem/i915_gem_stolen.c:776:35: error: ‘struct drm_device’ has no member named ‘pdev’; did you mean ‘dev’?

  struct pci_dev *pdev = i915->drm.pdev;
                                   ^~~~
                                   dev

scripts/Makefile.build:271: recipe for target 'drivers/gpu/drm/i915/gem/i915_gem_stolen.o' failed make[4]: *** [drivers/gpu/drm/i915/gem/i915_gem_stolen.o] Error 1 scripts/Makefile.build:514: recipe for target 'drivers/gpu/drm/i915' failed make[3]: *** [drivers/gpu/drm/i915] Error 2
scripts/Makefile.build:514: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:514: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1851: recipe for target 'drivers' failed
make: *** [drivers] Error 2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx