NetBSD Problem Report #53834

From www@NetBSD.org  Fri Jan  4 20:51:14 2019
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 336CA7A166
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  4 Jan 2019 20:51:14 +0000 (UTC)
Message-Id: <20190104205113.153CA7A1E8@mollari.NetBSD.org>
Date: Fri,  4 Jan 2019 20:51:13 +0000 (UTC)
From: tnn@NetBSD.org
Reply-To: tnn@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: drm2 DMA fd allocation issue
X-Send-Pr-Version: www-1.0

>Number:         53834
>Category:       kern
>Synopsis:       drm2 DMA fd allocation issue
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    riastradh
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 04 20:55:00 +0000 2019
>Closed-Date:    Fri Jan 04 23:03:59 +0000 2019
>Last-Modified:  Fri Jan 04 23:05:01 +0000 2019
>Originator:     Tobias Nygren
>Release:        current
>Organization:
NetBSD
>Environment:
NetBSD drmdev 8.99.30 NetBSD 8.99.30 (GENERIC.drmdev-debug) #6: Fri Jan  4 20:01:54 UTC 2019  root@drmdev:/usr/src/sys/arch/amd64/compile/GENERIC.drmdev-debug amd64
>Description:
sys/external/bsd/drm2/linux/linux_dma_buf.c:dma_buf_fd() does
a fd_putfile() on a file descriptor newly allocated with fd_allocfile() with the refcnt set to 0.

This causes Xorg with radeondrm to be wedged in unkillable state or a kernel diagnostic assertion with a debug kernel:

panic: kernel diagnostic assertion "(ff->ff_refcnt & FR_MASK) > 0
" failed: file "../../../../kern/kern_descrip.c", line 433
vpanic() at netbsd:vpanic+0x16f
ch_voltag_convert_in() at netbsd:ch_voltag_convert_in
fd_putfile() at netbsd:fd_putfile+0x10f
linux_dma_buf_fd() at netbsd:linux_dma_buf_fd+0x96
drm_gem_prime_handle_to_fd() at netbsd:drm_gem_prime_handle_to_fd
+0x9b
drm_ioctl() at netbsd:drm_ioctl+0x23b

>How-To-Repeat:
Try to use an AMD R9 GPU that I bought ~5 years ago which has been sitting in it's box ever since because I couldn't get it to work back then.
>Fix:
I just deleted the call to fd_putfile() and now Xorg starts and glxgears works. Maybe it needs some refcnt things added too?

Index: linux_dma_buf.c
===================================================================
RCS file: /cvsroot/src/sys/external/bsd/drm2/linux/linux_dma_buf.c,v
retrieving revision 1.4
diff -p -u -r1.4 linux_dma_buf.c
--- linux_dma_buf.c	27 Aug 2018 15:25:13 -0000	1.4
+++ linux_dma_buf.c	4 Jan 2019 20:43:40 -0000
@@ -119,7 +119,6 @@ dma_buf_fd(struct dma_buf *dmabuf, int f
 	fd_set_exclose(curlwp, fd, (flags & O_CLOEXEC) != 0);
 	fd_affix(curproc, file, fd);

-	fd_putfile(fd);
 	ret = fd;
 out0:	return ret;
 }

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->riastradh
Responsible-Changed-By: tnn@NetBSD.org
Responsible-Changed-When: Fri, 04 Jan 2019 20:58:40 +0000
Responsible-Changed-Why:
Please have a look at this one.


From: Jason Thorpe <thorpej@me.com>
To: "gnats-bugs@netbsd.org" <gnats-bugs@NetBSD.org>
Cc: kern-bug-people@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: kern/53834: drm2 DMA fd allocation issue
Date: Fri, 4 Jan 2019 13:15:53 -0800

 > On Jan 4, 2019, at 12:55 PM, tnn@netbsd.org <tnn@NetBSD.org> wrote:
 >=20
 > I just deleted the call to fd_putfile() and now Xorg starts and =
 glxgears works. Maybe it needs some refcnt things added too?

 I believe simply removing fd_putfile() is all that's needed to fix this.

 -- thorpej

State-Changed-From-To: open->closed
State-Changed-By: tnn@NetBSD.org
State-Changed-When: Fri, 04 Jan 2019 23:03:59 +0000
State-Changed-Why:
fix was committed


From: "Tobias Nygren" <tnn@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53834 CVS commit: src/sys/external/bsd/drm2/linux
Date: Fri, 4 Jan 2019 23:03:02 +0000

 Module Name:	src
 Committed By:	tnn
 Date:		Fri Jan  4 23:03:02 UTC 2019

 Modified Files:
 	src/sys/external/bsd/drm2/linux: linux_dma_buf.c

 Log Message:
 dma_buf_fd(): fd_putfile() does not belong here

 PR kern/53834 ok riastradh@


 To generate a diff of this commit:
 cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/linux/linux_dma_buf.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.