Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 May 2008 16:45:45 GMT
From:      Sergey Korsak <skif@1plus1.net>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   i386/123734: Chipset VIA CX700 requires extra initialization
Message-ID:  <200805161645.m4GGjjdL056847@www.freebsd.org>
Resent-Message-ID: <200805161650.m4GGo0T1043316@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         123734
>Category:       i386
>Synopsis:       Chipset VIA CX700 requires extra initialization
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-i386
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 16 16:50:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Sergey Korsak
>Release:        7.0-RELEASE
>Organization:
TV channel "Studio 1+1"
>Environment:
FreeBSD tiny.homenet 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 19:59:52 UTC 2008     root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
I had got mini PC eBox-4854 made by DMP Electronics Inc. ( http://www.compactpc.com.tw/ebox-4854.htm ) and found onboard NIC (Realtek 8100B) and mini-PCI Wi-Fi module didn't work with errors:
rl0: watchdog timeout
and
ath0: ath_chan_set: unable to reset channel ...
Booting FreeBSD on another eBox-4854, playing with BIOS and sysctl settings, switching  ACPI/APIC and compiling custom kernels didn't help.
OpenBSD 4.3 experienced the same problems.
But in Linux (fc7) both devices worked OK.
This box uses VIA CX700M chipset, so I grep-ped linux kernel sources and found interesting piece of code:

/*
 * Disable PCI Bus Parking and PCI Master read caching on CX700
 * which causes unspecified timing errors with a VT6212L on the PCI
 * bus leading to USB2.0 packet loss. The defaults are that these
 * features are turned off but some BIOSes turn them on.
 */

uint8_t b;
if (pci_read_config_byte(dev, 0x76, &b) == 0) {
  if (b & 0x40) {
    /* Turn off PCI Bus Parking */
    pci_write_config_byte(dev, 0x76, b ^ 0x40);

    dev_info(&dev->dev,
      "Disabling VIA CX700 PCI parking\n");
   }
}

if (pci_read_config_byte(dev, 0x72, &b) == 0) {
  if (b != 0) {
    /* Turn off PCI Master read caching */
    pci_write_config_byte(dev, 0x72, 0x0);

    /* Set PCI Master Bus time-out to "1x16 PCLK" */
    pci_write_config_byte(dev, 0x75, 0x1);

    /* Disable "Read FIFO Timer" */
    pci_write_config_byte(dev, 0x77, 0x0);

    dev_info(&dev->dev,
      "Disabling VIA CX700 PCI caching\n");
  }
}

Here dev is
    vendor = 0x1106 'VIA Technologies Inc'
    device = 0x324e 'CX700 Internal Module Bus'
    class  = 0x060000 'HOST-PCI bridge'

Being done on FreeBSD, these steps fix the problem till the next system boot.
>How-To-Repeat:
Boot FreeBSD on PC, based on VIA CX700* chipset. If BIOS doesn't initialize chipset correctly, like in my case, problem with some PCI devices using DMA transfer should appear.
>Fix:
I think BIOS developers but not OS developers must fix this problem. But as long as not all of them do it, it will be good to include this quirk in FreeBSD's kernel code. Anyway, there is my script /usr/local/etc/rc.d/cx700fix in the attach.

Patch attached with submission follows:

#!/bin/sh

# PROVIDE: cx700fix
# REQUIRE: FILESYSTEMS
# BEFORE: netif

. /etc/rc.subr

name="cx700fix"
start_cmd="reg_fix"
stop_cmd=":"


reg_fix()
{
	if selector=`pciconf -l | sed -n '/chip=0x324e1106/{s/[[:blank:]].*//;p;}'` && [ -n "$selector" ]; then
		b=`read_config_byte 0x76`
		if [ $((b & 64)) -eq 64 ]; then
			echo "Disabling VIA CX700 PCI parking"
			write_config_byte 0x76 $((b ^ 64))
		fi

		if [ `read_config_byte 0x72` -ne 0 ]; then
			echo "Disabling VIA CX700 PCI caching"
			write_config_byte 0x72 0
			write_config_byte 0x75 1
			write_config_byte 0x77 0
		fi
	fi

	return 0
}

read_config_byte() {
	echo $(( 0x$(pciconf -rb $selector $1) ))
}

write_config_byte() {
	pciconf -wb $selector $1 $2
}

run_rc_command "$1"


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805161645.m4GGjjdL056847>