NetBSD Problem Report #50067

From www@NetBSD.org  Mon Jul 20 04:00:22 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id AC953A6551
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 20 Jul 2015 04:00:22 +0000 (UTC)
Message-Id: <20150720040020.D5BC4A6555@mollari.NetBSD.org>
Date: Mon, 20 Jul 2015 04:00:20 +0000 (UTC)
From: davshao@gmail.com
Reply-To: davshao@gmail.com
To: gnats-bugs@NetBSD.org
Subject: x11/xf86-video-ati dports patch-src_radeon__kms.c for newer DragonFly and FreeBSD
X-Send-Pr-Version: www-1.0

>Number:         50067
>Category:       pkg
>Synopsis:       x11/xf86-video-ati dports patch-src_radeon__kms.c for newer DragonFly and FreeBSD
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 20 04:05:00 +0000 2015
>Closed-Date:    Thu Feb 02 18:58:06 +0000 2017
>Last-Modified:  Thu Feb 02 18:58:06 +0000 2017
>Originator:     David Shao
>Release:        pkgsrc current cvs
>Organization:
>Environment:
DragonFly  4.3-DEVELOPMENT DragonFly v4.2.2.63.ga2b9b7-DEVELOPMENT #1: Sun Jul 19 19:22:57 PDT 2015     xxxxx@:/usr/obj/usr/src/sys/X86_64_GENERIC  x86_64
>Description:
x11/xf86-video-ati can be patched using a patch from DragonFly dports so that KMS and other capabilities from newer DragonFly and FreeBSD Oses can be activated.  Unlike say NetBSD or OpenBSD, for DragonFly and FreeBSD the Radeon drm kernel modules are not necessarily loaded before Xorg is started using say startx.  

The following patch is from DragonFly dports master as of commit 4f04bfe0ea83ce09 ..., 
file x11-drivers/xf86-video-ati/files/patch-src__radeon_kms.c:

It has been tested on DragonFly 4.3-DEVELOPMENT x86_64 and FreeBSD 10.1 release amd64, using openbox and a patched xf86-input-mouse.  It also at least compiled and built successfully on NetBSD 6.99.20 amd64 X11_type=modular, and should have no affect on it.  The result for DragonFly and FreeBSD is the desired activation, as can be seen from Xorg.0.log:

[    61.049] (II) [KMS] Kernel modesetting enabled.
...
[    63.244] (II) RADEON(0): KMS Color Tiling: enabled
[    63.244] (II) RADEON(0): KMS Color Tiling 2D: enabled
[    63.244] (II) RADEON(0): KMS Pageflipping: enabled
[    63.244] (II) RADEON(0): SwapBuffers wait for vsync: enabled
[    63.319] (II) RADEON(0): Output VGA-0 has no monitor section
[    63.319] (II) RADEON(0): Output HDMI-0 has no monitor section
[    63.326] (II) RADEON(0): Output DVI-0 has no monitor section
[    63.400] (II) RADEON(0): EDID for output VGA-0
[    63.400] (II) RADEON(0): Manufacturer: VSC  Model: d427  Serial#: 16843009
[    63.400] (II) RADEON(0): Year: 2010  Week: 44
...
[    63.425] (II) RADEON(0): [DRI2] Setup complete
[    63.425] (II) RADEON(0): [DRI2]   DRI driver: r600
[    63.425] (II) RADEON(0): [DRI2]   VDPAU driver: r600
[    63.425] (II) RADEON(0): Front buffer size: 5120K
[    63.425] (II) RADEON(0): VRAM usage limit set to 462384K
[    63.440] (==) RADEON(0): Backing store enabled
[    63.440] (II) RADEON(0): Direct rendering enabled
[    63.440] (II) EXA(0): Driver allocated offscreen pixmaps
[    63.440] (II) EXA(0): Driver registered support for the following operations:
[    63.440] (II)         Solid
[    63.440] (II)         Copy
[    63.440] (II)         Composite (RENDER acceleration)
[    63.440] (II)         UploadToScreen
[    63.440] (II)         DownloadFromScreen
[    63.440] (II) RADEON(0): Acceleration enabled
[    63.441] (==) RADEON(0): DPMS enabled
...
[    63.444] (--) RandR disabled
[    63.833] (II) AIGLX: enabled GLX_MESA_copy_sub_buffer
[    63.833] (II) AIGLX: enabled GLX_ARB_create_context
[    63.833] (II) AIGLX: enabled GLX_ARB_create_context_profile
[    63.833] (II) AIGLX: enabled GLX_EXT_create_context_es2_profile
[    63.833] (II) AIGLX: enabled GLX_INTEL_swap_event
[    63.833] (II) AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control
[    63.833] (II) AIGLX: enabled GLX_EXT_framebuffer_sRGB
[    63.833] (II) AIGLX: enabled GLX_ARB_fbconfig_float
[    63.833] (II) AIGLX: GLX_EXT_texture_from_pixmap backed by buffer objects
[    63.834] (II) AIGLX: Loaded and initialized r600






>How-To-Repeat:

>Fix:
The following is the patch:

$NetBSD$

--- src/radeon_kms.c.orig	2014-10-02 03:31:27.000000000 +0000
+++ src/radeon_kms.c
@@ -30,6 +30,12 @@

 #include <errno.h>
 #include <sys/ioctl.h>
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+#include <sys/param.h>
+#include <sys/linker.h>
+#endif
+
 /* Driver data structures */
 #include "radeon.h"
 #include "radeon_reg.h"
@@ -280,7 +286,7 @@ static void
 radeon_dirty_update(ScreenPtr screen)
 {
 	RegionPtr region;
-	PixmapDirtyUpdatePtr ent;
+	PixmapDirtyUpdatePtr ent = NULL;

 	if (xorg_list_is_empty(&screen->pixmap_dirty_list))
 		return;
@@ -589,7 +595,11 @@ static int radeon_get_drm_master_fd(Scrn
 #endif
     struct pci_device *dev = info->PciInfo;
     char *busid;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+    int fd, err;
+#else
     int fd;
+#endif

 #ifdef XF86_PDEV_SERVER_FD
     if (pRADEONEnt->platform_dev) {
@@ -608,6 +618,17 @@ static int radeon_get_drm_master_fd(Scrn
 		      dev->domain, dev->bus, dev->dev, dev->func);
 #endif

+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+    err = kldload("radeonkms");
+    if (err == -1 && errno != EEXIST) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+        	"[drm] Failed to load kernel module for %s: %s\n",
+        	busid, strerror(errno));
+        free(busid);
+        return -1;
+    }
+#endif
+
     fd = drmOpen(NULL, busid);
     if (fd == -1)
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,

>Release-Note:

>Audit-Trail:
From: Thomas Klausner <wiz@NetBSD.org>
To: NetBSD bugtracking <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: pkg/50067: x11/xf86-video-ati dports patch-src_radeon__kms.c for
 newer DragonFly and FreeBSD
Date: Mon, 20 Jul 2015 11:33:35 +0200

 Do you have any idea if this has been included in upstream?
 I'd really like to avoid having new xorg patches in pkgsrc.
  Thomas

From: David Shao <davshao@gmail.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/50067: x11/xf86-video-ati dports patch-src_radeon__kms.c for
 newer DragonFly and FreeBSD
Date: Thu, 23 Jul 2015 20:29:45 -0700

 On Mon, Jul 20, 2015 at 2:35 AM, Thomas Klausner <wiz@netbsd.org> wrote:
 > The following reply was made to PR pkg/50067; it has been noted by GNATS.
 >
 > From: Thomas Klausner <wiz@NetBSD.org>
 > To: NetBSD bugtracking <gnats-bugs@NetBSD.org>
 > Cc:
 > Subject: Re: pkg/50067: x11/xf86-video-ati dports patch-src_radeon__kms.c for
 >  newer DragonFly and FreeBSD
 > Date: Mon, 20 Jul 2015 11:33:35 +0200
 >
 >  Do you have any idea if this has been included in upstream?
 >  I'd really like to avoid having new xorg patches in pkgsrc.
 >   Thomas

 I believe this patch, which is in DragonFly dports and FreeBSD ports,
 has no chance to be committed upstream.

 One huge problem is that DragonFly and FreeBSD 10.1 are not in step
 with almost any other OS in ease of loading the radeon kernel modules
 without such code, so why should upstream change the code for what it
 sees are laggards.

 Also the original radeon_kms.c file has no explicit OS conditional
 code, so it seems the developers have worked very hard to have the
 conditionals at most in the header or configure files.

 Nevertheless the patch is essential to have a reasonable user
 experience with a Radeon graphics card on either FreeBSD 10.1 or
 DragonFly.  (I have not tested pkgsrc with FreeBSD 10 stable or beyond
 which has Newcons.)

From: "Thomas Klausner" <wiz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50067 CVS commit: pkgsrc/x11/xf86-video-ati
Date: Thu, 2 Feb 2017 18:54:44 +0000

 Module Name:	pkgsrc
 Committed By:	wiz
 Date:		Thu Feb  2 18:54:44 UTC 2017

 Modified Files:
 	pkgsrc/x11/xf86-video-ati: Makefile distinfo
 Added Files:
 	pkgsrc/x11/xf86-video-ati/patches: patch-src_radeon__kms.c

 Log Message:
 Updated xf86-video-ati to 7.8.0nb1:

 Add patch from PR 50067 by David Shao, which comes from FreeBSD
 ports/Dragonfly overlay, to improve the situation on FreeBSD and
 Dragonfly.


 To generate a diff of this commit:
 cvs rdiff -u -r1.40 -r1.41 pkgsrc/x11/xf86-video-ati/Makefile
 cvs rdiff -u -r1.28 -r1.29 pkgsrc/x11/xf86-video-ati/distinfo
 cvs rdiff -u -r0 -r1.4 \
     pkgsrc/x11/xf86-video-ati/patches/patch-src_radeon__kms.c

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

State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Thu, 02 Feb 2017 18:58:06 +0000
State-Changed-Why:
Committed. Please work with upstream on integrating some version of it.

Thanks.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.