Bug 76879

Summary: drm.ko PCI vendor/device id detection is broken
Product: Base System Reporter: Alexei Khalimov <lesha>
Component: kernAssignee: Eric Anholt <anholt>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.3-RELEASE   
Hardware: Any   
OS: Any   

Description Alexei Khalimov 2005-01-31 04:40:22 UTC
During drm_probe vendor and device ids are messed up.

------------ [from drm_drv.c] ------------
if (!strcmp(device_get_name(dev), "drmsub"))
                pciid = pci_get_devid(device_get_parent(dev));
        else
                pciid = pci_get_devid(dev);

        vendor = (pciid & 0x0000ffff);
        device = (pciid & 0xffff0000) >> 16;
------------
This returns trash instead of real vendor/device ids for probed hardware.

Why not to use  pci_get_vendor(dev)  and  pci_get_device(dev) ??

p.s. I'm totally lame, but curious.  ;)

Fix: 

vendor = (pciid & 0x0000ffff);
        device = (pciid & 0xffff0000) >> 16;
+
+ // override
+         vendor = pci_get_vendor(dev);
+         device = pci_get_device(dev);

        s = drm_find_description(vendor, device, idlist);
        if (s != NULL) {


--------
after this patch:
drmsub1: <Intel i852GM/i855GM GMCH> mem 0xd0080000-0xd00fffff,0xe0000000-0xe7ffffff at device 2.1 on pci0
info: [drm] AGP at 0xd8000000 128MB
info: [drm] Initialized i915 1.2.0 20041217 on minor 1--PaOa6QsRykJX2iuY0oeOQL5v5HJlolblK4P1ER2ezURqwtEd
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

*** drm_drv.c.org       Mon Jan 31 07:14:19 2005
--- drm_drv.c   Mon Jan 31 07:16:19 2005
*************** int drm_probe(device_t dev, drm_pci_id_l
*** 150,155 ****
--- 150,159 ----
How-To-Repeat: Install DRI port and see that your i915 is not detected/working 
;)
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2005-02-01 06:49:55 UTC
Responsible Changed
From-To: freebsd-ports-bugs->anholt

Over to maintainer.
Comment 2 Eric Anholt 2005-02-13 00:20:08 UTC
I tried your fix, as I've been wanting to get i915 to work for a long
time, but it didn't work.  I got three drmsub1 (why 1?  devinfo -v shows
a drmsub0) probes, for the ac97, the smbus, and the ehci controller, but
none for the GMCH.  Chipset is an i845 with integrated graphics.

-- 
Eric Anholt                                eta@lclark.edu          
http://people.freebsd.org/~anholt/         anholt@FreeBSD.org
Comment 3 Eric Anholt freebsd_committer freebsd_triage 2005-04-14 02:48:38 UTC
State Changed
From-To: open->closed

Committed with DRM update to -current.  Still doesn't get i915 working, but 
covers the issue brought up.