On 11/10/2026 10:46 PM, Kuehling, Felix wrote:
...
>>> + * @checkpoint_ts: IH ring timestamp captured on unmap, used to drop
>>> stale
>>> + * faults.
>>> + * @default_granularity: Default range granularity.
>>> + * @xnack_enabled: Whether retry (XNACK) faults are enabled.
>>> + * @invalidate_ranges: Callback of the MMU notifier invalidate event.
>>> + */
>>> +struct amdgpu_svm {
>>> + struct drm_gpusvm gpusvm;
>>> + struct kref refcount;
>>> + struct amdgpu_device *adev;
>>> + struct amdgpu_vm *vm;
>>> + struct amdgpu_svm_attr_tree *attr_tree;
>>> + struct rw_semaphore svm_lock;
>>> + spinlock_t work_lock;
>>> + struct amdgpu_svm_gc gc;
>>> + atomic_t exiting;
>>> + uint64_t checkpoint_ts;
>> By now we have figured out that TS in faults are not useable for fault
>> handling.
>>
>> Background is that they reset from time to time because of GFXOFF and
>> may vary depending on the engine who sends the fault.
>>
>> Adding Timur from Valve on CC, he send out a patch to completely
>> remove the existing timestamp handling from the fault filter.
>>
>> We need to come up with a different approach here.
>
> At least for the fault filter that shouldn't be a big problem. We don't
> need the SW fault filter on any GPU that has a CAM. That should be any
> GPU that supports retry faults starting with Vega20. AFAIK the only GPUs
> that still need the SW fault filter are Vega10 and Raven. If the
> timestamps work on those, we're fine. If there are any newer GPUs left
> that don't enable the CAM for whatever reason, let's fix that instead.
>
> Regards,
> Felix
Hi Christian and Felix,
I totally remoed the ts check in amdgpu drm svm fault, following is
diff, is that looks valid for you?
diff:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_fault.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_fault.c
index d95ac3651..15d8da7ea 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_fault.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_fault.c
@@ -31,7 +31,6 @@
#include "amdgpu.h"
#include "amdgpu_vm.h"
#include "amdgpu_gmc.h"
-#include "amdgpu_ih.h"
#include "amdgpu_trace.h"
#include <drm/drm_exec.h>
@@ -358,18 +357,16 @@ static int fault_map_range(struct amdgpu_svm *svm,
* @adev: The amdgpu device.
* @pasid: PASID of the faulting context.
* @fault_page: Faulting page index.
- * @ts: IH ring timestamp of the fault.
* @write_fault: True if the fault was caused by a write.
*
* Entry point from the VM fault path. Look up the SVM context, drop the
- * fault if the context is gone/exiting or the mm is dying, filter stale
- * retry faults using the checkpoint timestamp, then resolve the covering
+ * fault if the context is gone/exiting or the mm is dying, then
resolve the covering
* attribute range (creating a default one if needed) and map it.
*
* Return: 0 on success or a dropped fault, negative error code on
failure.
*/
int amdgpu_svm_handle_fault(struct amdgpu_device *adev, uint32_t pasid,
- uint64_t fault_page, uint64_t ts,
+ uint64_t fault_page,
bool write_fault)
{
struct amdgpu_svm *svm;
@@ -378,7 +375,6 @@ int amdgpu_svm_handle_fault(struct amdgpu_device
*adev, uint32_t pasid,
unsigned long attr_start_page, attr_last_page;
uint64_t fault_addr = fault_page << PAGE_SHIFT;
struct mm_struct *mm = NULL;
- uint64_t ckpt;
int ret;
if (amdgpu_in_reset(adev))
@@ -414,21 +410,6 @@ int amdgpu_svm_handle_fault(struct amdgpu_device
*adev, uint32_t pasid,
goto out_put;
}
- ckpt = READ_ONCE(svm->checkpoint_ts);
- if (ckpt != 0) {
- if (amdgpu_ih_ts_after_or_equal(ts, ckpt)) {
- pr_debug(
- "draining stale retry fault, drop fault 0x%llx ts=%llu
checkpoint=%llu\n",
- fault_addr, ts, ckpt);
- amdgpu_gmc_filter_faults_remove(
- adev, fault_page, pasid);
- ret = 0;
- goto out_put;
- } else {
- WRITE_ONCE(svm->checkpoint_ts, 0);
- }
- }
-
amdgpu_svm_lock(svm);
mutex_lock(&svm->attr_tree->lock);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_fault.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_fault.h
index c169a9660..15c3915bd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_fault.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_fault.h
@@ -33,7 +33,7 @@ struct amdgpu_svm_attr_range;
struct amdgpu_svm_attrs;
int amdgpu_svm_handle_fault(struct amdgpu_device *adev, uint32_t pasid,
- uint64_t fault_page, uint64_t ts,
+ uint64_t fault_page,
bool write_fault);
#endif /* __AMDGPU_SVM_FAULT_H__ */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.c
index 627b61c7e..f552725f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_svm_range.c
@@ -758,39 +758,6 @@ void amdgpu_svm_range_unqueue(struct amdgpu_svm *svm,
drm_gpusvm_range_put(&range->base);
}
-/**
- * amdgpu_svm_capture_checkpoint_ts() - Record the IH ring write
pointer time
- * @svm: The SVM context.
- *
- * Capture the timestamp of the most recent interrupt handler write pointer
- * into @svm->checkpoint_ts. Retry faults whose timestamp predates this
- * checkpoint are stale and are dropped by the fault handler.
- */
-void amdgpu_svm_capture_checkpoint_ts(struct amdgpu_svm *svm)
-{
- struct amdgpu_device *adev = svm->adev;
- struct amdgpu_ih_ring *ih;
- uint32_t checkpoint_wptr;
-
- if (!adev->irq.retry_cam_enabled && adev->irq.ih1.ring_size) {
- ih = &adev->irq.ih1;
- checkpoint_wptr = amdgpu_ih_get_wptr(adev, ih);
- if (ih->rptr != checkpoint_wptr) {
- WRITE_ONCE(svm->checkpoint_ts,
- amdgpu_ih_decode_iv_ts(adev, ih,
- checkpoint_wptr, -1));
- return;
- }
- }
-
- ih = &adev->irq.ih_soft;
- checkpoint_wptr = amdgpu_ih_get_wptr(adev, ih);
- if (ih->rptr != checkpoint_wptr)
- WRITE_ONCE(svm->checkpoint_ts,
- amdgpu_ih_decode_iv_ts(adev, ih,
- checkpoint_wptr, -1));
-}
-
/**
* amdgpu_svm_range_invalidate() - MMU notifier invalidate_ranges callback
* @svm: The SVM context.
@@ -802,8 +769,7 @@ void amdgpu_svm_capture_checkpoint_ts(struct
amdgpu_svm *svm)
*
* Dispatch the two phase notifier handling across every range in
* [@adj_start, @adj_end): run the begin phase for all ranges, then
- * the end phase. On an unmap event, also capture a checkpoint timestamp
- * so stale retry faults can be filtered.
+ * the end phase.
*/
void amdgpu_svm_range_invalidate(struct amdgpu_svm *svm,
struct drm_gpusvm_notifier *notifier,
@@ -814,9 +780,6 @@ void amdgpu_svm_range_invalidate(struct amdgpu_svm *svm,
struct drm_gpusvm_range *r;
bool needs_flush = false;
- if (mmu_range->event == MMU_NOTIFY_UNMAP)
- amdgpu_svm_capture_checkpoint_ts(svm);
-
r = first;
drm_gpusvm_for_each_range(r, notifier, adj_start, adj_end)
needs_flush |= amdgpu_svm_range_notifier_event_begin(svm, r,
Regards,
Honglei
>
>
>>
>>> + u8 default_granularity;
>>> + bool xnack_enabled;
>> It's probably ok to have that here for now, but that will become a VM
>> property in the future I think.
>>
>>> + void (*invalidate_ranges)(struct amdgpu_svm *svm,
>>> + struct drm_gpusvm_notifier *notifier,
>>> + const struct mmu_notifier_range *mmu_range,
>>> + struct drm_gpusvm_range *first,
>>> + uint64_t adj_start, uint64_t adj_end);
>> That looks a bit questionable. Why is that a pointer inside the
>> amdgpu_svm structure?
>>
>> Apart from those questions that looks rather reasonable.
>>
>> Regards,
>> Christian.
...