Bug 56297

Summary: Agp problem for intel chipsets ? DRM and
Product: Base System Reporter: Angelescu Ovidiu <mrhsaacdoh>
Component: kernAssignee: Eric Anholt <anholt>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.8-STABLE   
Hardware: Any   
OS: Any   

Description Angelescu Ovidiu 2003-09-02 05:50:00 UTC
After FreeBSD > 4.6.2-p13 system crash at the second
,third or fourth
restart of
X Server when DRI and DRM are activated for Ati Radeon
VE QY video
card.
I have noticed that at the restarting of X sever on my
screen apears
images from my previous X session even i have changed
the windowmanager
from
.xinitrc.

Fix: 

It seems that problem is due to code from function
agp_intel_flush_tlb(device_tdev)  wich is in 
/sys/pci/agp_intel.c.
In FreeBSD < 4.7 it was
  agp_intel_flush_tlb(device_t dev)
{
        pci_write_config(dev, AGP_INTEL_AGPCTRL,
0x2200, 4);
        pci_write_config(dev, AGP_INTEL_AGPCTRL,
0x2280, 4);
}
In FreeBSD> 4.6.2-p13
agp_intel_flush_tlb(device_t dev)
{
        u_int32_t val;
        val = pci_read_config(dev, AGP_INTEL_AGPCTRL,
4);
        pci_write_config(dev, AGP_INTEL_AGPCTRL,val &
~(1 << 8)  , 4);
        pci_write_config(dev, AGP_INTEL_AGPCTRL, val ,
4);
}.
After i have inspected agp code for intel chipsets in
NetBSD-1.6 ,
OpenBSD-3.2
and Linux i have noticed that:
In OpenBSD and NetBSD is used a code similar from
FreeBSD <= 4.6.2-p13.
In Linux it is used a code similar with FreeBSD>
4.6.2-p13 with a
little
diference:
In Linux instead of variabile val & ~(1 << 8) it is
used val & ~(1 <<
7) at the
first invocation
of function pci_write_config and at the second
invocation it is used
val | (1 <<7) instead of val used in FreeBSD.
To fix the problem it seems to be  three posibilities:

1) The use of the old FreeBSD code for
agp_intel_flush_tlb(device_t
dev)
but i don't know if it works for all chipsets. 
agp_intel_flush_tlb(device_t dev)
{
        pci_write_config(dev, AGP_INTEL_AGPCTRL,
0x2200, 4);
        pci_write_config(dev, AGP_INTEL_AGPCTRL,
0x2280, 4);
}

2) The use of the code from FreeBSD > 4.6.2-p13 with a
minor
modification
where we write 7 instead of 8 in val & ~(1 << 8) at
the first
invocation of pci_
write_config

agp_intel_flush_tlb(device_t dev)
{
        u_int32_t val;
        val = pci_read_config(dev, AGP_INTEL_AGPCTRL,
4);
        pci_write_config(dev, AGP_INTEL_AGPCTRL,val &
~(1 << 7)  , 4);
        pci_write_config(dev, AGP_INTEL_AGPCTRL, val ,
4);
}

 3) The use of the Linux code adapted for FreeBSD

agp_intel_flush_tlb(device_t dev)
{
        u_int32_t val;
        val = pci_read_config(dev, AGP_INTEL_AGPCTRL,
4);
        pci_write_config(dev, AGP_INTEL_AGPCTRL, val &
~(1 << 7), 4);
        val = pci_read_config(dev, AGP_INTEL_AGPCTRL,
4);
        pci_write_config(dev, AGP_INTEL_AGPCTRL, val |
(1 << 7), 4);
}.
With any of these modifications all works well on my
motherboard.
I haven't tested that for other motherboards or
chipsets because
i have only one Computer.
Hope it helps !


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
How-To-Repeat: Install drm-kmod from ports or compile it in Kernel
for FReeBSD >=4.8.
Install and configure X Server to use DRI.
Start X Server once , exit and restart several times X
Server.
Comment 1 Eric Anholt freebsd_committer freebsd_triage 2003-09-17 04:21:34 UTC
State Changed
From-To: open->patched

Patch committed to -current, submitted to re@. 


Comment 2 Eric Anholt freebsd_committer freebsd_triage 2003-09-17 04:21:34 UTC
Responsible Changed
From-To: freebsd-bugs->anholt

Patch committed to -current, submitted to re@.
Comment 3 Eric Anholt freebsd_committer freebsd_triage 2003-09-17 07:57:25 UTC
State Changed
From-To: patched->closed

MFCed.  Thanks for an excellent PR!