From nobody@FreeBSD.org  Sun Jul 15 08:12:02 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 76BFD1065673
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 15 Jul 2012 08:12:02 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 47DB28FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 15 Jul 2012 08:12:02 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q6F8C1ik086229
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 15 Jul 2012 08:12:01 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q6F8C1aQ086228;
	Sun, 15 Jul 2012 08:12:01 GMT
	(envelope-from nobody)
Message-Id: <201207150812.q6F8C1aQ086228@red.freebsd.org>
Date: Sun, 15 Jul 2012 08:12:01 GMT
From: Archibald <archibald@ethernull.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: vesa on 9-BETA1/Xorg 7.7 with radeon 6450 causes segfault
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169875
>Category:       ports
>Synopsis:       x11/xorg: vesa on 9-BETA1/Xorg 7.7 with radeon 6450 causes segfault
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-x11
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 15 08:20:09 UTC 2012
>Closed-Date:    Tue Apr 16 10:05:56 UTC 2013
>Last-Modified:  Tue Apr 16 10:05:56 UTC 2013
>Originator:     Archibald
>Release:        9.1-BETA with CFT Xorg 7.7
>Organization:
>Environment:
FreeBSD collossus 9.1-BETA1 FreeBSD 9.1-BETA1 #1: Sat Jul 14 19:21:50 CEST 2012     root@collossus:/usr/obj/usr/src/sys/XONAR  amd64

(XONAR is GENERIC but with the sound drivers removed)
>Description:
I run 9.1-BETA, updated to the Xorg 7.7 CFT branch, merged with my ports tree using the xorgmerge script and rebuilt my ports as directing in the CFT. I am using an AMD Radeon HD 6450 and the amd64 architecture.

I receive the error "Segmentation fault: 11 at address 0x0" when I try to start X (using startx, xdm or X). The log file indicates that my GPU is only supported with kernel modesetting and that it is falling back to vesa. This occurs with no xorg.conf and with an xorg.conf specifying the vesa driver.

On the advice of the #freebsd-help IRC channel I built a kernel without the line "options VESA" and tried to run X by manually loading the module with kldload and then trying the above methods (startx, xdm and X) but received the same errors.

I have complete versions of my dmesg, Xorg.0.log and output of pkg_info available if these would be helpful.

Notable lines from /var/log/Xorg.0.log:

[   604.164] (II) VESA: driver for VESA chipsets: vesa
[   604.165] (--) Using syscons driver with X support (version 2.0)
[   604.165] (--) using VT number 9

[   604.166] (II) [KMS] drm report modesetting isn't supported.
[   604.166] (II) GPU only supported with KMS, using vesa instead.
[   604.167] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
[   604.167] (II) Loading sub module "vbe"
[   604.167] (II) LoadModule: "vbe"
[   604.168] (II) Loading /usr/local/lib/xorg/modules/libvbe.so
[   604.169] (II) Module vbe: vendor="X.Org Foundation"
[   604.170] 	compiled for 1.12.2, module version = 1.1.0
[   604.170] 	ABI class: X.Org Video Driver, version 12.0
[   604.170] (II) Loading sub module "int10"
[   604.170] (II) LoadModule: "int10"
[   604.171] (II) Loading /usr/local/lib/xorg/modules/libint10.so
[   604.172] (II) Module int10: vendor="X.Org Foundation"
[   604.172] 	compiled for 1.12.2, module version = 1.0.0
[   604.172] 	ABI class: X.Org Video Driver, version 12.0
[   604.172] (II) VESA(1): initializing int10
[   604.175] Segmentation fault: 11 at address 0x0
[   604.176] 
Fatal server error:
[   604.176] Caught signal 11 (Segmentation fault: 11). Server aborting

>How-To-Repeat:
Run startx, xdm or X.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->freebsd-x11 
Responsible-Changed-By: crees 
Responsible-Changed-When: Sun Jul 15 08:37:44 UTC 2012 
Responsible-Changed-Why:  
Over to maintainers 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169875 

From: Mark Linimon <linimon@lonesome.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/169875: vesa on 9-BETA1/Xorg 7.7 with radeon 6450 causes
 segfault
Date: Wed, 18 Jul 2012 12:54:34 -0500

 ----- Forwarded message from archibald <archibald@ethernull.org> -----
 
 Date: Wed, 18 Jul 2012 18:05:25 +0100
 From: archibald <archibald@ethernull.org>
 To: freebsd-ports-bugs@freebsd.org
 Cc: freebsd-x11@freebsd.org
 Subject: Re: ports/169875: vesa on 9-BETA1/Xorg 7.7 with radeon 6450 causes
 	segfault
 User-Agent: Roundcube Webmail/0.7.2
 
 As a follow-up to this, I updated to 9.1-PRERELEASE yesterday (and
 updated my ports tree), merged the Xorg development branch,
 rebuilt my ports and exactly the same errors occur.
 
 Is there any additional information I could provide that would
 be useful in tracking this down?
 
 archibald
 _______________________________________________
 freebsd-ports-bugs@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-ports-bugs
 To unsubscribe, send any mail to "freebsd-ports-bugs-unsubscribe@freebsd.org"
 
 
 ----- End forwarded message -----

From: John Wehle <john@feith.com>
To: bug-followup@FreeBSD.org
Cc: archibald@ethernull.org
Subject: Re: ports/169875: x11/xorg: vesa on 9-BETA1/Xorg 7.7 with radeon 6450 causes segfault
Date: Tue, 16 Apr 2013 00:25:42 -0400 (EDT)

 I encountered a similar problem using a Radeon 7850 after upgrading from
 xorg-server-1.11.4 to xorg-server-1.12.4.
 
 Tracing through the code shows the problem is caused by libpciaccess
 missing routines for implementing legacy I/O on FreeBSD.  xorg-server-1.12.4
 passes a quick smoke test once the enclosed patch is applied to libpciaccess
 0.13.1.
 
 I've only tested this fix an i386 platform.
 
 I've also submitted this issue upstream as:
 
   https://bugs.freedesktop.org/show_bug.cgi?id=63583
 
 -- John
 ------------------------8<------------------------------8<---------------
 --- src/freebsd_pci.c.ORIGINAL	2012-04-09 13:02:57.000000000 -0400
 +++ src/freebsd_pci.c	2013-04-15 23:35:33.000000000 -0400
 @@ -561,6 +561,92 @@
      freebsd_pci_sys = NULL;
  }
  
 +#if defined(__i386__) || defined(__amd64__)
 +#include <machine/cpufunc.h>
 +#include <machine/sysarch.h>
 +
 +static struct pci_io_handle *
 +pci_device_freebsd_open_legacy_io(struct pci_io_handle *ret,
 +    struct pci_device *dev, pciaddr_t base, pciaddr_t size)
 +{
 +
 +	if (i386_set_ioperm (base, size, 1) != 0)
 +		return NULL;
 +
 +	ret->base = base;
 +	ret->size = size;
 +	return ret;
 +}
 +
 +static uint32_t
 +pci_device_freebsd_read32(struct pci_io_handle *handle, uint32_t reg)
 +{
 +	return inl(handle->base + reg);
 +}
 +
 +static uint16_t
 +pci_device_freebsd_read16(struct pci_io_handle *handle, uint32_t reg)
 +{
 +	return inw(handle->base + reg);
 +}
 +
 +static uint8_t
 +pci_device_freebsd_read8(struct pci_io_handle *handle, uint32_t reg)
 +{
 +	return inb(handle->base + reg);
 +}
 +
 +static void
 +pci_device_freebsd_write32(struct pci_io_handle *handle, uint32_t reg,
 +    uint32_t data)
 +{
 +	outl(handle->base + reg, data);
 +}
 +
 +static void
 +pci_device_freebsd_write16(struct pci_io_handle *handle, uint32_t reg,
 +    uint16_t data)
 +{
 +	outw(handle->base + reg, data);
 +}
 +
 +static void
 +pci_device_freebsd_write8(struct pci_io_handle *handle, uint32_t reg,
 +    uint8_t data)
 +{
 +	outb(handle->base + reg, data);
 +}
 +#endif
 +
 +static int
 +pci_device_freebsd_map_legacy(struct pci_device *dev, pciaddr_t base,
 +    pciaddr_t size, unsigned map_flags, void **addr)
 +{
 +	struct pci_device_mapping map;
 +	int err;
 +
 +	map.base = base;
 +	map.size = size;
 +	map.flags = map_flags;
 +	map.memory = NULL;
 +	err = pci_device_freebsd_map_range(dev, &map);
 +	*addr = map.memory;
 +
 +	return err;
 +}
 +
 +static int
 +pci_device_freebsd_unmap_legacy(struct pci_device *dev, void *addr,
 +    pciaddr_t size)
 +{
 +	struct pci_device_mapping map;
 +
 +	map.memory = addr;
 +	map.size = size;
 +	map.flags = 0;
 +	return pci_device_freebsd_unmap_range(dev, &map);
 +}
 +
  static const struct pci_system_methods freebsd_pci_methods = {
      .destroy = pci_system_freebsd_destroy,
      .destroy_device = NULL, /* nothing to do for this */
 @@ -571,6 +657,17 @@
      .read = pci_device_freebsd_read,
      .write = pci_device_freebsd_write,
      .fill_capabilities = pci_fill_capabilities_generic,
 +#if defined(__i386__) || defined(__amd64__)
 +    .open_legacy_io = pci_device_freebsd_open_legacy_io,
 +    .read32 = pci_device_freebsd_read32,
 +    .read16 = pci_device_freebsd_read16,
 +    .read8 = pci_device_freebsd_read8,
 +    .write32 = pci_device_freebsd_write32,
 +    .write16 = pci_device_freebsd_write16,
 +    .write8 = pci_device_freebsd_write8,
 +#endif
 +    .map_legacy = pci_device_freebsd_map_legacy,
 +    .unmap_legacy = pci_device_freebsd_unmap_legacy,
  };
  
  /**
 -------------------------------------------------------------------------
 |   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
 |    John Wehle    |     Fax: 1-215-540-5495  |                         |
 -------------------------------------------------------------------------
 
State-Changed-From-To: open->closed 
State-Changed-By: zeising 
State-Changed-When: Tue Apr 16 10:05:54 UTC 2013 
State-Changed-Why:  
This PR is for the FreeBSD xorg development repo, not the regular ports 
repo.  Also, the problem described therein is fixed since quite some 
time.  Close the PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169875 
>Unformatted:
