Skip to content

iommu/amd: Improve updates, GCR3 teardown, and completions

Vasant Hegde linux-iommu 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 0 repliesNew
  2. v17 patches 1 replySuperseded

Changes in v2 from the cover letter

- Rebased on top of v7.4-rc3
- Addressed AI review comments

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7iommu/amd: Drop redundant flushes when the page table top changesdrivers/iommu/amd/iommu.c+5 -80 replies
2/7iommu/amd: Fix page-counter drift in multi-level GCR3 table teardowndrivers/iommu/amd/iommu.c+5 -30 replies
3/7iommu/amd: Do not allocate GCR3 tables when clearing a PASIDdrivers/iommu/amd/iommu.c+2 -20 replies
4/7iommu/amd: Allocate the completion sequence after queueing commandsdrivers/iommu/amd/iommu.c+23 -270 replies
5/7iommu/amd: Free the level-1 tables of a two-level GCR3 tabledrivers/iommu/amd/iommu.c+1 -00 replies
6/7iommu/amd: Update device attach state only after a successful attachdrivers/iommu/amd/iommu.c+5 -30 replies
7/7iommu/amd: Write the DTE under the domain lock on attach and detachdrivers/iommu/amd/iommu.c+9 -60 replies

Reviews trailers per patch

1 of 7 patches has a Reviewed-by or Acked-by.

PatchAnkit Soni
1/7
2/7
3/7
4/7R-b
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/7] iommu/amd: Improve updates, GCR3 teardown, and completions

Various enhancement to command completion handling, fix page accounting issue, remove redundant dte flush, etc.

- attach_device() publishes a device on dev_list under the domain lock, then writes the DTE after dropping it. change_top() and dirty tracking walk that list under the same lock, so the new DTE can store a stale page-table root or drop the HDAT bit. detach_device() clears the DTE before taking the lock, and a concurrent walk can make the entry valid again. Hold the domain lock across both the list update and the DTE write. defer_attach and use_vapic are updated only after attach succeeds. change_top() no longer repeats the alias clone and DTE flush that set_dte_entry() already performs.

- GCR3 intermediate pages were allocated with get_zeroed_page() and freed with iommu_free_pages(), so the IOMMU page counters drift on teardown. Allocate them with iommu_alloc_pages_node_sz() on the IOMMU node. A clear does not allocate a missing intermediate table, and a two-level table frees its level-1 pages as well as the leaves.

- iommu_flush_irt_and_complete() reserved a completion-wait sequence before the invalidate commands were queued, and dropped it if queueing failed. Reserve the sequence only after those commands are queued.

This series is made with the help of AI (Cursor).

Full series including other cleanup is available at :
https://github.com/AMDESE/linux-iommu/tree/iommu_code_audit_7.4_v1

Changes since v1:
- Rebased on top of v7.4-rc3
- Addressed AI review comments

v1: https://lore.kernel.org/linux-iommu/[email protected]/

Vasant Hegde (7):
iommu/amd: Drop redundant flushes when the page table top changes iommu/amd: Fix page-counter drift in multi-level GCR3 table teardown iommu/amd: Do not allocate GCR3 tables when clearing a PASID iommu/amd: Allocate the completion sequence after queueing commands iommu/amd: Free the level-1 tables of a two-level GCR3 table iommu/amd: Update device attach state only after a successful attach iommu/amd: Write the DTE under the domain lock on attach and detach

 drivers/iommu/amd/iommu.c | 97 ++++++++++++++++++++-------------------
 1 file changed, 49 insertions(+), 48 deletions(-)
Signature · 1 line
2.31.1