* [PATCH RFT 0/2] drm/msm/adreno: Setup SMMU aparture
@ 2024-10-03 3:01 Bjorn Andersson
2024-10-03 3:01 ` [PATCH RFT 1/2] firmware: qcom: scm: Introduce CP_SMMU_APERTURE_ID Bjorn Andersson
2024-10-03 3:01 ` [PATCH RFT 2/2] drm/msm/adreno: Setup SMMU aparture for per-process page table Bjorn Andersson
0 siblings, 2 replies; 7+ messages in thread
From: Bjorn Andersson @ 2024-10-03 3:01 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Rob Clark, Sean Paul,
Abhinav Kumar, Dmitry Baryshkov, Marijn Suijten, David Airlie,
Simona Vetter
Cc: linux-arm-msm, linux-kernel, dri-devel, freedreno,
Bjorn Andersson
Support for per-page tables requires the SMMU aparture to be setup, on
some targets this is done statically in firmware, on others it's
expected to be requested in runtime by the driver, through a SCM call.
Marking the series as RFT, as this has been tested on a few different
modern platforms, but only with Qualcomm presence in EL2.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
---
Bjorn Andersson (2):
firmware: qcom: scm: Introduce CP_SMMU_APERTURE_ID
drm/msm/adreno: Setup SMMU aparture for per-process page table
drivers/firmware/qcom/qcom_scm.c | 19 +++++++++++++++++++
drivers/firmware/qcom/qcom_scm.h | 1 +
drivers/gpu/drm/msm/adreno/adreno_gpu.c | 10 ++++++++++
include/linux/firmware/qcom/qcom_scm.h | 1 +
4 files changed, 31 insertions(+)
---
base-commit: fe21733536749bb1b31c9c84e0b8d2ab8d82ce13
change-id: 20241002-adreno-smmu-aparture-fe7d5a1cb834
Best regards,
--
Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH RFT 1/2] firmware: qcom: scm: Introduce CP_SMMU_APERTURE_ID
2024-10-03 3:01 [PATCH RFT 0/2] drm/msm/adreno: Setup SMMU aparture Bjorn Andersson
@ 2024-10-03 3:01 ` Bjorn Andersson
2024-10-03 16:48 ` Konrad Dybcio
2024-10-04 22:30 ` Jessica Zhang
2024-10-03 3:01 ` [PATCH RFT 2/2] drm/msm/adreno: Setup SMMU aparture for per-process page table Bjorn Andersson
1 sibling, 2 replies; 7+ messages in thread
From: Bjorn Andersson @ 2024-10-03 3:01 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Rob Clark, Sean Paul,
Abhinav Kumar, Dmitry Baryshkov, Marijn Suijten, David Airlie,
Simona Vetter
Cc: linux-arm-msm, linux-kernel, dri-devel, freedreno,
Bjorn Andersson
The QCOM_SCM_SVC_MP service provides QCOM_SCM_MP_CP_SMMU_APERTURE_ID,
which is used to trigger the mapping of register banks into the SMMU
context for per-processes page tables to function (in case this isn't
statically setup by firmware).
This is necessary on e.g. QCS6490 Rb3Gen2, in order to avoid "CP | AHB
bus error"-errors from the GPU.
Introduce a function to allow the msm driver to invoke this call.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
---
drivers/firmware/qcom/qcom_scm.c | 19 +++++++++++++++++++
drivers/firmware/qcom/qcom_scm.h | 1 +
include/linux/firmware/qcom/qcom_scm.h | 1 +
3 files changed, 21 insertions(+)
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 10986cb11ec0..bd633c57b6e8 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -903,6 +903,25 @@ int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare)
}
EXPORT_SYMBOL_GPL(qcom_scm_restore_sec_cfg);
+#define QCOM_SCM_CP_APERTURE_CONTEXT_MASK GENMASK(7, 0)
+
+int qcom_scm_set_gpu_smmu_aperture(unsigned int context_bank)
+{
+ struct qcom_scm_desc desc = {
+ .svc = QCOM_SCM_SVC_MP,
+ .cmd = QCOM_SCM_MP_CP_SMMU_APERTURE_ID,
+ .arginfo = QCOM_SCM_ARGS(4),
+ .args[0] = 0xffff0000 | FIELD_PREP(QCOM_SCM_CP_APERTURE_CONTEXT_MASK, context_bank),
+ .args[1] = 0xffffffff,
+ .args[2] = 0xffffffff,
+ .args[3] = 0xffffffff,
+ .owner = ARM_SMCCC_OWNER_SIP
+ };
+
+ return qcom_scm_call(__scm->dev, &desc, NULL);
+}
+EXPORT_SYMBOL_GPL(qcom_scm_set_gpu_smmu_aperture);
+
int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size)
{
struct qcom_scm_desc desc = {
diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h
index 685b8f59e7a6..e36b2f67607f 100644
--- a/drivers/firmware/qcom/qcom_scm.h
+++ b/drivers/firmware/qcom/qcom_scm.h
@@ -116,6 +116,7 @@ struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void);
#define QCOM_SCM_MP_IOMMU_SET_CP_POOL_SIZE 0x05
#define QCOM_SCM_MP_VIDEO_VAR 0x08
#define QCOM_SCM_MP_ASSIGN 0x16
+#define QCOM_SCM_MP_CP_SMMU_APERTURE_ID 0x1b
#define QCOM_SCM_MP_SHM_BRIDGE_ENABLE 0x1c
#define QCOM_SCM_MP_SHM_BRIDGE_DELETE 0x1d
#define QCOM_SCM_MP_SHM_BRIDGE_CREATE 0x1e
diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h
index 9f14976399ab..23ec8ee5e49f 100644
--- a/include/linux/firmware/qcom/qcom_scm.h
+++ b/include/linux/firmware/qcom/qcom_scm.h
@@ -85,6 +85,7 @@ int qcom_scm_io_writel(phys_addr_t addr, unsigned int val);
bool qcom_scm_restore_sec_cfg_available(void);
int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare);
+int qcom_scm_set_gpu_smmu_aperture(unsigned int context_bank);
int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size);
int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare);
int qcom_scm_iommu_set_cp_pool_size(u32 spare, u32 size);
--
2.45.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RFT 2/2] drm/msm/adreno: Setup SMMU aparture for per-process page table
2024-10-03 3:01 [PATCH RFT 0/2] drm/msm/adreno: Setup SMMU aparture Bjorn Andersson
2024-10-03 3:01 ` [PATCH RFT 1/2] firmware: qcom: scm: Introduce CP_SMMU_APERTURE_ID Bjorn Andersson
@ 2024-10-03 3:01 ` Bjorn Andersson
2024-10-03 16:55 ` Konrad Dybcio
2024-10-04 22:35 ` Jessica Zhang
1 sibling, 2 replies; 7+ messages in thread
From: Bjorn Andersson @ 2024-10-03 3:01 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Rob Clark, Sean Paul,
Abhinav Kumar, Dmitry Baryshkov, Marijn Suijten, David Airlie,
Simona Vetter
Cc: linux-arm-msm, linux-kernel, dri-devel, freedreno,
Bjorn Andersson
Support for per-process page tables requires the SMMU aparture to be
setup such that the GPU can make updates with the SMMU. On some targets
this is done statically in firmware, on others it's expected to be
requested in runtime by the driver, through a SCM call.
One place where configuration is expected to be done dynamically is the
QCS6490 rb3gen2.
The downstream driver does this unconditioanlly on any A6xx and newer,
so follow suite and make the call.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
---
drivers/gpu/drm/msm/adreno/adreno_gpu.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 465a4cd14a43..5b06f7a04fe6 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -572,8 +572,18 @@ struct drm_gem_object *adreno_fw_create_bo(struct msm_gpu *gpu,
int adreno_hw_init(struct msm_gpu *gpu)
{
+ struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
+ int ret;
+
VERB("%s", gpu->name);
+ if (adreno_gpu->info->family >= ADRENO_6XX_GEN1) {
+ /* We currently always use context bank 0, so hard code this */
+ ret = qcom_scm_set_gpu_smmu_aperture(0);
+ if (ret)
+ DRM_DEV_ERROR(gpu->dev->dev, "unable to set SMMU aperture: %d\n", ret);
+ }
+
for (int i = 0; i < gpu->nr_rings; i++) {
struct msm_ringbuffer *ring = gpu->rb[i];
--
2.45.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RFT 1/2] firmware: qcom: scm: Introduce CP_SMMU_APERTURE_ID
2024-10-03 3:01 ` [PATCH RFT 1/2] firmware: qcom: scm: Introduce CP_SMMU_APERTURE_ID Bjorn Andersson
@ 2024-10-03 16:48 ` Konrad Dybcio
2024-10-04 22:30 ` Jessica Zhang
1 sibling, 0 replies; 7+ messages in thread
From: Konrad Dybcio @ 2024-10-03 16:48 UTC (permalink / raw)
To: Bjorn Andersson, Bjorn Andersson, Konrad Dybcio, Rob Clark,
Sean Paul, Abhinav Kumar, Dmitry Baryshkov, Marijn Suijten,
David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-kernel, dri-devel, freedreno
On 3.10.2024 5:01 AM, Bjorn Andersson wrote:
> The QCOM_SCM_SVC_MP service provides QCOM_SCM_MP_CP_SMMU_APERTURE_ID,
> which is used to trigger the mapping of register banks into the SMMU
> context for per-processes page tables to function (in case this isn't
> statically setup by firmware).
>
> This is necessary on e.g. QCS6490 Rb3Gen2, in order to avoid "CP | AHB
> bus error"-errors from the GPU.
>
> Introduce a function to allow the msm driver to invoke this call.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
> ---
Tested-by: Konrad Dybcio <konradybcio@kernel.org> # FP5
Reviewed-by: Konrad Dybcio <konradybcio@kernel.org>
Konrad
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFT 2/2] drm/msm/adreno: Setup SMMU aparture for per-process page table
2024-10-03 3:01 ` [PATCH RFT 2/2] drm/msm/adreno: Setup SMMU aparture for per-process page table Bjorn Andersson
@ 2024-10-03 16:55 ` Konrad Dybcio
2024-10-04 22:35 ` Jessica Zhang
1 sibling, 0 replies; 7+ messages in thread
From: Konrad Dybcio @ 2024-10-03 16:55 UTC (permalink / raw)
To: Bjorn Andersson, Bjorn Andersson, Konrad Dybcio, Rob Clark,
Sean Paul, Abhinav Kumar, Dmitry Baryshkov, Marijn Suijten,
David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-kernel, dri-devel, freedreno
On 3.10.2024 5:01 AM, Bjorn Andersson wrote:
> Support for per-process page tables requires the SMMU aparture to be
> setup such that the GPU can make updates with the SMMU. On some targets
> this is done statically in firmware, on others it's expected to be
> requested in runtime by the driver, through a SCM call.
>
> One place where configuration is expected to be done dynamically is the
> QCS6490 rb3gen2.
>
> The downstream driver does this unconditioanlly on any A6xx and newer,
> so follow suite and make the call.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
> ---
Not all A6xx targets support PPPT (e.g. A619 on SM6375 - but A619 on SM6350
does..). We already print some error messages when that's the case, I think
this may add one more.
Nonetheless, I think that sticks to the accepted status quo where lacking
PPPT is a bug, so..
Tested-by: Konrad Dybcio <konradybcio@kernel.org> # FP5
Reviewed-by: Konrad Dybcio <konradybcio@kernel.org>
Konrad
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFT 1/2] firmware: qcom: scm: Introduce CP_SMMU_APERTURE_ID
2024-10-03 3:01 ` [PATCH RFT 1/2] firmware: qcom: scm: Introduce CP_SMMU_APERTURE_ID Bjorn Andersson
2024-10-03 16:48 ` Konrad Dybcio
@ 2024-10-04 22:30 ` Jessica Zhang
1 sibling, 0 replies; 7+ messages in thread
From: Jessica Zhang @ 2024-10-04 22:30 UTC (permalink / raw)
To: Bjorn Andersson, Bjorn Andersson, Konrad Dybcio, Rob Clark,
Sean Paul, Abhinav Kumar, Dmitry Baryshkov, Marijn Suijten,
David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-kernel, dri-devel, freedreno
On 10/2/2024 8:01 PM, Bjorn Andersson wrote:
> The QCOM_SCM_SVC_MP service provides QCOM_SCM_MP_CP_SMMU_APERTURE_ID,
> which is used to trigger the mapping of register banks into the SMMU
> context for per-processes page tables to function (in case this isn't
> statically setup by firmware).
>
> This is necessary on e.g. QCS6490 Rb3Gen2, in order to avoid "CP | AHB
> bus error"-errors from the GPU.
>
> Introduce a function to allow the msm driver to invoke this call.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Hi Bjorn,
Tested-by: Jessica Zhang <quic_jesszhan@quicinc.com> # Trogdor (sc7180)
Thanks,
Jessica Zhang
> ---
> drivers/firmware/qcom/qcom_scm.c | 19 +++++++++++++++++++
> drivers/firmware/qcom/qcom_scm.h | 1 +
> include/linux/firmware/qcom/qcom_scm.h | 1 +
> 3 files changed, 21 insertions(+)
>
> diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
> index 10986cb11ec0..bd633c57b6e8 100644
> --- a/drivers/firmware/qcom/qcom_scm.c
> +++ b/drivers/firmware/qcom/qcom_scm.c
> @@ -903,6 +903,25 @@ int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare)
> }
> EXPORT_SYMBOL_GPL(qcom_scm_restore_sec_cfg);
>
> +#define QCOM_SCM_CP_APERTURE_CONTEXT_MASK GENMASK(7, 0)
> +
> +int qcom_scm_set_gpu_smmu_aperture(unsigned int context_bank)
> +{
> + struct qcom_scm_desc desc = {
> + .svc = QCOM_SCM_SVC_MP,
> + .cmd = QCOM_SCM_MP_CP_SMMU_APERTURE_ID,
> + .arginfo = QCOM_SCM_ARGS(4),
> + .args[0] = 0xffff0000 | FIELD_PREP(QCOM_SCM_CP_APERTURE_CONTEXT_MASK, context_bank),
> + .args[1] = 0xffffffff,
> + .args[2] = 0xffffffff,
> + .args[3] = 0xffffffff,
> + .owner = ARM_SMCCC_OWNER_SIP
> + };
> +
> + return qcom_scm_call(__scm->dev, &desc, NULL);
> +}
> +EXPORT_SYMBOL_GPL(qcom_scm_set_gpu_smmu_aperture);
> +
> int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size)
> {
> struct qcom_scm_desc desc = {
> diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h
> index 685b8f59e7a6..e36b2f67607f 100644
> --- a/drivers/firmware/qcom/qcom_scm.h
> +++ b/drivers/firmware/qcom/qcom_scm.h
> @@ -116,6 +116,7 @@ struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void);
> #define QCOM_SCM_MP_IOMMU_SET_CP_POOL_SIZE 0x05
> #define QCOM_SCM_MP_VIDEO_VAR 0x08
> #define QCOM_SCM_MP_ASSIGN 0x16
> +#define QCOM_SCM_MP_CP_SMMU_APERTURE_ID 0x1b
> #define QCOM_SCM_MP_SHM_BRIDGE_ENABLE 0x1c
> #define QCOM_SCM_MP_SHM_BRIDGE_DELETE 0x1d
> #define QCOM_SCM_MP_SHM_BRIDGE_CREATE 0x1e
> diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h
> index 9f14976399ab..23ec8ee5e49f 100644
> --- a/include/linux/firmware/qcom/qcom_scm.h
> +++ b/include/linux/firmware/qcom/qcom_scm.h
> @@ -85,6 +85,7 @@ int qcom_scm_io_writel(phys_addr_t addr, unsigned int val);
>
> bool qcom_scm_restore_sec_cfg_available(void);
> int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare);
> +int qcom_scm_set_gpu_smmu_aperture(unsigned int context_bank);
> int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size);
> int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare);
> int qcom_scm_iommu_set_cp_pool_size(u32 spare, u32 size);
>
> --
> 2.45.2
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFT 2/2] drm/msm/adreno: Setup SMMU aparture for per-process page table
2024-10-03 3:01 ` [PATCH RFT 2/2] drm/msm/adreno: Setup SMMU aparture for per-process page table Bjorn Andersson
2024-10-03 16:55 ` Konrad Dybcio
@ 2024-10-04 22:35 ` Jessica Zhang
1 sibling, 0 replies; 7+ messages in thread
From: Jessica Zhang @ 2024-10-04 22:35 UTC (permalink / raw)
To: Bjorn Andersson, Bjorn Andersson, Konrad Dybcio, Rob Clark,
Sean Paul, Abhinav Kumar, Dmitry Baryshkov, Marijn Suijten,
David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-kernel, dri-devel, freedreno
On 10/2/2024 8:01 PM, Bjorn Andersson wrote:
> Support for per-process page tables requires the SMMU aparture to be
> setup such that the GPU can make updates with the SMMU. On some targets
> this is done statically in firmware, on others it's expected to be
> requested in runtime by the driver, through a SCM call.
>
> One place where configuration is expected to be done dynamically is the
> QCS6490 rb3gen2.
>
> The downstream driver does this unconditioanlly on any A6xx and newer,
> so follow suite and make the call.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Hi Bjorn,
Tested-by: Jessica Zhang <quic_jesszhan@quicinc.com> # Trogdor (sc7180)
Thanks,
Jessica Zhang
> ---
> drivers/gpu/drm/msm/adreno/adreno_gpu.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index 465a4cd14a43..5b06f7a04fe6 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -572,8 +572,18 @@ struct drm_gem_object *adreno_fw_create_bo(struct msm_gpu *gpu,
>
> int adreno_hw_init(struct msm_gpu *gpu)
> {
> + struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
> + int ret;
> +
> VERB("%s", gpu->name);
>
> + if (adreno_gpu->info->family >= ADRENO_6XX_GEN1) {
> + /* We currently always use context bank 0, so hard code this */
> + ret = qcom_scm_set_gpu_smmu_aperture(0);
> + if (ret)
> + DRM_DEV_ERROR(gpu->dev->dev, "unable to set SMMU aperture: %d\n", ret);
> + }
> +
> for (int i = 0; i < gpu->nr_rings; i++) {
> struct msm_ringbuffer *ring = gpu->rb[i];
>
>
> --
> 2.45.2
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-10-04 22:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-03 3:01 [PATCH RFT 0/2] drm/msm/adreno: Setup SMMU aparture Bjorn Andersson
2024-10-03 3:01 ` [PATCH RFT 1/2] firmware: qcom: scm: Introduce CP_SMMU_APERTURE_ID Bjorn Andersson
2024-10-03 16:48 ` Konrad Dybcio
2024-10-04 22:30 ` Jessica Zhang
2024-10-03 3:01 ` [PATCH RFT 2/2] drm/msm/adreno: Setup SMMU aparture for per-process page table Bjorn Andersson
2024-10-03 16:55 ` Konrad Dybcio
2024-10-04 22:35 ` Jessica Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).