Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2283212ybl; Thu, 19 Dec 2019 10:59:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwH0IIp+ccxPoaLAoMfV1e3dWTvpaTuVaQyvO87shi11LrFmyUE3eZrLi+0UMBipjHX+pX9 X-Received: by 2002:a9d:2c68:: with SMTP id f95mr10490392otb.33.1576781978737; Thu, 19 Dec 2019 10:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781978; cv=none; d=google.com; s=arc-20160816; b=qsqtBNIl6hCMc60+L8bSP+QWDE/JD9sIQl1A4guVvXbvun82dj7SMvZ3BdVhzC+NRT wV99RxYs2LjspfYk7yWj+F3824Xzc9nlj9P+W01YFDTnkTYtSxIN5/8l6GhbvyxLTRj3 0TYXadN2cQgODUtumhgTqZ/nMFgQd9ky/DG/e8GH3hR+TPsmvxRMr7ckXSdelDS0bRaf wYzUengmNURoejnombQo9luxPoa4fDe4Q1RtsKOghGA01hQUx5jGjz62ml8NbsIiqgyc euaTX3FCPxbPuWptWN1leR2kNSQ+LNO/LQN7eDdJu2nkk7Nn3DSy2m6b4hf5+htGuB/Q 6jeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LwxSrk4psaBnD0EqbsLIyhBNdWj75e00GMSEYwqbDfQ=; b=mc54hAc3DuuDDB3TxOKC2stufClHcOutqKtXFvsaEdAFP8PvZtFpRzk8O2O0FxDlNS KyWYUCI4+H8pH6pVi4nVSgivfOBq7ZMW9ZmYgSdO8ZnkTLPwN34O5ioZthnbbMWtK7Qw qJTNQFm1u1gvY4G2hjgSa1wklTqFryfiddWmxRh6Sh6ucYB9S/qvPf3HXJLU82Zl+j62 tz1edhtpvmKj1YPRWeCBj4vRNn7vy8kxt7ZqQS4jbVaxhC6yxvSQUS4hEOmrkRQ0xtxQ ASUlDynRGsqsA2qikRPd5nSXWwF0SKL9acLfrrCZDkKcX48KmC2B2Rygj7wwjQMMyf/4 vR+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wb1RnXll; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t28si3710331otr.16.2019.12.19.10.59.26; Thu, 19 Dec 2019 10:59:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wb1RnXll; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730630AbfLSSzJ (ORCPT + 99 others); Thu, 19 Dec 2019 13:55:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:50882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730622AbfLSSzH (ORCPT ); Thu, 19 Dec 2019 13:55:07 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4EC6024686; Thu, 19 Dec 2019 18:55:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781706; bh=8lf+bvqxmeTkyo+Jri7kTp9DHiOIK0LeB435rMQ/SCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wb1RnXllbyM5VgeCu+ctzG02hLIzQdXxPg/TFVB/Qqsnj+Ei+XTP2CwPydHp/CX6h OfmoYbqKK+26EofVWBqeVjH4aVUFALCvBZZbhmwqvqzbwUd/08ErziIEM0UaD0y86y 5Ou7LVIP2TyHwAr7j+35EWrE1rczQKn75EXU/c+4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Zimmermann , John Donnelly , Daniel Vetter , Gerd Hoffmann , Dave Airlie , Maarten Lankhorst , Maxime Ripard , David Airlie , Sam Ravnborg , "Y.C. Chen" , Neil Armstrong , Thomas Gleixner , =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= , Andrzej Pietrasiewicz , dri-devel@lists.freedesktop.org Subject: [PATCH 5.4 48/80] drm/mgag200: Add workaround for HW that does not support startadd Date: Thu, 19 Dec 2019 19:34:40 +0100 Message-Id: <20191219183116.739455056@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183031.278083125@linuxfoundation.org> References: <20191219183031.278083125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Zimmermann commit 1591fadf857cdbaf2baa55e421af99a61354713c upstream. There's at least one system that does not interpret the value of the device's 'startadd' field correctly, which leads to incorrectly displayed scanout buffers. Always placing the active scanout buffer at offset 0 works around the problem. Signed-off-by: Thomas Zimmermann Reported-by: John Donnelly Tested-by: John Donnelly Reviewed-by: Daniel Vetter Fixes: 81da87f63a1e ("drm: Replace drm_gem_vram_push_to_system() with kunmap + unpin") Cc: Gerd Hoffmann Cc: Dave Airlie Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: David Airlie Cc: Sam Ravnborg Cc: "Y.C. Chen" Cc: Neil Armstrong Cc: Thomas Gleixner Cc: "José Roberto de Souza" Cc: Andrzej Pietrasiewicz Cc: dri-devel@lists.freedesktop.org Cc: # v5.3+ Link: https://gitlab.freedesktop.org/drm/misc/issues/7 Link: https://patchwork.freedesktop.org/patch/msgid/20191126101529.20356-4-tzimmermann@suse.de [drop debugfs_init callback - gregkh] Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/mgag200/mgag200_drv.c | 35 +++++++++++++++++++++++++++++++++- drivers/gpu/drm/mgag200/mgag200_drv.h | 3 ++ 2 files changed, 37 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -30,6 +30,8 @@ module_param_named(modeset, mgag200_mode static struct drm_driver driver; static const struct pci_device_id pciidlist[] = { + { PCI_VENDOR_ID_MATROX, 0x522, PCI_VENDOR_ID_SUN, 0x4852, 0, 0, + G200_SE_A | MGAG200_FLAG_HW_BUG_NO_STARTADD}, { PCI_VENDOR_ID_MATROX, 0x522, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_A }, { PCI_VENDOR_ID_MATROX, 0x524, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_B }, { PCI_VENDOR_ID_MATROX, 0x530, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EV }, @@ -63,6 +65,35 @@ static const struct file_operations mgag DRM_VRAM_MM_FILE_OPERATIONS }; +static bool mgag200_pin_bo_at_0(const struct mga_device *mdev) +{ + return mdev->flags & MGAG200_FLAG_HW_BUG_NO_STARTADD; +} + +int mgag200_driver_dumb_create(struct drm_file *file, + struct drm_device *dev, + struct drm_mode_create_dumb *args) +{ + struct mga_device *mdev = dev->dev_private; + unsigned long pg_align; + + if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized")) + return -EINVAL; + + pg_align = 0ul; + + /* + * Aligning scanout buffers to the size of the video ram forces + * placement at offset 0. Works around a bug where HW does not + * respect 'startadd' field. + */ + if (mgag200_pin_bo_at_0(mdev)) + pg_align = PFN_UP(mdev->mc.vram_size); + + return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev, + pg_align, false, args); +} + static struct drm_driver driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET, .load = mgag200_driver_load, @@ -74,7 +105,9 @@ static struct drm_driver driver = { .major = DRIVER_MAJOR, .minor = DRIVER_MINOR, .patchlevel = DRIVER_PATCHLEVEL, - DRM_GEM_VRAM_DRIVER + .dumb_create = mgag200_driver_dumb_create, + .dumb_map_offset = drm_gem_vram_driver_dumb_mmap_offset, + .gem_prime_mmap = drm_gem_prime_mmap, }; static struct pci_driver mgag200_pci_driver = { --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -159,6 +159,9 @@ enum mga_type { G200_EW3, }; +/* HW does not handle 'startadd' field correct. */ +#define MGAG200_FLAG_HW_BUG_NO_STARTADD (1ul << 8) + #define MGAG200_TYPE_MASK (0x000000ff) #define MGAG200_FLAG_MASK (0x00ffff00)