FAILED: patch "[PATCH] drm/msm: Wire up tlb ops" failed to apply to 5.10-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 8c7bfd8262319fd3f127a5380f593ea76f1b88a2
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024021917-apron-rising-e383@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..
Possible dependencies:
8c7bfd826231 ("drm/msm: Wire up tlb ops") 70bccecfcaf6 ("drm/msm/iommu: optimize map/unmap")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8c7bfd8262319fd3f127a5380f593ea76f1b88a2 Mon Sep 17 00:00:00 2001
From: Rob Clark <[email protected]>
Date: Tue, 13 Feb 2024 09:23:40 -0800
Subject: [PATCH] drm/msm: Wire up tlb ops
The brute force iommu_flush_iotlb_all() was good enough for unmap, but in some cases a map operation could require removing a table pte entry to replace with a block entry. This also requires tlb invalidation. Missing this was resulting an obscure iova fault on what should be a valid buffer address.
Thanks to Robin Murphy for helping me understand the cause of the fault.
Patchwork: https://patchwork.freedesktop.org/patch/578117/
drivers/gpu/drm/msm/msm_iommu.c +29 -3
@@ -21,6 +21,8 @@ struct msm_iommu_pagetable {struct msm_mmu base;struct msm_mmu *parent;struct io_pgtable_ops *pgtbl_ops; +const struct iommu_flush_ops *tlb; +struct device *iommu_dev;unsigned long pgsize_bitmap;/* Bitmap of page sizes in use */ phys_addr_t ttbr;u32 asid;
@@ -201,11 +203,33 @@ static const struct msm_mmu_funcs pagetable_funcs = {static void msm_iommu_tlb_flush_all (void *cookie) { +struct msm_iommu_pagetable *pagetable = cookie; +struct adreno_smmu_priv *adreno_smmu; + +if (!pm_runtime_get_if_in_use (pagetable->iommu_dev)) +return ; + + adreno_smmu =dev_get_drvdata (pagetable->parent->dev); + + pagetable->tlb->tlb_flush_all ((void *)adreno_smmu->cookie); + +pm_runtime_put_autosuspend (pagetable->iommu_dev); }static void msm_iommu_tlb_flush_walk (unsigned long iova,size_t size,size_t granule,void *cookie) { +struct msm_iommu_pagetable *pagetable = cookie; +struct adreno_smmu_priv *adreno_smmu; + +if (!pm_runtime_get_if_in_use (pagetable->iommu_dev)) +return ; + + adreno_smmu =dev_get_drvdata (pagetable->parent->dev); + + pagetable->tlb->tlb_flush_walk (iova, size, granule, (void *)adreno_smmu->cookie); + +pm_runtime_put_autosuspend (pagetable->iommu_dev); } static void msm_iommu_tlb_add_page(struct iommu_iotlb_gather *gather,
@@ -213,7 +237,7 @@ static void msm_iommu_tlb_add_page(struct iommu_iotlb_gather *gather, { } -static const struct iommu_flush_ops null_tlb_ops = { +static const struct iommu_flush_ops tlb_ops = { .tlb_flush_all = msm_iommu_tlb_flush_all, .tlb_flush_walk = msm_iommu_tlb_flush_walk, .tlb_add_page = msm_iommu_tlb_add_page,
@@ -254,10 +278,10 @@ struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent)/* The incoming cfg will have the TTBR1 quirk enabled */ ttbr0_cfg.quirks &= ~IO_PGTABLE_QUIRK_ARM_TTBR1 ; - ttbr0_cfg.tlb = &null_tlb_ops; + ttbr0_cfg.tlb = &tlb_ops; pagetable->pgtbl_ops =alloc_io_pgtable_ops (ARM_64_LPAE_S1 , - &ttbr0_cfg, iommu->domain); + &ttbr0_cfg, pagetable);if (!pagetable->pgtbl_ops) {kfree (pagetable);
@@ -279,6 +303,8 @@ struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent)/* Needed later for TLB flush */ pagetable->parent = parent; + pagetable->tlb = ttbr1_cfg->tlb; + pagetable->iommu_dev = ttbr1_cfg->iommu_dev; pagetable->pgsize_bitmap = ttbr0_cfg.pgsize_bitmap; pagetable->ttbr = ttbr0_cfg.arm_lpae_s1_cfg.ttbr;