Re: Kernel/driver hacking: panic: Assertion vm_object_busied((m->object)) failed at /usr/src/sys/vm/vm_page.c:5455
Date: Wed, 16 Jun 2021 18:10:11 UTC
Hi Neel,
On 6/16/21 5:28 PM, Neel Chauhan wrote:
> Hi,
>
> On 2021-06-16 00:35, Hans Petter Selasky wrote:
>> Do you have the full backtrace?
>
> Yes.
>
> I have attached a stack trace in the previous email, but if you didn't
> get it, I have uploaded it to GitHub:
> https://gist.github.com/neelchauhan/437bd10239f84c563aafb37ab440029a
>
>> Doesn't this code work in the current DRM - kmod? What changed? Did
>> you perhaps miss a patch?
>
> I think there is new code with Linux 5.6 which changes how this is done.
>
> I have been attempting to make a FreeBSD equivalent, but it panics. It
> is **not** from missing Linux commits since I believe I added them all.
>
> The code in my GH repo:
> https://github.com/neelchauhan/drm-kmod/blob/5.7-wip/drivers/gpu/drm/i915/gem/i915_gem_mman.c#L346
>
I think the following changes are needed. CC'ing Jeff.
> for_each_sg_page(pages->sgl, &sg_iter, pages->nents, 0) {
> pmap_t pmap = vm_map_pmap(map);
> struct vm_page *pa = sg_page_iter_page(&sg_iter);
> VM_OBJECT_RLOCK(pa->object);
Try adding this:
vm_object_busy(pa->object);
> if (pmap_enter(pmap, va, pa, 0, flags, 0)) {
Try adding this:
vm_object_unbusy(pa->object);
VM_OBJECT_RUNLOCK(pa->object);
> err = -ENOMEM;
> break;
> }
Try adding this:
vm_object_unbusy(pa->object);
> VM_OBJECT_RUNLOCK(pa->object);
> va += PAGE_SIZE;
--HPS