From patchwork Tue Apr 23 12:32:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10912871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 628901390 for ; Tue, 23 Apr 2019 12:33:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5244C28689 for ; Tue, 23 Apr 2019 12:33:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 506B2286B5; Tue, 23 Apr 2019 12:33:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DC2F928796 for ; Tue, 23 Apr 2019 12:33:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C04C892EF; Tue, 23 Apr 2019 12:33:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-BY2-obe.outbound.protection.outlook.com (mail-eopbgr710052.outbound.protection.outlook.com [40.107.71.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DDF4892EF for ; Tue, 23 Apr 2019 12:33:01 +0000 (UTC) Received: from MN2PR05MB6141.namprd05.prod.outlook.com (20.178.241.217) by MN2PR05MB6704.namprd05.prod.outlook.com (20.178.249.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1835.9; Tue, 23 Apr 2019 12:32:59 +0000 Received: from MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::441b:ef64:e316:b294]) by MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::441b:ef64:e316:b294%5]) with mapi id 15.20.1835.010; Tue, 23 Apr 2019 12:32:59 +0000 From: Thomas Hellstrom To: Deepak Singh Rawat , "hch@lst.de" Subject: [PATCH] drm/vmwgfx: Fix dma API layer violation Thread-Topic: [PATCH] drm/vmwgfx: Fix dma API layer violation Thread-Index: AQHU+dCvO3ng+InGw0O++RF6DrHRnA== Date: Tue, 23 Apr 2019 12:32:59 +0000 Message-ID: <20190423123242.3028-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0347.eurprd05.prod.outlook.com (2603:10a6:7:92::42) To MN2PR05MB6141.namprd05.prod.outlook.com (2603:10b6:208:c7::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [155.4.205.35] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 81484530-35b8-4dde-4c7b-08d6c7e7d195 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:MN2PR05MB6704; x-ms-traffictypediagnostic: MN2PR05MB6704: x-microsoft-antispam-prvs: x-forefront-prvs: 0016DEFF96 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(39860400002)(376002)(136003)(366004)(199004)(189003)(6506007)(102836004)(2501003)(6436002)(5660300002)(3846002)(386003)(52116002)(6116002)(2906002)(6486002)(66446008)(53936002)(66556008)(66476007)(6512007)(86362001)(66946007)(73956011)(25786009)(66066001)(64756008)(4326008)(107886003)(8676002)(81166006)(50226002)(8936002)(81156014)(1076003)(14454004)(2616005)(486006)(97736004)(71190400001)(256004)(36756003)(26005)(476003)(186003)(71200400001)(305945005)(110136005)(54906003)(316002)(99286004)(7736002)(478600001)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR05MB6704; H:MN2PR05MB6141.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: KQksZ4C6uzYxGixyVe5Srk7e1OVC+jaGvu78aIvOq7ltiP0Xv3c+HFV+89ep2jXgDYqCnfVZ3MxHljcovd8/C+KIEbp1q3R/5CvrbB8w2bJBA/gwFt5aYCFKtZmRfUnWciAmIiTIJwbC/hwe2XP5xKakD+PmW54WABEMzByhruTnaueUkIEBH09E779wZ0EFYHleRAu97krUMdSzPIUuMA2lbCXZogP3aukRUgYE/hFdAGTw5Rs+pUNoUZcvGi7di7a9x5s1dHzIh2Ul3H04M8VK5XH6fzveCmFWUklceE2CxWcQ7PKdLUSvav2FSKGfB2VXsCIKRCcdsIO/KOFsIna13N7J5sUWOX3cMXh290y5XlmJxeJj9MYvnWgnH+B94egYDpRcCi4Qml6iQtDE96XvF764tnDxVoiv5x0Cmag= MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81484530-35b8-4dde-4c7b-08d6c7e7d195 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Apr 2019 12:32:59.0782 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR05MB6704 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SFOWcRMqYDhw6jqoVK+LfZMp/kt/wYrgJGBI7ZffPGk=; b=YYqWWbgXt1dRe98rTUW4tLQxyZBgm1iSUizVmwAsvhLDeMSJiHen5C1hKtCUqEcfqQoc0J9wYTeQ1rcqR4ymerOIYYShTl0Zc3JOFFx0j2jK/H7KjkFR7+lB5T0ugMJAtBum7zuiu5ZIAuBZVhMEv+ViAAzM/Wj2gcxxNRH9xuE= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstrom , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Remove the check for IOMMU presence since it was considered a layer violation. This means we have no reliable way to destinguish between coherent hardware IOMMU DMA address translations and incoherent SWIOTLB DMA address translations, which we can't handle. So always presume the former. This means that if anybody forces SWIOTLB without also setting the vmw_force_coherent=1 vmwgfx option, driver operation will fail, like it will on most other graphics drivers. Signed-off-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 33 +++++------------------------ 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 74e94138877e..2772530de4cb 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -545,30 +545,14 @@ static void vmw_get_initial_size(struct vmw_private *dev_priv) dev_priv->initial_height = height; } -/** - * vmw_assume_iommu - Figure out whether coherent dma-remapping might be - * taking place. - * @dev: Pointer to the struct drm_device. - * - * Return: true if iommu present, false otherwise. - */ -static bool vmw_assume_iommu(struct drm_device *dev) -{ - const struct dma_map_ops *ops = get_dma_ops(dev->dev); - - return !dma_is_direct(ops) && ops && - ops->map_page != dma_direct_map_page; -} - /** * vmw_dma_select_mode - Determine how DMA mappings should be set up for this * system. * * @dev_priv: Pointer to a struct vmw_private * - * This functions tries to determine the IOMMU setup and what actions - * need to be taken by the driver to make system pages visible to the - * device. + * This functions tries to determine what actions need to be taken by the + * driver to make system pages visible to the device. * If this function decides that DMA is not possible, it returns -EINVAL. * The driver may then try to disable features of the device that require * DMA. @@ -578,23 +562,16 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv) static const char *names[vmw_dma_map_max] = { [vmw_dma_phys] = "Using physical TTM page addresses.", [vmw_dma_alloc_coherent] = "Using coherent TTM pages.", - [vmw_dma_map_populate] = "Keeping DMA mappings.", + [vmw_dma_map_populate] = "Caching DMA mappings.", [vmw_dma_map_bind] = "Giving up DMA mappings early."}; if (vmw_force_coherent) dev_priv->map_mode = vmw_dma_alloc_coherent; - else if (vmw_assume_iommu(dev_priv->dev)) - dev_priv->map_mode = vmw_dma_map_populate; - else if (!vmw_force_iommu) - dev_priv->map_mode = vmw_dma_phys; - else if (IS_ENABLED(CONFIG_SWIOTLB) && swiotlb_nr_tbl()) - dev_priv->map_mode = vmw_dma_alloc_coherent; + else if (vmw_restrict_iommu) + dev_priv->map_mode = vmw_dma_map_bind; else dev_priv->map_mode = vmw_dma_map_populate; - if (dev_priv->map_mode == vmw_dma_map_populate && vmw_restrict_iommu) - dev_priv->map_mode = vmw_dma_map_bind; - /* No TTM coherent page pool? FIXME: Ask TTM instead! */ if (!(IS_ENABLED(CONFIG_SWIOTLB) || IS_ENABLED(CONFIG_INTEL_IOMMU)) && (dev_priv->map_mode == vmw_dma_alloc_coherent))