Message ID | 20200611223656.4724-1-jcrouse@codeaurora.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iommu/arm-smmu: Add a init_context_bank implementation hook | expand |
On Thu, Jun 11, 2020 at 04:36:56PM -0600, Jordan Crouse wrote: > Add a new implementation hook to allow the implementation specific code > to tweek the context bank configuration just before it gets written. > The first user will be the Adreno GPU implementation to turn on > SCTLR.HUPCF to ensure that a page fault doesn't terminating pending > transactions. Doing so could hang the GPU if one of the terminated > transactions is a CP read. > > This depends on the arm-smmu adreno SMMU implementation [1]. > > [1] https://patchwork.kernel.org/patch/11600943/ > > Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> > --- > > drivers/iommu/arm-smmu-qcom.c | 13 +++++++++++++ > drivers/iommu/arm-smmu.c | 28 +++++++++++++--------------- > drivers/iommu/arm-smmu.h | 11 +++++++++++ > 3 files changed, 37 insertions(+), 15 deletions(-) This looks straightforward enough, but I don't want to merge this without a user and Sai's series has open questions afaict. Will
On Mon, Jul 13, 2020 at 04:11:23PM +0100, Will Deacon wrote: > On Thu, Jun 11, 2020 at 04:36:56PM -0600, Jordan Crouse wrote: > > Add a new implementation hook to allow the implementation specific code > > to tweek the context bank configuration just before it gets written. > > The first user will be the Adreno GPU implementation to turn on > > SCTLR.HUPCF to ensure that a page fault doesn't terminating pending > > transactions. Doing so could hang the GPU if one of the terminated > > transactions is a CP read. > > > > This depends on the arm-smmu adreno SMMU implementation [1]. > > > > [1] https://patchwork.kernel.org/patch/11600943/ > > > > Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> > > --- > > > > drivers/iommu/arm-smmu-qcom.c | 13 +++++++++++++ > > drivers/iommu/arm-smmu.c | 28 +++++++++++++--------------- > > drivers/iommu/arm-smmu.h | 11 +++++++++++ > > 3 files changed, 37 insertions(+), 15 deletions(-) > > This looks straightforward enough, but I don't want to merge this without > a user and Sai's series has open questions afaict. Not sure what you mean by a user in this context? Are you referring to https://patchwork.kernel.org/patch/11628541/? > Will
On Mon, Jul 13, 2020 at 11:00:32AM -0600, Jordan Crouse wrote: > On Mon, Jul 13, 2020 at 04:11:23PM +0100, Will Deacon wrote: > > On Thu, Jun 11, 2020 at 04:36:56PM -0600, Jordan Crouse wrote: > > > Add a new implementation hook to allow the implementation specific code > > > to tweek the context bank configuration just before it gets written. > > > The first user will be the Adreno GPU implementation to turn on > > > SCTLR.HUPCF to ensure that a page fault doesn't terminating pending > > > transactions. Doing so could hang the GPU if one of the terminated > > > transactions is a CP read. > > > > > > This depends on the arm-smmu adreno SMMU implementation [1]. > > > > > > [1] https://patchwork.kernel.org/patch/11600943/ > > > > > > Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> > > > --- > > > > > > drivers/iommu/arm-smmu-qcom.c | 13 +++++++++++++ > > > drivers/iommu/arm-smmu.c | 28 +++++++++++++--------------- > > > drivers/iommu/arm-smmu.h | 11 +++++++++++ > > > 3 files changed, 37 insertions(+), 15 deletions(-) > > > > This looks straightforward enough, but I don't want to merge this without > > a user and Sai's series has open questions afaict. > > Not sure what you mean by a user in this context? > Are you referring to https://patchwork.kernel.org/patch/11628541/? Right, this post was just a single patch in isolation, whereas it was reposted over at: https://lore.kernel.org/r/cdcc6a1c95a84e774790389dc8b3b7feeee490dc.1593344119.git.saiprakash.ranjan@codeaurora.org so I'll ignore this one. Sorry, I'm just really struggling to keep track of what is targetting 5.9, and I don't have tonnes of time to sift through the backlog of duplicate postings :( Will
On Mon, Jul 13, 2020 at 08:03:32PM +0100, Will Deacon wrote: > On Mon, Jul 13, 2020 at 11:00:32AM -0600, Jordan Crouse wrote: > > On Mon, Jul 13, 2020 at 04:11:23PM +0100, Will Deacon wrote: > > > On Thu, Jun 11, 2020 at 04:36:56PM -0600, Jordan Crouse wrote: > > > > Add a new implementation hook to allow the implementation specific code > > > > to tweek the context bank configuration just before it gets written. > > > > The first user will be the Adreno GPU implementation to turn on > > > > SCTLR.HUPCF to ensure that a page fault doesn't terminating pending > > > > transactions. Doing so could hang the GPU if one of the terminated > > > > transactions is a CP read. > > > > > > > > This depends on the arm-smmu adreno SMMU implementation [1]. > > > > > > > > [1] https://patchwork.kernel.org/patch/11600943/ > > > > > > > > Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> > > > > --- > > > > > > > > drivers/iommu/arm-smmu-qcom.c | 13 +++++++++++++ > > > > drivers/iommu/arm-smmu.c | 28 +++++++++++++--------------- > > > > drivers/iommu/arm-smmu.h | 11 +++++++++++ > > > > 3 files changed, 37 insertions(+), 15 deletions(-) > > > > > > This looks straightforward enough, but I don't want to merge this without > > > a user and Sai's series has open questions afaict. > > > > Not sure what you mean by a user in this context? > > Are you referring to https://patchwork.kernel.org/patch/11628541/? > > Right, this post was just a single patch in isolation, whereas it was > reposted over at: > > https://lore.kernel.org/r/cdcc6a1c95a84e774790389dc8b3b7feeee490dc.1593344119.git.saiprakash.ranjan@codeaurora.org > > so I'll ignore this one. Sorry, I'm just really struggling to keep track > of what is targetting 5.9, and I don't have tonnes of time to sift through > the backlog of duplicate postings :( Yeah, that is our fault. There are too many cooks in the kitchen. We need to pick either system cache or split pagetable and serialize the other on top of it to get the impl code going and then build from there. This particular patch can happily hang out in the background until the rest is resolved. Jordan > Will > _______________________________________________ > Freedreno mailing list > Freedreno@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/freedreno
On 2020-07-14 00:43, Jordan Crouse wrote: > On Mon, Jul 13, 2020 at 08:03:32PM +0100, Will Deacon wrote: >> On Mon, Jul 13, 2020 at 11:00:32AM -0600, Jordan Crouse wrote: >> > On Mon, Jul 13, 2020 at 04:11:23PM +0100, Will Deacon wrote: >> > > On Thu, Jun 11, 2020 at 04:36:56PM -0600, Jordan Crouse wrote: >> > > > Add a new implementation hook to allow the implementation specific code >> > > > to tweek the context bank configuration just before it gets written. >> > > > The first user will be the Adreno GPU implementation to turn on >> > > > SCTLR.HUPCF to ensure that a page fault doesn't terminating pending >> > > > transactions. Doing so could hang the GPU if one of the terminated >> > > > transactions is a CP read. >> > > > >> > > > This depends on the arm-smmu adreno SMMU implementation [1]. >> > > > >> > > > [1] https://patchwork.kernel.org/patch/11600943/ >> > > > >> > > > Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> >> > > > --- >> > > > >> > > > drivers/iommu/arm-smmu-qcom.c | 13 +++++++++++++ >> > > > drivers/iommu/arm-smmu.c | 28 +++++++++++++--------------- >> > > > drivers/iommu/arm-smmu.h | 11 +++++++++++ >> > > > 3 files changed, 37 insertions(+), 15 deletions(-) >> > > >> > > This looks straightforward enough, but I don't want to merge this without >> > > a user and Sai's series has open questions afaict. >> > >> > Not sure what you mean by a user in this context? >> > Are you referring to https://patchwork.kernel.org/patch/11628541/? >> >> Right, this post was just a single patch in isolation, whereas it was >> reposted over at: >> >> https://lore.kernel.org/r/cdcc6a1c95a84e774790389dc8b3b7feeee490dc.1593344119.git.saiprakash.ranjan@codeaurora.org >> >> so I'll ignore this one. Sorry, I'm just really struggling to keep >> track >> of what is targetting 5.9, and I don't have tonnes of time to sift >> through >> the backlog of duplicate postings :( > > Yeah, that is our fault. There are too many cooks in the kitchen. > > We need to pick either system cache or split pagetable and serialize > the other on top of it to get the impl code going and then build from > there. > This particular patch can happily hang out in the background until the > rest is > resolved. > My bad, sorry. Let us get split pagetable support reviewed first, then I can post system cache support on top of it. As jordan said, this patch can hibernate until those get resolved. Thanks, Sai
diff --git a/drivers/iommu/arm-smmu-qcom.c b/drivers/iommu/arm-smmu-qcom.c index 6d0ab4865fc7..e5c6345da6fc 100644 --- a/drivers/iommu/arm-smmu-qcom.c +++ b/drivers/iommu/arm-smmu-qcom.c @@ -17,6 +17,18 @@ static bool qcom_adreno_smmu_is_gpu_device(struct arm_smmu_domain *smmu_domain) return of_device_is_compatible(smmu_domain->dev.of_node, "qcom,adreno"); } +static void qcom_adreno_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, + struct arm_smmu_cb *cb) +{ + /* + * On the GPU device we want to process subsequent transactions after a + * fault to keep the GPU from hanging + */ + + if (qcom_adreno_smmu_is_gpu_device(smmu_domain)) + cb->sctlr |= ARM_SMMU_SCTLR_HUPCF; +} + static int qcom_adreno_smmu_init_context(struct arm_smmu_domain *smmu_domain, struct io_pgtable_cfg *pgtbl_cfg) { @@ -92,6 +104,7 @@ static const struct arm_smmu_impl qcom_adreno_smmu_impl = { .init_context = qcom_adreno_smmu_init_context, .def_domain_type = qcom_smmu_def_domain_type, .reset = qcom_smmu500_reset, + .init_context_bank = qcom_adreno_smmu_init_context_bank, }; diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index a06cbcaec247..f0f201ece3a0 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -86,13 +86,6 @@ struct arm_smmu_smr { bool valid; }; -struct arm_smmu_cb { - u64 ttbr[2]; - u32 tcr[2]; - u32 mair[2]; - struct arm_smmu_cfg *cfg; -}; - struct arm_smmu_master_cfg { struct arm_smmu_device *smmu; s16 smendx[]; @@ -579,6 +572,18 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, cb->mair[1] = pgtbl_cfg->arm_lpae_s1_cfg.mair >> 32; } } + + cb->sctlr = ARM_SMMU_SCTLR_CFIE | ARM_SMMU_SCTLR_CFRE | ARM_SMMU_SCTLR_AFE | + ARM_SMMU_SCTLR_TRE | ARM_SMMU_SCTLR_M; + + if (stage1) + cb->sctlr |= ARM_SMMU_SCTLR_S1_ASIDPNE; + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) + cb->sctlr |= ARM_SMMU_SCTLR_E; + + /* Give the implementation a chance to adjust the configuration */ + if (smmu_domain->smmu->impl && smmu_domain->smmu->impl->init_context_bank) + smmu_domain->smmu->impl->init_context_bank(smmu_domain, cb); } static void arm_smmu_write_context_bank(struct arm_smmu_device *smmu, int idx) @@ -657,14 +662,7 @@ static void arm_smmu_write_context_bank(struct arm_smmu_device *smmu, int idx) } /* SCTLR */ - reg = ARM_SMMU_SCTLR_CFIE | ARM_SMMU_SCTLR_CFRE | ARM_SMMU_SCTLR_AFE | - ARM_SMMU_SCTLR_TRE | ARM_SMMU_SCTLR_M; - if (stage1) - reg |= ARM_SMMU_SCTLR_S1_ASIDPNE; - if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) - reg |= ARM_SMMU_SCTLR_E; - - arm_smmu_cb_write(smmu, idx, ARM_SMMU_CB_SCTLR, reg); + arm_smmu_cb_write(smmu, idx, ARM_SMMU_CB_SCTLR, cb->sctlr); } /* diff --git a/drivers/iommu/arm-smmu.h b/drivers/iommu/arm-smmu.h index 79d441024043..9b539820997b 100644 --- a/drivers/iommu/arm-smmu.h +++ b/drivers/iommu/arm-smmu.h @@ -142,6 +142,7 @@ enum arm_smmu_cbar_type { #define ARM_SMMU_CB_SCTLR 0x0 #define ARM_SMMU_SCTLR_S1_ASIDPNE BIT(12) +#define ARM_SMMU_SCTLR_HUPCF BIT(8) #define ARM_SMMU_SCTLR_CFCFG BIT(7) #define ARM_SMMU_SCTLR_CFIE BIT(6) #define ARM_SMMU_SCTLR_CFRE BIT(5) @@ -349,6 +350,14 @@ struct arm_smmu_domain { bool aux; }; +struct arm_smmu_cb { + u64 ttbr[2]; + u32 tcr[2]; + u32 mair[2]; + u32 sctlr; + struct arm_smmu_cfg *cfg; +}; + static inline u32 arm_smmu_lpae_tcr(struct io_pgtable_cfg *cfg) { u32 tcr = FIELD_PREP(ARM_SMMU_TCR_TG0, cfg->arm_lpae_s1_cfg.tcr.tg) | @@ -403,6 +412,8 @@ struct arm_smmu_impl { void (*tlb_sync)(struct arm_smmu_device *smmu, int page, int sync, int status); int (*def_domain_type)(struct device *dev); + void (*init_context_bank)(struct arm_smmu_domain *smmu_domain, + struct arm_smmu_cb *cb); }; static inline void __iomem *arm_smmu_page(struct arm_smmu_device *smmu, int n)
Add a new implementation hook to allow the implementation specific code to tweek the context bank configuration just before it gets written. The first user will be the Adreno GPU implementation to turn on SCTLR.HUPCF to ensure that a page fault doesn't terminating pending transactions. Doing so could hang the GPU if one of the terminated transactions is a CP read. This depends on the arm-smmu adreno SMMU implementation [1]. [1] https://patchwork.kernel.org/patch/11600943/ Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> --- drivers/iommu/arm-smmu-qcom.c | 13 +++++++++++++ drivers/iommu/arm-smmu.c | 28 +++++++++++++--------------- drivers/iommu/arm-smmu.h | 11 +++++++++++ 3 files changed, 37 insertions(+), 15 deletions(-)