From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 181802773DC for ; Tue, 30 Sep 2025 05:51:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759211470; cv=none; b=peCJ1911ueC6KbWIHdER15RSSw4AfZeMXddVG0wdgkYQpQDCX7Qc2TkQTPwU7BoElcz6fgyebbCPiJncl6I1TNoHLJ8KeDYXKjP0E1BCW3cq3YlcOpoK/F3CMyC+L21ya2r1kS54JIT/+P38Jnt8v7flzjaJrjHILbWq3b4vdCc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759211470; c=relaxed/simple; bh=GTpB2Z9lQwSz5qPaDRTgiMFZ74hnKCFSh/p08mqgbCw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dZVzE9mYuZaw3rDsyonptcog7fcu6433Io0Tm+ChWlbup/foJuA+0c+7oGZN9m6oZTd8PvGIAjAfUO8R2L+LgzRDW43Valrn9Iu4bNGGC9rrFrzSB8hkjKY/DTQ7LKdqRLnfOCOpoJ1h3NvuICiHKcNHCjEAz+4ePSvUlXyA2gc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=f1n9jVMx; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="f1n9jVMx" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58U4I0HL013362 for ; Tue, 30 Sep 2025 05:51:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= LEEZ0d7bP/9F2m15CHQF+Po5PDRcDjrLTRtWvJlPJw4=; b=f1n9jVMxr7y94CDU +HXmqW7dXEl7WnlvlNQkJAO2YA/qhjttfwKQahgYxiBOF+MKKKrRGD54E3bJKwYz 1G8hQGi0IqCQ8Wve43f7HQWvcu1Fd+2stPrx/cE8ngP/iZut3y0Vn3cuH28MJbg2 gvmvN1NZQdKwCtMsVJMaZuztOqg0wmiaIXT5zyjG/JIMqluhSdc4rpNos2HaMuPQ ghD6v+ius1Nway++jJ4Su0WqpSXJ2MbEZ4YYIxxvHVKOVnuf1fyJHYQwchsE8z/Y xCJMgvNasX+7wYt9IwHHEtr9w3L5Z+OqzCfLtUCh1P2c1pYxyBuEdM1YyNfeTtkk 3D5M0w== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 49e8a5yswc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 30 Sep 2025 05:51:05 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-33826e101ecso1853279a91.1 for ; Mon, 29 Sep 2025 22:51:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759211465; x=1759816265; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LEEZ0d7bP/9F2m15CHQF+Po5PDRcDjrLTRtWvJlPJw4=; b=tbKPBFRrNnYWFtEQ3pYOZctlnoUmtqzjuNX+I2t98nZjUMRIMESDE/M2C8oXDuJEn4 HMT281G3usk+WSg87kfEAF/J/Co4LRroEa6CYGHDuSoCMy9bqyZuHhRHurSdxbI1f5y8 jwnYWCEbvWnyIvcG8ms7bIWFIaWLr5oTf/TmDYicLz8mfZdKFU6jF7ZXMzeaI+nCRRb6 Lz9F5qfYujmAiLNC/2MT7B7Om/mJqz7i0jSUbdxvUCTzTaJq7aLYAk7wE+ltX2fBcIU0 SJDptC1Zy51V+BDOdB6ecbFfy8bj23Eh8sbUl7jGYXX8lgN9vyg7xJIMVIpdMbfdnzXE 4Orw== X-Forwarded-Encrypted: i=1; AJvYcCWlD/ZrY+85H9+5ybA6+m1UpBGt1Q3NP/BsRBlfhldUK47F3M18FMmnOy/o529VkfKDLMSjzfjHfNiS@vger.kernel.org X-Gm-Message-State: AOJu0YxPi7Zn4D6gsBhyIPFXUIzwuZ/3WxegFiqG9vnqAT7X2Qm14v/L QXvqB2sdObT1LciTMCDIkHOEqn7FTMWrXJLrzkCMga/oFZfO57bFYugeCtOkWwKJi/WvTJDuFKc 7cyuDKxr/mvDZekItg8qWdGqyhG2yw4OVpDFBhiU30QOZ8wv+B9qC5bZEx/SJ/IaR X-Gm-Gg: ASbGncsOfnwqo4N1i/OlJvY0GU0jkzfFpgyFl33gwM1WhzMchT+V7s/yDyNQHK/L0ht B1U39ihh+8wsBR5VIU7Wg8xkZiIXaGiZinA6UHN6lezfXZgKxOEoraDYPCZ9K21yHCsaRSo7c9l rNeeL2QokZKuShqYnTDSvIc6krjP5J1XMI3WoVwbz9Z4NjymEqGqoZGSvUCMtlHSX18bpY18tEC Wu7YfBeHWXL5Zy6ZCogKVrSbpCL48y9aGk+5QQ6rKAaCi/jxdegSWgIydsg1JK3kJ5MgPoNFZd/ uUGT8FfIkgPQahe1rtnKBiop9PRUPMT/X8BLyeOeiTIQ4UlTxVl8q7a1Cx0kzvG8yx7gwQ== X-Received: by 2002:a17:90b:548e:b0:32b:7d35:a7e6 with SMTP id 98e67ed59e1d1-3383ac467e9mr3543368a91.18.1759211464134; Mon, 29 Sep 2025 22:51:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5iAe3e4u5n6myqZaOqCbzZg+D9XtXMLcFkymOZGWVOgoVd1vtNUeKHmasAP52BXnr26yvmQ== X-Received: by 2002:a17:90b:548e:b0:32b:7d35:a7e6 with SMTP id 98e67ed59e1d1-3383ac467e9mr3543311a91.18.1759211463534; Mon, 29 Sep 2025 22:51:03 -0700 (PDT) Received: from hu-akhilpo-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3341be23412sm19029779a91.20.2025.09.29.22.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Sep 2025 22:51:03 -0700 (PDT) From: Akhil P Oommen Date: Tue, 30 Sep 2025 11:18:15 +0530 Subject: [PATCH 10/17] drm/msm/a6xx: Rebase GMU register offsets Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250930-kaana-gpu-support-v1-10-73530b0700ed@oss.qualcomm.com> References: <20250930-kaana-gpu-support-v1-0-73530b0700ed@oss.qualcomm.com> In-Reply-To: <20250930-kaana-gpu-support-v1-0-73530b0700ed@oss.qualcomm.com> To: Rob Clark , Bjorn Andersson , Konrad Dybcio , Sean Paul , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , Jonathan Marek , Jordan Crouse , Will Deacon , Robin Murphy , Joerg Roedel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, devicetree@vger.kernel.org, Akhil P Oommen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1759211380; l=25096; i=akhilpo@oss.qualcomm.com; s=20240726; h=from:subject:message-id; bh=GTpB2Z9lQwSz5qPaDRTgiMFZ74hnKCFSh/p08mqgbCw=; b=lQTeovCWHf3dlpBNPHq4p6TulzAuyrssPGoGSA461bCGJ6oueciYC7d4/0NgQBfF/N3A92wte BSJ3KDEkYHRA4g0blnzz/SrCb4WewRJypsdKlEEVAE7qUBQ+Fu2XG4l X-Developer-Key: i=akhilpo@oss.qualcomm.com; a=ed25519; pk=lmVtttSHmAUYFnJsQHX80IIRmYmXA4+CzpGcWOOsfKA= X-Authority-Analysis: v=2.4 cv=RZKdyltv c=1 sm=1 tr=0 ts=68db6fc9 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=yJojWOMRYYMA:10 a=e5mUnYsNAAAA:8 a=EUspDBNiAAAA:8 a=ZsPRCQnh5ccIFIapgMwA:9 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 a=Vxmtnl_E_bksehYqCbjh:22 X-Proofpoint-GUID: SKVtr8TuQoTJqTCbZS6ZTGFuR7EUMEOi X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTI3MDAzMyBTYWx0ZWRfXy0SnmuFYk2UJ qxtLsSUiAL1W8wZ858aoZXnDud7azk4CXgVBPhCJjcuhFTdVR01DpS+xuO3Q+oB+UObQZui5HTO my6p/LxPDGH7ttlzWnCKruKwW7Z3J2YXc4WBLcGO2EHXButxUWtMqMSpTUbvDbGbLPhroXtYJKo HAHiooYqx05R/2t80orP51Ym6uWaDmlzWnk2alYkslPHEkvf38zUhrX770P7bBeHUVQrZEojRG2 IgMxXB7mxvqcIyMyadL6uWUxGCIjyQv0cnywiFr9p4/50nrRAEDYpnQirLe8g7uSiyYuNZIMIMy Guu2Iw5AmsCam7n38qM/msDCNVVK7zeyWH9luE1x5qj+dZ3b+w+S5HgNcDdQ+vs06qXDSEAYEP/ p0+3CQ/g6ab44Ohe9VD+xE3mgeF7qw== X-Proofpoint-ORIG-GUID: SKVtr8TuQoTJqTCbZS6ZTGFuR7EUMEOi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-30_01,2025-09-29_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 priorityscore=1501 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2509150000 definitions=main-2509270033 GMU registers are always at a fixed offset from the GPU base address, a consistency maintained at least within a given architecture generation. In A8x family, the base address of the GMU has changed, but the offsets of the gmu registers remain largely the same. To enable reuse of the gmu code for A8x chipsets, update the gmu register offsets to be relative to the GPU's base address instead of GMU's. Signed-off-by: Akhil P Oommen --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 44 +++- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 20 +- drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml | 248 +++++++++++----------- 3 files changed, 172 insertions(+), 140 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index fc717c9474ca5bdd386a8e4e19f43abce10ce591..72d64eb10ca931ee90c91f7e004771cf6d7997a4 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -585,14 +585,14 @@ static inline void pdc_write(void __iomem *ptr, u32 offset, u32 value) } static void __iomem *a6xx_gmu_get_mmio(struct platform_device *pdev, - const char *name); + const char *name, resource_size_t *start); static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu) { struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu); struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; struct platform_device *pdev = to_platform_device(gmu->dev); - void __iomem *pdcptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc"); + void __iomem *pdcptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc", NULL); u32 seqmem0_drv0_reg = REG_A6XX_RSCC_SEQ_MEM_0_DRV0; void __iomem *seqptr = NULL; uint32_t pdc_address_offset; @@ -612,7 +612,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu) pdc_address_offset = 0x30080; if (!pdc_in_aop) { - seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq"); + seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq", NULL); if (IS_ERR(seqptr)) goto err; } @@ -1793,7 +1793,7 @@ static int a6xx_gmu_clocks_probe(struct a6xx_gmu *gmu) } static void __iomem *a6xx_gmu_get_mmio(struct platform_device *pdev, - const char *name) + const char *name, resource_size_t *start) { void __iomem *ret; struct resource *res = platform_get_resource_byname(pdev, @@ -1810,6 +1810,9 @@ static void __iomem *a6xx_gmu_get_mmio(struct platform_device *pdev, return ERR_PTR(-EINVAL); } + if (start) + *start = res->start; + return ret; } @@ -1922,7 +1925,11 @@ static int cxpd_notifier_cb(struct notifier_block *nb, int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) { struct platform_device *pdev = of_find_device_by_node(node); + struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; + struct msm_gpu *gpu = &adreno_gpu->base; struct a6xx_gmu *gmu = &a6xx_gpu->gmu; + resource_size_t start; + struct resource *res; int ret; if (!pdev) @@ -1940,12 +1947,21 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) gmu->legacy = true; /* Map the GMU registers */ - gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu"); + gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu", &start); if (IS_ERR(gmu->mmio)) { ret = PTR_ERR(gmu->mmio); goto err_mmio; } + res = platform_get_resource_byname(gpu->pdev, IORESOURCE_MEM, "kgsl_3d0_reg_memory"); + if (!res) { + ret = -EINVAL; + goto err_mmio; + } + + /* Identify gmu base offset from gpu base address */ + gmu->mmio_offset = (u32)(start - res->start); + gmu->cxpd = dev_pm_domain_attach_by_name(gmu->dev, "cx"); if (IS_ERR(gmu->cxpd)) { ret = PTR_ERR(gmu->cxpd); @@ -1986,10 +2002,13 @@ int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) { + struct platform_device *pdev = of_find_device_by_node(node); struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; + struct msm_gpu *gpu = &adreno_gpu->base; struct a6xx_gmu *gmu = &a6xx_gpu->gmu; - struct platform_device *pdev = of_find_device_by_node(node); struct device_link *link; + resource_size_t start; + struct resource *res; int ret; if (!pdev) @@ -2084,15 +2103,24 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) goto err_memory; /* Map the GMU registers */ - gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu"); + gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu", &start); if (IS_ERR(gmu->mmio)) { ret = PTR_ERR(gmu->mmio); goto err_memory; } + res = platform_get_resource_byname(gpu->pdev, IORESOURCE_MEM, "kgsl_3d0_reg_memory"); + if (!res) { + ret = -EINVAL; + goto err_mmio; + } + + /* Identify gmu base offset from gpu base address */ + gmu->mmio_offset = (u32)(start - res->start); + if (adreno_is_a650_family(adreno_gpu) || adreno_is_a7xx(adreno_gpu)) { - gmu->rscc = a6xx_gmu_get_mmio(pdev, "rscc"); + gmu->rscc = a6xx_gmu_get_mmio(pdev, "rscc", NULL); if (IS_ERR(gmu->rscc)) { ret = -ENODEV; goto err_mmio; diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h index 06cfc294016f513a33eb4004c7892996ac9e0435..55b1c78daa8b523147435a86d6eb629dbad18acd 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h @@ -68,6 +68,7 @@ struct a6xx_gmu { struct drm_gpuvm *vm; void __iomem *mmio; + u32 mmio_offset; void __iomem *rscc; int hfi_irq; @@ -130,20 +131,23 @@ struct a6xx_gmu { unsigned long status; }; +#define GMU_BYTE_OFFSET(gmu, offset) (((offset) << 2) - (gmu)->mmio_offset) + static inline u32 gmu_read(struct a6xx_gmu *gmu, u32 offset) { - return readl(gmu->mmio + (offset << 2)); + /* The 'offset' is based on GPU's start address. Adjust it */ + return readl(gmu->mmio + GMU_BYTE_OFFSET(gmu, offset)); } static inline void gmu_write(struct a6xx_gmu *gmu, u32 offset, u32 value) { - writel(value, gmu->mmio + (offset << 2)); + writel(value, gmu->mmio + GMU_BYTE_OFFSET(gmu, offset)); } static inline void gmu_write_bulk(struct a6xx_gmu *gmu, u32 offset, const u32 *data, u32 size) { - memcpy_toio(gmu->mmio + (offset << 2), data, size); + memcpy_toio(gmu->mmio + GMU_BYTE_OFFSET(gmu, offset), data, size); wmb(); } @@ -160,17 +164,17 @@ static inline u64 gmu_read64(struct a6xx_gmu *gmu, u32 lo, u32 hi) { u64 val; - val = (u64) readl(gmu->mmio + (lo << 2)); - val |= ((u64) readl(gmu->mmio + (hi << 2)) << 32); + val = gmu_read(gmu, lo); + val |= ((u64) gmu_read(gmu, hi) << 32); return val; } #define gmu_poll_timeout(gmu, addr, val, cond, interval, timeout) \ - readl_poll_timeout((gmu)->mmio + ((addr) << 2), val, cond, \ - interval, timeout) + readl_poll_timeout((gmu)->mmio + (GMU_BYTE_OFFSET(gmu, addr)), val, \ + cond, interval, timeout) #define gmu_poll_timeout_atomic(gmu, addr, val, cond, interval, timeout) \ - readl_poll_timeout_atomic((gmu)->mmio + ((addr) << 2), val, cond, \ + readl_poll_timeout_atomic((gmu)->mmio + (GMU_BYTE_OFFSET(gmu, addr)), val, cond, \ interval, timeout) static inline u32 gmu_read_rscc(struct a6xx_gmu *gmu, u32 offset) diff --git a/drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml b/drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml index b15a242d974d6b42133171c8484d3b0413f2d3a4..09b8a0b9c0de7615f7e7e6364c198405a498121a 100644 --- a/drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml +++ b/drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml @@ -40,56 +40,56 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + @@ -99,15 +99,15 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> - + - + - + @@ -119,71 +119,71 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -191,27 +191,27 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> - - - - - + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + -- 2.51.0