Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1496048imu; Sat, 5 Jan 2019 00:03:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN6EP/Sa/dtYDV04sDCn7ImfCNHzaKofMWj0wgqKr2+Vm3ouj7Z09vTmsgIxyLnv7NRCl8VO X-Received: by 2002:a17:902:b494:: with SMTP id y20mr54905566plr.178.1546675428625; Sat, 05 Jan 2019 00:03:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546675428; cv=none; d=google.com; s=arc-20160816; b=C/k32+OM1e3PvvYCjUUTnrxcuW9r1pzyRFG4btBCgHGDFpgGaOux8sPx0WxFtulGpk 2aca+o1RIk+R0gBPOv7LC9CEYx85sWn0d/+ecpFPUi3GjQczye6OPTw5twF258kT9Eh/ UNztZfuzbPvTJgNt9pxj5rb2+bjtt5vh0icSBXCDqcJ7MgDo1KiHrXysv5q5S7BSx/0Y rK2x0SSxU/ljuKuuYW6eObNvnk9xzdo0QLqwwqFHuhplMuC8hydNaf2uaCpQ/nZcOnIi e5GIWU2QX7gcIpd2yTFQmYFCdFQbHlvsc0Ou89uLjbSpCoIRbqpvbGuotmjBhJYT6wgB 2OOA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oz/kstUMDjo2/7DezyE12VsuvnT5Qn/XHw8dHT4vIsY=; b=C9fD0/Z5FBbUsB438ZEqz1gWxLfb9554vZolCYDRj6n2YnA6mEkrmUBRdHQCASW5FF PrnoWsGt8e3Fqa0MpWQ13/NS2i2Biu8RYdHgzIeRFI84uShOM4A3PdNDZsTUCcAFIBNx ENMnrVgMshIzeSki4ap3R0Z7SGEj9Om0tQg6fARiB8EBERyIhEt3ebFtdiyhRuk6EYVE 6q7lgLjHBkUgf5sjKsRqhQn0qCNhliYpa1yC4knJvUpA6VJmLqPbkd4sgosAsEHHrMP+ sVl0RMSndghA7qtlh2ncNS7PEGd/89cAKFuKeeDtN2XY0NpDNdtwt//IqDrPUetcUeBD HqpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gsrPuVE7; 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 g92si10511032plg.392.2019.01.05.00.03.18; Sat, 05 Jan 2019 00:03:48 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gsrPuVE7; 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 S1726332AbfAEIB1 (ORCPT + 99 others); Sat, 5 Jan 2019 03:01:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48862 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbfAEIBZ (ORCPT ); Sat, 5 Jan 2019 03:01:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oz/kstUMDjo2/7DezyE12VsuvnT5Qn/XHw8dHT4vIsY=; b=gsrPuVE7vngxfS0LtHc3LXLwmr sKJdoXUBVSqjqpqxWYKuWXxydwOCeIdTgFJA2CJ3NAu8T6zYH3zep6fH5gxkp9Ol5tuIfDKph2l54 x1plOfl4IpxVpepqduxJsWM/k+4iiNwuMKfj8G3GZNhsKap8h4I9D2j7NBkKh5t4NLcpIQ1/nB8nM v/kMJQgMMl+qOqf3hR7sPK5AJbMYhhVqj4Y7I0GGkPAjRdIV2rGe3QAju3ku1Dq+NNOzO3Qqf8HO6 VD/SHTJ/FnfoIRRgHwKdg/2QJkBWm3wPvI0TLsap3YZaNJxd/3sQfWDQNbD/Q0tXTR7E7LTM++1MD DuZjNFLQ==; Received: from 089144213048.atnat0022.highway.a1.net ([89.144.213.48] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gfgtX-0000Jc-KT; Sat, 05 Jan 2019 08:01:24 +0000 From: Christoph Hellwig To: thellstrom@vmware.com Cc: linux-graphics-maintainer@vmware.com, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] drm/vmwgfx: unwind spaghetti code in vmw_dma_select_mode Date: Sat, 5 Jan 2019 09:01:08 +0100 Message-Id: <20190105080108.14837-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190105080108.14837-1-hch@lst.de> References: <20190105080108.14837-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just use a simple if/else chain to select the DMA mode. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index c2060f6cc9e8..86387735a90b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -566,34 +566,21 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv) [vmw_dma_map_populate] = "Keeping DMA mappings.", [vmw_dma_map_bind] = "Giving up DMA mappings early."}; - if (intel_iommu_enabled) { + if (vmw_force_coherent) + dev_priv->map_mode = vmw_dma_alloc_coherent; + else if (intel_iommu_enabled) dev_priv->map_mode = vmw_dma_map_populate; - goto out_fixup; - } - - if (!(vmw_force_iommu || vmw_force_coherent)) { + else if (!vmw_force_iommu) dev_priv->map_mode = vmw_dma_phys; - DRM_INFO("DMA map mode: %s\n", names[dev_priv->map_mode]); - return 0; - } - -#ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) + else if (IS_ENABLED(CONFIG_SWIOTLB) && swiotlb_nr_tbl()) dev_priv->map_mode = vmw_dma_alloc_coherent; else -#endif dev_priv->map_mode = vmw_dma_map_populate; -out_fixup: - if (dev_priv->map_mode == vmw_dma_map_populate && - vmw_restrict_iommu) + if (dev_priv->map_mode == vmw_dma_map_populate && vmw_restrict_iommu) dev_priv->map_mode = vmw_dma_map_bind; - if (vmw_force_coherent) - dev_priv->map_mode = vmw_dma_alloc_coherent; - DRM_INFO("DMA map mode: %s\n", names[dev_priv->map_mode]); - return 0; } -- 2.20.1