diff mbox series

[1/1] drm/ast: Remove existing framebuffers before loading driver

Message ID 20181217070122.14148-2-kai.heng.feng@canonical.com
State New
Headers show
Series [1/1] drm/ast: Remove existing framebuffers before loading driver | expand

Commit Message

Kai-Heng Feng Dec. 17, 2018, 7:01 a.m. UTC
From: Thomas Zimmermann <tzimmermann@suse.de>

BugLink: https://bugs.launchpad.net/bugs/1808183

If vesafb attaches to the AST device, it configures the framebuffer memory
for uncached access by default. When ast.ko later tries to attach itself to
the device, it wants to use write-combining on the framebuffer memory, but
vesefb's existing configuration for uncached access takes precedence. This
results in reduced performance.

Removing the framebuffer's configuration before loding the AST driver fixes
the problem. Other DRM drivers already contain equivalent code.

Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1112963
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: <stable@vger.kernel.org>
Tested-by: Y.C. Chen <yc_chen@aspeedtech.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 5478ad10e7850ce3d8b7056db05ddfa3c9ddad9a)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/gpu/drm/ast/ast_drv.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Kleber Sacilotto de Souza Dec. 17, 2018, 1:45 p.m. UTC | #1
On 12/17/18 8:01 AM, Kai-Heng Feng wrote:
> From: Thomas Zimmermann <tzimmermann@suse.de>
>
> BugLink: https://bugs.launchpad.net/bugs/1808183
>
> If vesafb attaches to the AST device, it configures the framebuffer memory
> for uncached access by default. When ast.ko later tries to attach itself to
> the device, it wants to use write-combining on the framebuffer memory, but
> vesefb's existing configuration for uncached access takes precedence. This
> results in reduced performance.
>
> Removing the framebuffer's configuration before loding the AST driver fixes
> the problem. Other DRM drivers already contain equivalent code.
>
> Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1112963
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: <stable@vger.kernel.org>
> Tested-by: Y.C. Chen <yc_chen@aspeedtech.com>
> Reviewed-by: Jean Delvare <jdelvare@suse.de>
> Tested-by: Jean Delvare <jdelvare@suse.de>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> (cherry picked from commit 5478ad10e7850ce3d8b7056db05ddfa3c9ddad9a)
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

Clean cherry-pick, limited to a single driver and tested by the bug
reporter. Regression potential seems low.


Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

> ---
>  drivers/gpu/drm/ast/ast_drv.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index 69dab82a3771..bf589c53b908 100644
> --- a/drivers/gpu/drm/ast/ast_drv.c
> +++ b/drivers/gpu/drm/ast/ast_drv.c
> @@ -60,8 +60,29 @@ static const struct pci_device_id pciidlist[] = {
>  
>  MODULE_DEVICE_TABLE(pci, pciidlist);
>  
> +static void ast_kick_out_firmware_fb(struct pci_dev *pdev)
> +{
> +	struct apertures_struct *ap;
> +	bool primary = false;
> +
> +	ap = alloc_apertures(1);
> +	if (!ap)
> +		return;
> +
> +	ap->ranges[0].base = pci_resource_start(pdev, 0);
> +	ap->ranges[0].size = pci_resource_len(pdev, 0);
> +
> +#ifdef CONFIG_X86
> +	primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
> +#endif
> +	drm_fb_helper_remove_conflicting_framebuffers(ap, "astdrmfb", primary);
> +	kfree(ap);
> +}
> +
>  static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  {
> +	ast_kick_out_firmware_fb(pdev);
> +
>  	return drm_get_pci_dev(pdev, ent, &driver);
>  }
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index 69dab82a3771..bf589c53b908 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -60,8 +60,29 @@  static const struct pci_device_id pciidlist[] = {
 
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
+static void ast_kick_out_firmware_fb(struct pci_dev *pdev)
+{
+	struct apertures_struct *ap;
+	bool primary = false;
+
+	ap = alloc_apertures(1);
+	if (!ap)
+		return;
+
+	ap->ranges[0].base = pci_resource_start(pdev, 0);
+	ap->ranges[0].size = pci_resource_len(pdev, 0);
+
+#ifdef CONFIG_X86
+	primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
+#endif
+	drm_fb_helper_remove_conflicting_framebuffers(ap, "astdrmfb", primary);
+	kfree(ap);
+}
+
 static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
+	ast_kick_out_firmware_fb(pdev);
+
 	return drm_get_pci_dev(pdev, ent, &driver);
 }