From nobody Wed Jun 16 18:10:11 2021 X-Original-To: current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DCEC111C8148 for ; Wed, 16 Jun 2021 18:10:17 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4G4tWs5HK7z4t4K; Wed, 16 Jun 2021 18:10:17 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [178.17.145.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 71416260360; Wed, 16 Jun 2021 20:10:14 +0200 (CEST) Subject: Re: Kernel/driver hacking: panic: Assertion vm_object_busied((m->object)) failed at /usr/src/sys/vm/vm_page.c:5455 To: Neel Chauhan Cc: current@freebsd.org, Jeff Roberson References: From: Hans Petter Selasky Message-ID: Date: Wed, 16 Jun 2021 20:10:11 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4G4tWs5HK7z4t4K X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N 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