Skip to contentSkip to conversation

drm/radeon: Add early unregister of firmware fb's

PATCH In review Daniel Vetter 3 participants 5 messages Oct 6, 2010 – Oct 31, 2010

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

PATCH 1/1 drm/radeon: Add early unregister of firmware fb's

From: Benjamin Herrenschmidt <[email protected]>

Without this, we attempt the handover too late, the firmware fb might be accessing the chip simultaneously to us re-initializing various parts of it, which might frighten babies or cause all sort of nasty psychologic trauma to kitten.

[danvet: add cc: stable, forward ported and compile-fixed for X86]

---

This patch is required to get the agp rv270 in my ppc Mac Mini working with kms. Also tested on my agp rv570 on amd64, doesn't seem to have ill effects there.

Please review and apply.

Thanks, Daniel

 drivers/gpu/drm/radeon/radeon_device.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +19 -0
index 256d204..3aea1a8 100644
@@ -584,6 +584,22 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
 }
 
 
+static void radeon_kick_out_firmware_fb(struct drm_device *ddev)
+{
+	struct apertures_struct *ap;
+	bool primary = false;
+
+	ap = alloc_apertures(1);
+	ap->ranges[0].base = pci_resource_start(ddev->pdev, 0);
+	ap->ranges[0].size = pci_resource_len(ddev->pdev, 0);
+
+#ifdef CONFIG_X86
+	primary = ddev->pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
+#endif
+	remove_conflicting_framebuffers(ap, "radeondrmfb", primary);
+	kfree(ap);
+}
+
 int radeon_device_init(struct radeon_device *rdev,
 		       struct drm_device *ddev,
 		       struct pci_dev *pdev,
@@ -623,6 +639,9 @@ int radeon_device_init(struct radeon_device *rdev,
 	init_waitqueue_head(&rdev->irq.vblank_queue);
 	init_waitqueue_head(&rdev->irq.idle_queue);
 
+	/* Get rid of things like offb */
+	radeon_kick_out_firmware_fb(ddev);
+
 	/* setup workqueue */
 	rdev->wq = create_workqueue("radeon");
 	if (rdev->wq == NULL)
Signature · 1 line
1.7.1
#1 lore raw
Quoted 30 lines · Daniel Vetter

From: Benjamin Herrenschmidt <[email protected]>

Without this, we attempt the handover too late, the firmware fb might be accessing the chip simultaneously to us re-initializing various parts of it, which might frighten babies or cause all sort of nasty psychologic trauma to kitten.

[danvet: add cc: stable, forward ported and compile-fixed for X86]

---

This patch is required to get the agp rv270 in my ppc Mac Mini working with kms. Also tested on my agp rv570 on amd64, doesn't seem to have ill effects there.

Please review and apply.

Thanks, Daniel

 drivers/gpu/drm/radeon/radeon_device.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +0 -0
index 256d204..3aea1a8 100644
@@ -584,6 +584,22 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
 }

drivers/gpu/drm/radeon/radeon_device.c static bool radeon_switcheroo_can_switch(struct pci_dev *pdev) · line 594

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_device.c +8 -0
 
 
+static void radeon_kick_out_firmware_fb(struct drm_device *ddev)
+{
+	struct apertures_struct *ap;
+	bool primary = false;
+
+	ap = alloc_apertures(1);
+	ap->ranges[0].base = pci_resource_start(ddev->pdev, 0);
+	ap->ranges[0].size = pci_resource_len(ddev->pdev, 0);

Any reason why this range differs from the one in radeonfb_create? Maybe it needs to be fixed there too?

Quoted 28 lines
drivers/gpu/drm/radeon/radeon_device.c +11 -0
+
+#ifdef CONFIG_X86
+	primary = ddev->pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
+#endif
+	remove_conflicting_framebuffers(ap, "radeondrmfb", primary);
+	kfree(ap);
+}
+
 int radeon_device_init(struct radeon_device *rdev,
 		       struct drm_device *ddev,
 		       struct pci_dev *pdev,
@@ -623,6 +639,9 @@ int radeon_device_init(struct radeon_device *rdev,
 	init_waitqueue_head(&rdev->irq.vblank_queue);
 	init_waitqueue_head(&rdev->irq.idle_queue);
 
+	/* Get rid of things like offb */
+	radeon_kick_out_firmware_fb(ddev);
+
 	/* setup workqueue */
 	rdev->wq = create_workqueue("radeon");
 	if (rdev->wq == NULL)
Signature · 6 lines
1.7.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 12 lines · Marcin Slusarz

drivers/gpu/drm/radeon/radeon_device.c static bool radeon_switcheroo_can_switch(struct pci_dev *pdev) · line 594

Quoted 8 lines · Daniel Vetter
drivers/gpu/drm/radeon/radeon_device.c +8 -0
+static void radeon_kick_out_firmware_fb(struct drm_device *ddev)
+{
+	struct apertures_struct *ap;
+	bool primary = false;
+
+	ap = alloc_apertures(1);
+	ap->ranges[0].base = pci_resource_start(ddev->pdev, 0);
+	ap->ranges[0].size = pci_resource_len(ddev->pdev, 0);

Any reason why this range differs from the one in radeonfb_create? Maybe it needs to be fixed there too?

I've stumbled over that, too. It won't really matter at all because the fb subsystem does an intersection check. The values in radeonfb_create look more like the correct ones, but I can't get at them before the card is initialized.

-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#3 lore raw
Quoted 14 lines · Daniel Vetter
Quoted 12 lines · Marcin Slusarz

drivers/gpu/drm/radeon/radeon_device.c static bool radeon_switcheroo_can_switch(struct pci_dev *pdev) · line 594

Quoted 8 lines · Daniel Vetter
drivers/gpu/drm/radeon/radeon_device.c +8 -0
+static void radeon_kick_out_firmware_fb(struct drm_device *ddev)
+{
+	struct apertures_struct *ap;
+	bool primary = false;
+
+	ap = alloc_apertures(1);
+	ap->ranges[0].base = pci_resource_start(ddev->pdev, 0);
+	ap->ranges[0].size = pci_resource_len(ddev->pdev, 0);

Any reason why this range differs from the one in radeonfb_create? Maybe it needs to be fixed there too?

Quoted 4 lines

I've stumbled over that, too. It won't really matter at all because the fb subsystem does an intersection check. The values in radeonfb_create look more like the correct ones, but I can't get at them before the card is initialized.

I think regions passed to fb layer should be "memory I want exclusive access to", not "memory where I want to have the framebuffer", because the first one is stronger - you don't want other framebuffer to mess with your non-fb memory...

Marcin

#4 lore raw
In reply to Daniel Vetter

Hi Dave,

This hasn't shown up in one of your branches, yet. Do you want me to change something or was this patch simply lost somewhere?

Thanks, Daniel

Quoted 64 lines · Daniel Vetter

From: Benjamin Herrenschmidt <[email protected]>

Without this, we attempt the handover too late, the firmware fb might be accessing the chip simultaneously to us re-initializing various parts of it, which might frighten babies or cause all sort of nasty psychologic trauma to kitten.

[danvet: add cc: stable, forward ported and compile-fixed for X86]

---

This patch is required to get the agp rv270 in my ppc Mac Mini working with kms. Also tested on my agp rv570 on amd64, doesn't seem to have ill effects there.

Please review and apply.

Thanks, Daniel

 drivers/gpu/drm/radeon/radeon_device.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_device.c +19 -0
index 256d204..3aea1a8 100644
@@ -584,6 +584,22 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
 }
 
 
+static void radeon_kick_out_firmware_fb(struct drm_device *ddev)
+{
+	struct apertures_struct *ap;
+	bool primary = false;
+
+	ap = alloc_apertures(1);
+	ap->ranges[0].base = pci_resource_start(ddev->pdev, 0);
+	ap->ranges[0].size = pci_resource_len(ddev->pdev, 0);
+
+#ifdef CONFIG_X86
+	primary = ddev->pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
+#endif
+	remove_conflicting_framebuffers(ap, "radeondrmfb", primary);
+	kfree(ap);
+}
+
 int radeon_device_init(struct radeon_device *rdev,
 		       struct drm_device *ddev,
 		       struct pci_dev *pdev,
@@ -623,6 +639,9 @@ int radeon_device_init(struct radeon_device *rdev,
 	init_waitqueue_head(&rdev->irq.vblank_queue);
 	init_waitqueue_head(&rdev->irq.idle_queue);
 
+	/* Get rid of things like offb */
+	radeon_kick_out_firmware_fb(ddev);
+
 	/* setup workqueue */
 	rdev->wq = create_workqueue("radeon");
 	if (rdev->wq == NULL)
Signature · 1 line
1.7.1
Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48