Re: [PATCH v2 4/5] kdump: wait for DMA to finish when using CMA

From: Jiri Bohac
Date: Tue Mar 11 2025 - 08:00:37 EST


On Mon, Mar 03, 2025 at 10:02:38AM +0800, Baoquan He wrote:
> On 02/20/25 at 05:55pm, Jiri Bohac wrote:
> > +static void crash_cma_clear_pending_dma(void)
> > +{
> > + if (!crashk_cma_cnt)
> > + return;
> > +
> > + mdelay(CMA_DMA_TIMEOUT_MSEC);
> > +}
> > +
> > /*
> > * No panic_cpu check version of crash_kexec(). This function is called
> > * only when panic_cpu holds the current CPU number; this is the only CPU
> > @@ -116,6 +125,7 @@ void __noclone __crash_kexec(struct pt_regs *regs)
> > if (kexec_crash_image) {
> > struct pt_regs fixed_regs;
> >
> > + crash_cma_clear_pending_dma();
>
> This could be too ideal, I am not sure if it's a good way. When crash
> triggered, we need do the urgent and necessary thing as soon as
> possible, then shutdown all CPU to avoid further damage. This one second
> of waiting could give the strayed system too much time. My personal
> opinion.

Good point! I think it makes sense to move the call to crash_cma_clear_pending_dma()
past the call of machine_crash_shutdown where all the shutdown
happens, like this:

> > crash_setup_regs(&fixed_regs, regs);
> > crash_save_vmcoreinfo();
> > machine_crash_shutdown(&fixed_regs);

+ crash_cma_clear_pending_dma();

I'll post a v3 with this change included.

--
Jiri Bohac <jbohac@xxxxxxx>
SUSE Labs, Prague, Czechia