Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2296944pxb; Mon, 11 Jan 2021 06:19:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxs+rdYORR+xZdcK+nC95ZSYTNNUzXzJPmI+MDFv6fm8IYlKR30huNAa+yThWWcazeYwO8W X-Received: by 2002:a05:6402:a5b:: with SMTP id bt27mr14479895edb.222.1610374749575; Mon, 11 Jan 2021 06:19:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610374749; cv=none; d=google.com; s=arc-20160816; b=CQGZxioXDFQ2v+Og6nnkK4Xki+GRy8GIvE5SFlP8QmVXRiCjL2MQZCgaceONtU/7fY vjW7iOrb2L7CbXyBsJfxYvwRzxbrnyu7FRZQRK2LmtwPPJ/M43SLhH4BBzMCJmAPoIMc 5YXyeghUXaZbuFINRhgMBBkBgUwMydUFZRJUvgUhqfcKdi6rRWvLeuLZl1zueUp86td8 EJ/9D37sN3B5yj/nf709qCTkgtnNlnMTnx5VLZrl8EioiV6eOPTNF4wYFL1fcs+fkBiK TYQWE0Pfmk4bZOH/kk3y0960GUg3+eQM0PdSvxPHJSIcOoour1OG4aWrhDwE93FRvvjI yLHw== 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 :dmarc-filter:sender:dkim-signature; bh=+zvATLB17FSikJ474bJLjVIT/0w+t+4NoZVNMOXfLUE=; b=QjNtxvpt7dEY0YTd5SC7FqjE2BkyiKAw/H9aQ3gqTnJaXchOqsCVCHX3hS7RQTYks3 R3J98trrRn9gh/aaezzxM0GZOnEzPXwirJrVKXTiupZvRlzFdHof6xyR7cxUdmmfzSTG M9GuHYLWi/QlzQiAD0WRRvRZheJg5jhsZ5Kr56vbJEnYuk4qoB5L5UYmsH88J5KVZaNQ mbtysjLokNWtEWXs5i/HSL518/6fI/6COr64TDh0nOdSn6FnwJayEMfJIuRjXmdg8Y9P KA9V3PmSTWVufPV1Zrdxfbi4EGA8XDyKjLL/uMyDutf04PHuPnPVdPS/dEEL4B5ySvHt vPeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="f2I/TeNX"; 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 w5si6502596ejc.599.2021.01.11.06.18.45; Mon, 11 Jan 2021 06:19:09 -0800 (PST) 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=@mg.codeaurora.org header.s=smtp header.b="f2I/TeNX"; 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 S1730339AbhAKOQj (ORCPT + 99 others); Mon, 11 Jan 2021 09:16:39 -0500 Received: from so254-31.mailgun.net ([198.61.254.31]:26774 "EHLO so254-31.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728558AbhAKOQh (ORCPT ); Mon, 11 Jan 2021 09:16:37 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1610374573; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=+zvATLB17FSikJ474bJLjVIT/0w+t+4NoZVNMOXfLUE=; b=f2I/TeNXsCSGIRXonsEiGGBn9EYeIsi/u1uXR6ldEYBIGFIZ3BEQyYKFq5U42SBnvQ7jLEKc cpQa/jJCbte/PPP2bdXyHZut2OwecVm9PUh9T71iIpU8Ib+NlZPA5UGUH6AOF3jw3u0A1fGJ Gr57rqpp9xF3enaWbJe9oeCQtXc= X-Mailgun-Sending-Ip: 198.61.254.31 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-west-2.postgun.com with SMTP id 5ffc5d90415a6293c509702d (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 11 Jan 2021 14:15:44 GMT Sender: saiprakash.ranjan=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 0755EC43464; Mon, 11 Jan 2021 14:15:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from blr-ubuntu-253.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan) by smtp.codeaurora.org (Postfix) with ESMTPSA id CF8F9C433C6; Mon, 11 Jan 2021 14:15:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org CF8F9C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Will Deacon , Robin Murphy , Joerg Roedel , Jordan Crouse , Rob Clark , Akhil P Oommen , isaacm@codeaurora.org Cc: iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno , Kristian H Kristensen , Sean Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, Sai Prakash Ranjan Subject: [PATCH 3/3] drm/msm: Use IOMMU_LLC page protection flag to map gpu buffers Date: Mon, 11 Jan 2021 19:45:05 +0530 Message-Id: <6f8ec1a563cb6e408c5c1cae82b9417860d49549.1610372717.git.saiprakash.ranjan@codeaurora.org> X-Mailer: git-send-email 2.29.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the newly introduced IOMMU_LLC page protection flag to map GPU buffers. This will make sure that proper stage-1 PTE attributes are set for GPU buffers to use system cache. This also introduces MMU_FEATURE_USE_LLC features bit to check for GPUs supporting LLC and set them in the target specific address space creation, in this case we set them for A6XX GPUs. Signed-off-by: Sai Prakash Ranjan --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 3 +++ drivers/gpu/drm/msm/msm_iommu.c | 3 +++ drivers/gpu/drm/msm/msm_mmu.h | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 3c7ad51732bb..23da21b6f0ff 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -1266,6 +1266,9 @@ a6xx_create_address_space(struct msm_gpu *gpu, struct platform_device *pdev) return ERR_CAST(mmu); } + if (!IS_ERR_OR_NULL(a6xx_gpu->llc_slice)) + mmu->features |= MMU_FEATURE_USE_LLC; + /* * Use the aperture start or SZ_16M, whichever is greater. This will * ensure that we align with the allocated pagetable range while still diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c index 22ac7c692a81..a329f9836422 100644 --- a/drivers/gpu/drm/msm/msm_iommu.c +++ b/drivers/gpu/drm/msm/msm_iommu.c @@ -235,6 +235,9 @@ static int msm_iommu_map(struct msm_mmu *mmu, uint64_t iova, if (iova & BIT_ULL(48)) iova |= GENMASK_ULL(63, 49); + if (mmu->features & MMU_FEATURE_USE_LLC) + prot |= IOMMU_LLC; + ret = iommu_map_sgtable(iommu->domain, iova, sgt, prot); WARN_ON(!ret); diff --git a/drivers/gpu/drm/msm/msm_mmu.h b/drivers/gpu/drm/msm/msm_mmu.h index 61ade89d9e48..efcd1939c98e 100644 --- a/drivers/gpu/drm/msm/msm_mmu.h +++ b/drivers/gpu/drm/msm/msm_mmu.h @@ -23,12 +23,16 @@ enum msm_mmu_type { MSM_MMU_IOMMU_PAGETABLE, }; +/* MMU features */ +#define MMU_FEATURE_USE_LLC BIT(0) + struct msm_mmu { const struct msm_mmu_funcs *funcs; struct device *dev; int (*handler)(void *arg, unsigned long iova, int flags); void *arg; enum msm_mmu_type type; + u32 features; }; static inline void msm_mmu_init(struct msm_mmu *mmu, struct device *dev, -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation