Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1610095pxy; Fri, 23 Apr 2021 12:13:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNbNroTzU/RIB/XBbwb11ioptQcEx9OmE2CnxDPqQOUEzf/F2p2NCT4t0kCwwGfqmoZQ37 X-Received: by 2002:a17:902:eac1:b029:ea:dfe4:7b44 with SMTP id p1-20020a170902eac1b02900eadfe47b44mr5028212pld.79.1619205204819; Fri, 23 Apr 2021 12:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619205204; cv=none; d=google.com; s=arc-20160816; b=qvSeqyAr2iGVRp35VKfjEHdNn+whYga6417nSy4pVtfJMmFccgrgfzWBj34MIFH8aN gie/UNvMxo4hbOQNAEkbnaEL3HbcWdOonPoJmEiYw+88h0LEWcgEEq8OcbXd8JRyg7xi UG1/QvELYOe01VoJpwCH2TTBY+r123/9FIovyDzhfJ4mAMV34VzGxKT8Akb2w1Z7sUDE TPS4iVESobi+Z3wZHFfa2VJczatp/8Udo5X8qnDLYoQP5GkWXuza+WZFguPYuwR5rMgz cTKPiTt3cUuj3ApnL7O0buqJ1NcmSPkUlGmHv7htb1oLtqh3iNJJFc6+kYwKNhTT+6wP 8pVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ISaGQqIyXJuhKuzVxpoTcs8C/mq7EiQzHJb8rdBgzn0=; b=0GwRttF/XioI0w8Ho7B7eNCeZJxuTxaQe5fWLD2FLnMKBoAM1sve7TLbPJPf/kiZQ3 cwuqkclR5n2Lm+/zubhE0OtLpw9Rg4vgJV6vpsjKrumrau2oIfYwUIeXQBtTZnjaOK5B KL+uQX3IsrN1kKd06IlzCBRBJwLXO+En990oFGXGKsc+qgqZ+bH1CHhjFuLFavEKBKsF sysB6CwkrSqmOtYGgThhfoekB9GuxzFAMKkowTbmY4knoZx4xU7XERfCUAz+yRhcrExj XQAtFgZHmJ1GZ/8Yp0iQG8kDcAkf/U7FYZpjUuCOdOIfBr7E8zwG7VJKpLUdyjL4Xzbs F1dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marek-ca.20150623.gappssmtp.com header.s=20150623 header.b=ovPFosPv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 102si7898535plb.217.2021.04.23.12.13.13; Fri, 23 Apr 2021 12:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@marek-ca.20150623.gappssmtp.com header.s=20150623 header.b=ovPFosPv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243843AbhDWTM6 (ORCPT + 99 others); Fri, 23 Apr 2021 15:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbhDWTM4 (ORCPT ); Fri, 23 Apr 2021 15:12:56 -0400 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388B6C06174A for ; Fri, 23 Apr 2021 12:12:19 -0700 (PDT) Received: by mail-qk1-x732.google.com with SMTP id d19so14978655qkk.12 for ; Fri, 23 Apr 2021 12:12:19 -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=ISaGQqIyXJuhKuzVxpoTcs8C/mq7EiQzHJb8rdBgzn0=; b=ovPFosPvCHBDD1TWjcy6/UJR+yBG0R3HQfY1u1P/9v2GdJxMdB7rKLzZRXgc37jqCC GX9NnlpRE+U+iZroT3oqxnUtbJ/KuqDn/g0uil7jdJaPzw1uyMIK1Yw5TZJ75f//TTre bdQ5lmxcq6GEzes5votv+/bA0c0fpa2xud0wAG0+EwZaMxFGuThIVTZ4tSGntPTJ692s qQgp/TzV5TU849eCrsllgLmBk2f2wVfdPe0TL3DYbtWbXQX4A/LSilpt0Cpl9ACALf5B FSa7YOqw61D4lv1ehSvy8nid1FG761IpeXp4SzsDnYSzFyfSdtsiZ+R0HNsytE3XaUad VrYg== 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=ISaGQqIyXJuhKuzVxpoTcs8C/mq7EiQzHJb8rdBgzn0=; b=NS0tQWxDbJWAEcG6JWNGZg8+4o7VAnXU7wlolxi6k9rFIzPq4CFY8ARwYD2yz1PgrK RF63HXhELX8o+BeCF1zKTj74I6BZJGok/7Zeek5XVryF858irxlkC4m2mq2h0g7jR8ye 6JRvD0bE2nbyohGzgOf7XIZyyL8H7xaDmh3TjWuzs+xVxRGb/I1HHwlcpUP6l0JzrzQo PK7vpno1zzyuNkyyncV4dIKHQFA/ISWtkbzjjaZgEuD/VZyyc8sDOqWy05zgORzLgM1e 4btx/YeNCROZQKMTj4LpStqWwBlQA1JCZfQqZQ6MsIzbaMMRP1J8np908AIo1nJUa+HK oUbA== X-Gm-Message-State: AOAM530R5tORSld6IPm4+636r0/noNLMSBd3DzgSrJgU/BVo2+DUNDQM 6R34TVVl94C0lXFE3+brTJn5Kg== X-Received: by 2002:a05:620a:243:: with SMTP id q3mr5781843qkn.160.1619205138472; Fri, 23 Apr 2021 12:12:18 -0700 (PDT) Received: from localhost.localdomain (modemcable068.184-131-66.mc.videotron.ca. [66.131.184.68]) by smtp.gmail.com with ESMTPSA id a22sm4834630qtp.80.2021.04.23.12.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 12:12:18 -0700 (PDT) From: Jonathan Marek To: freedreno@lists.freedesktop.org Cc: Jordan Crouse , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jordan Crouse , Bjorn Andersson , AngeloGioacchino Del Regno , Iskren Chernev , Akhil P Oommen , Shawn Guo , linux-arm-msm@vger.kernel.org (open list:DRM DRIVER FOR MSM ADRENO GPU), dri-devel@lists.freedesktop.org (open list:DRM DRIVER FOR MSM ADRENO GPU), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 4/5] drm/msm: add MSM_BO_CACHED_COHERENT Date: Fri, 23 Apr 2021 15:08:20 -0400 Message-Id: <20210423190833.25319-5-jonathan@marek.ca> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20210423190833.25319-1-jonathan@marek.ca> References: <20210423190833.25319-1-jonathan@marek.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.c | 3 ++- drivers/gpu/drm/msm/msm_drv.h | 1 + drivers/gpu/drm/msm/msm_gem.c | 8 ++++++++ include/uapi/drm/msm_drm.h | 5 ++--- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index 9770fd81c614..155c10ffda6e 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -469,6 +469,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.c b/drivers/gpu/drm/msm/msm_drv.c index a63e969e5efb..7576a987dccc 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -40,9 +40,10 @@ * - 1.5.0 - Add SUBMITQUERY_QUERY ioctl * - 1.6.0 - Syncobj support * - 1.7.0 - Add MSM_PARAM_SUSPENDS to access suspend count + * - 1.8.0 - Add MSM_BO_CACHED_COHERENT for supported GPUs (a6xx) */ #define MSM_VERSION_MAJOR 1 -#define MSM_VERSION_MINOR 7 +#define MSM_VERSION_MINOR 8 #define MSM_VERSION_PATCHLEVEL 0 static const struct drm_mode_config_funcs mode_config_funcs = { diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index ea78154c3c24..ffc9092b87b2 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -168,6 +168,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 0f58937be0a9..2e92e80009c8 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -433,6 +433,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; + GEM_WARN_ON(!msm_gem_is_locked(obj)); if (GEM_WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED)) @@ -1144,6 +1147,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) { @@ -1151,6 +1155,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 5596d7c37f9e..a92d90a6d96f 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h @@ -95,12 +95,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 */ -- 2.26.1