Re: [PATCH v4 04/25] dmaengine: sdxi: Prepare function and sanitize MMIO state
From: Frank Li
Date: Thu Nov 12 2026 - 16:49:11 EST
On Tue, Nov 03, 2026 at 08:49:45PM -0600, Nathan Lynch via B4 Relay wrote:
> From: Nathan Lynch <nathan.lynch@xxxxxxx>
>
> Recover an inherited function state using bounded native stop/reset
> transitions and a PCI function reset that saves and restores PCI
> configuration. Use the locked reset API because probe and removal hold
> the device lock. If reset fails, disable bus mastering and wait
> for pending transactions as a best-effort fallback.
>
> Disable inherited error logging before stop commands can provoke errors.
> After stopping, sanitize writable configuration in Chapter 9 order:
> preserve the function group ID, clear PASID and interrupt enables,
> restore CTL2 reset limits with operation groups disabled, discard stale
> context and supported RKey tables, and clear error-log state. Disable
> mailbox interrupts only on functions with SR-IOV mailbox support.
>
> Keep mailbox commands and peer-owned payloads untouched. Status cleanup
> uses the specified write-one-to-clear semantics. Invoke preparation
> before feature configuration or publishing new DMA control structures.
>
> Co-developed-by: Wei Huang <wei.huang2@xxxxxxx>
> Signed-off-by: Wei Huang <wei.huang2@xxxxxxx>
> Signed-off-by: Nathan Lynch <nathan.lynch@xxxxxxx>
> ---
...
> +
> +/* Drive the function to GSV_STOP from any state. */
> +static int sdxi_dev_stop(struct sdxi_dev *sdxi)
> +{
> + unsigned long stepped_from = 0;
> + enum sdxi_fn_gsv gsv;
> +
> + /*
> + * Each step must reach a state we have not already stepped from.
> + * The table admits no cycles, so revisiting one means the device
> + * is not behaving as specified.
> + */
> + for (gsv = sdxi_dev_gsv(sdxi); gsv != SDXI_GSV_STOP; ) {
> + const struct gsv_stop_step *step;
> + enum sdxi_fn_gsv from = gsv;
> +
> + if ((size_t)gsv >= ARRAY_SIZE(gsv_stop_steps))
> + break;
> + if (stepped_from & BIT(gsv))
> + break;
> + stepped_from |= BIT(gsv);
BIT_ULL()?
Frank