From patchwork Thu Oct 1 00:27:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Marek X-Patchwork-Id: 11811111 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BF446CA for ; Thu, 1 Oct 2020 08:16:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1EF242087E for ; Thu, 1 Oct 2020 08:16:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=marek-ca.20150623.gappssmtp.com header.i=@marek-ca.20150623.gappssmtp.com header.b="yPNOx4Gp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EF242087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=marek.ca Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 349ED6E858; Thu, 1 Oct 2020 08:15:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by gabe.freedesktop.org (Postfix) with ESMTPS id D47FC6E83C for ; Thu, 1 Oct 2020 00:28:51 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id e7so2935046qtj.11 for ; Wed, 30 Sep 2020 17:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marek-ca.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pWObr22ksvrhZ9O40b17Fzoa2hTSNXx9/SjTN9dVo8k=; b=yPNOx4GpQBiFPPh+PQdDvQWjS5Xz2iVEXS/BFhbrNYOuHP2QY3xw7QbruNjJZLDjeM ouFhttsr3QDwLIG3V/O6rmwdBXY03GT4Wxcnex65pVCB21YDO9o0MRqAJUBon8aCN1jI moZE26Gzled0QULso6fEHiKxMWdpnhxl3qhGXCiZtTtYkGTAJA30A9YxgHYAthQa5vC5 1zsT80azDrfrk4mCG3IZWhrMZhiCqhQIl9n6vJIZsKCRFJujzCQRpqZDJShg3x7vIR/o MXHtfC7Xuv7rQOahaln6rZRdToz6gmRKXTN19/rlQoyRuMoV1EBi9lZtPwsYtHPfq1C3 FGIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pWObr22ksvrhZ9O40b17Fzoa2hTSNXx9/SjTN9dVo8k=; b=gSIZHT+23mrCa4z/+Hxo1FZEQ0oJnTub3AzEeyOyig76K6iDGSuJbirGe+UAbHv4T3 ZZ3txkeQ2vOe5lTgolPxURRZCKD892VdyqLpPEd9Slig7sPsl2RIlXUXaykrhea3F9BO PEmuduJJbOmCRGisiCNwl4ZQq/seQi60nXo2H1rsSwkmud988oLMz/MqQhyyQNXG/SkX dNvw+BRoLNoVG4yG8dzG+zK6DN88FN4hV4WwRFXdq4Ui5scf+GipppBOgHZvFURy9tLZ lFgEshBj+Nv3SIupbVurHh3s+B+VFKx7DvoTMkVFS9LAaJ2Jlda/8S9mHcwS2yAfnaAF rrjA== X-Gm-Message-State: AOAM530JsO/jg+cqw4lT+QyfcYM7gTYbqoD1SOSICY9A3OtMCSD/uzpM LAx+UyV43Wc47o6JnkoS8dw7yg== X-Google-Smtp-Source: ABdhPJw1xbbmUE0uYgqAcoDIE0beNjdgLWS9VXi0OSqc4efGHwSsyirtn6p5iTR3hqYqwqkY0sdYfQ== X-Received: by 2002:ac8:7b2b:: with SMTP id l11mr4900812qtu.126.1601512130987; Wed, 30 Sep 2020 17:28:50 -0700 (PDT) Received: from localhost.localdomain ([147.253.86.153]) by smtp.gmail.com with ESMTPSA id 205sm3850908qki.118.2020.09.30.17.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 17:28:49 -0700 (PDT) From: Jonathan Marek To: freedreno@lists.freedesktop.org Subject: [PATCH 1/3] drm/msm: add MSM_BO_CACHED_COHERENT Date: Wed, 30 Sep 2020 20:27:04 -0400 Message-Id: <20201001002709.21361-2-jonathan@marek.ca> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20201001002709.21361-1-jonathan@marek.ca> References: <20201001002709.21361-1-jonathan@marek.ca> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 01 Oct 2020 08:15:43 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: AngeloGioacchino Del Regno , David Airlie , "open list:DRM DRIVER FOR MSM ADRENO GPU" , Sharat Masetty , "open list:DRM DRIVER FOR MSM ADRENO GPU" , open list , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a new cache mode for creating coherent host-cached BOs. Signed-off-by: Jonathan Marek Reviewed-by: Jordan Crouse --- drivers/gpu/drm/msm/adreno/adreno_device.c | 1 + drivers/gpu/drm/msm/msm_drv.h | 1 + drivers/gpu/drm/msm/msm_gem.c | 8 ++++++++ include/uapi/drm/msm_drm.h | 5 ++--- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index 9eeb46bf2a5d..2aa707546254 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -410,6 +410,7 @@ static int adreno_bind(struct device *dev, struct device *master, void *data) config.rev.minor, config.rev.patchid); priv->is_a2xx = config.rev.core == 2; + priv->has_cached_coherent = config.rev.core >= 6; gpu = info->init(drm); if (IS_ERR(gpu)) { diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 2c3225bc1794..6384844b1696 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -167,6 +167,7 @@ struct msm_drm_private { struct msm_file_private *lastctx; /* gpu is only set on open(), but we need this info earlier */ bool is_a2xx; + bool has_cached_coherent; struct drm_fb_helper *fbdev; diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index b2f49152b4d4..ad9a627493ae 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -431,6 +431,9 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj, if (msm_obj->flags & MSM_BO_MAP_PRIV) prot |= IOMMU_PRIV; + if (msm_obj->flags & MSM_BO_CACHED_COHERENT) + prot |= IOMMU_CACHE; + WARN_ON(!mutex_is_locked(&msm_obj->lock)); if (WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED)) @@ -998,6 +1001,7 @@ static int msm_gem_new_impl(struct drm_device *dev, uint32_t size, uint32_t flags, struct drm_gem_object **obj) { + struct msm_drm_private *priv = dev->dev_private; struct msm_gem_object *msm_obj; switch (flags & MSM_BO_CACHE_MASK) { @@ -1005,6 +1009,10 @@ static int msm_gem_new_impl(struct drm_device *dev, case MSM_BO_CACHED: case MSM_BO_WC: break; + case MSM_BO_CACHED_COHERENT: + if (priv->has_cached_coherent) + break; + /* fallthrough */ default: DRM_DEV_ERROR(dev->dev, "invalid cache flag: %x\n", (flags & MSM_BO_CACHE_MASK)); diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h index a6c1f3eb2623..474497e8743a 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h @@ -94,12 +94,11 @@ struct drm_msm_param { #define MSM_BO_CACHED 0x00010000 #define MSM_BO_WC 0x00020000 #define MSM_BO_UNCACHED 0x00040000 +#define MSM_BO_CACHED_COHERENT 0x080000 #define MSM_BO_FLAGS (MSM_BO_SCANOUT | \ MSM_BO_GPU_READONLY | \ - MSM_BO_CACHED | \ - MSM_BO_WC | \ - MSM_BO_UNCACHED) + MSM_BO_CACHE_MASK) struct drm_msm_gem_new { __u64 size; /* in */