Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2032722lqo; Sun, 19 May 2024 09:55:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOoIA6Nbzo8GG8uNGC8fDDAgAdGwjZYZQJgbcDRcDxdBrth8FrWSigf88rMFsifxQycYDaA/S6lKL4lm+ICle/riYEwwO0zn/JKVMy/g== X-Google-Smtp-Source: AGHT+IHvu7wIzNIRep8qBXnLERZeqSeMdFFH5dWUAIYzSTLejhvCiOcLVmyOPdeU1AGkFbw8T61I X-Received: by 2002:a50:aa94:0:b0:572:a731:dd14 with SMTP id 4fb4d7f45d1cf-5734d6edacemr19755575a12.28.1716137728582; Sun, 19 May 2024 09:55:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716137728; cv=pass; d=google.com; s=arc-20160816; b=IGsuJ0qT4Q0p7nIADzAFfyPei73VKjzYdbZwLKUgLSy2na2NG4HvBMDs9WpBUTw/JX 99jIWRueLR9mETLZgSznndADoh/Ou2v2dmWvD8wBdgAZlBHivS74kBdQfM7yVosCm1vO XDeswRQSHEEN2sJe4TNRlobKQYCItjZgZ0iGREjnPM+4wpshXi2BWiL6GJUZz+LR+cnA NyesYq71Fq1ohXuGcDJX3py8hdVmGIuAgZPFOPo5qQPEiJ9iIJ3ndWYSmHAcdWvbduZa 9ye05CKUNLabZKRj5V+qTHoBFr+onaF/8rWNna7k5QErW54zkAanTcYc8OzFnFn4bjlj Fxsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=pwKICKst0L9yhry2NDoovnT+HCNlgrmcR3qE1GjmJec=; fh=Mx+BJ0Zegwoq+pIWLfBBdNviDVJx9ufihb/fzE11nms=; b=td+9IWiaQGsJvnS9A/r9J9OlT4TyTGD/IWC089GDwluWvelixYGhsozwwtRuoZ4UCz sxF2mwb/furBnj/Qmw4gKDGmpm/kvV91Ljjqvb68WWdiGujsUXOPV+LpruvC4hlLGYKd PL+kHPbGKzfDHFJCIDBRD21vrSwVoPgGlCbAjOhErqZbfY9a5c+QT+3UjhgVyLP2GL+m rrvRRX3lLN76paHYm6vzCLixzc9fotTGnkNdYqhbNIOTjOom6PHOBM1wut16Tls+24p4 lKgxiARU87hoY5V7N+7nDLHv3FqGWEd4d5b+kEwvt8jluVrenWjhusQkJpStj4uVEpxR hNwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bBlT1H7D; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-183157-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-575ab5dd695si1702797a12.499.2024.05.19.09.55.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 09:55:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183157-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bBlT1H7D; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-183157-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 538C61F21BF8 for ; Sun, 19 May 2024 16:55:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB6594D5AA; Sun, 19 May 2024 16:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="bBlT1H7D" Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64EB6495E5 for ; Sun, 19 May 2024 16:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716137714; cv=none; b=t0qXgpm3rVtO/YY+y0OXON7820IdH1braHWvcM2/yFOGat0pbKH+Jpn3nO3FqVG5dA/xDRUmHlZk6JqqeeJLAyUIeG0o4UUu2PDFHeieRkyvdJM+DPjNxg6cJHn98M0g7qg2POK0RJHcs3B1FqLv3jlVsmnmFTDY2PGkc2SWfPw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716137714; c=relaxed/simple; bh=HLEE5CycAUBUUmCccedhfrJ12xykardYssIwYKvg69Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G/YP/ib8WUv3SDTv0lQIL7LsCEdkRLLgyrpyx6ywqObimDt1jVgafFNE6FI7ZKIW5YgYXTvdBOnOk5pBjMWUfEFLZ3apwkBIhcp9b0YKyG7JC7mtS8piQ6LYHsFaoj9934ZftCHaQMPg1RoAI+7FGhMg+mf6vHFgPt8DGws7350= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=bBlT1H7D; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: l.stach@pengutronix.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716137710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pwKICKst0L9yhry2NDoovnT+HCNlgrmcR3qE1GjmJec=; b=bBlT1H7DxARNi8JC9kBvYsbaGoD0hxSggt0J/XuuMtKkhgwS8p7//uKxzrGvH8wGWkeKGm e1iyhK+QtBKAFoftw8vneZwgTuHBhhMNXMCe7HXugnF78CplZLZB0hYyEUpZP+8fbVIgP0 GMgT57Wf5lN9/+RCOkQBCZN8fKtJ1Do= X-Envelope-To: linux+etnaviv@armlinux.org.uk X-Envelope-To: christian.gmeiner@gmail.com X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: etnaviv@lists.freedesktop.org X-Envelope-To: dri-devel@lists.freedesktop.org X-Envelope-To: sui.jingfeng@linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sui Jingfeng To: Lucas Stach Cc: Russell King , Christian Gmeiner , linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Sui Jingfeng Subject: [etnaviv-next v14 4/8] drm/etnaviv: Fix wrong cache property being used for vmap() Date: Mon, 20 May 2024 00:53:17 +0800 Message-Id: <20240519165321.2123356-5-sui.jingfeng@linux.dev> In-Reply-To: <20240519165321.2123356-1-sui.jingfeng@linux.dev> References: <20240519165321.2123356-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT In the etnaviv_gem_vmap_impl() function, the driver vmap whatever buffers with Write-Combine page property. This is unreasonable, as some platforms are cached coherent. And cached buffers should be mapped with cached page property. Fixes: a0a5ab3e99b8 ("drm/etnaviv: call correct function when trying to vmap a DMABUF") Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index aa95a5e98374..eed98bb9e446 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -342,6 +342,7 @@ void *etnaviv_gem_vmap(struct drm_gem_object *obj) static void *etnaviv_gem_vmap_impl(struct etnaviv_gem_object *obj) { struct page **pages; + pgprot_t prot; lockdep_assert_held(&obj->lock); @@ -349,8 +350,19 @@ static void *etnaviv_gem_vmap_impl(struct etnaviv_gem_object *obj) if (IS_ERR(pages)) return NULL; - return vmap(pages, obj->base.size >> PAGE_SHIFT, - VM_MAP, pgprot_writecombine(PAGE_KERNEL)); + switch (obj->flags) { + case ETNA_BO_CACHED: + prot = PAGE_KERNEL; + break; + case ETNA_BO_UNCACHED: + prot = pgprot_noncached(PAGE_KERNEL); + break; + case ETNA_BO_WC: + default: + prot = pgprot_writecombine(PAGE_KERNEL); + } + + return vmap(pages, obj->base.size >> PAGE_SHIFT, VM_MAP, prot); } static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op) -- 2.34.1