From elsukov@kirov.so-cdu.ru  Wed Jul  9 06:44:20 2008
Return-Path: <elsukov@kirov.so-cdu.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4119F1065674;
	Wed,  9 Jul 2008 06:44:20 +0000 (UTC)
	(envelope-from elsukov@kirov.so-cdu.ru)
Received: from mgat.kirov.so-cdu.ru (mgat.kirov.so-cdu.ru [77.72.136.147])
	by mx1.freebsd.org (Postfix) with ESMTP id 166798FC16;
	Wed,  9 Jul 2008 06:44:18 +0000 (UTC)
	(envelope-from elsukov@kirov.so-cdu.ru)
Received: from mail.kirov.so-cdu.ru ([62.33.253.129]) by mgat.kirov.so-cdu.ru with InterScan Message Security Suite; Wed, 09 Jul 2008 10:14:07 +0400
Received: from kas30pipe.localhost (localhost.kirov.so-cdu.ru [127.0.0.1])
	by mail.kirov.so-cdu.ru (Postfix) with SMTP id 90279B805F;
	Wed,  9 Jul 2008 10:14:07 +0400 (MSD)
Received: by mail.kirov.so-cdu.ru (Postfix, from userid 1011)
	id 6DA53B805E; Wed,  9 Jul 2008 10:14:07 +0400 (MSD)
Message-Id: <20080709061407.6DA53B805E@mail.kirov.so-cdu.ru>
Date: Wed,  9 Jul 2008 10:14:07 +0400 (MSD)
From: Andrey V. Elsukov <bu7cher@yandex.ru>
Reply-To: Andrey V. Elsukov <bu7cher@yandex.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc: <sos@freebsd.org>
Subject: [ata][patch] sii 680 failed to allocate resources
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         125421
>Category:       kern
>Synopsis:       [ata][patch] sii 680 failed to allocate resources
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    remko
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 09 06:50:02 UTC 2008
>Closed-Date:    Sat Aug 02 12:41:31 UTC 2008
>Last-Modified:  Sat Aug 02 12:41:31 UTC 2008
>Originator:     Andrey V. Elsukov
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
>Environment:
	FreeBSD
>Description:
atapci1: <SiI SiI 0680 UDMA133 controller> port 0xa800-0xa807,0xa400-0xa403,0xa000-0xa007,0x9800-0x9803,0x9400-0x940f irq 22 at device 10.0 on pci1
atapci1: Reserved 0x10 bytes for rid 0x20 type 4 at 0x9400
ioapic0: routing intpin 22 (PCI IRQ 22) to vector 54
atapci1: [MPSAFE]
atapci1: [ITHREAD]
device_attach: atapci1 attach returned 6

Driver failed to allocate MMIO resources. Attached patch adds a fallback path.
It uses generic IDE facilities if sii-specific allocations failed. After path
we have:

atapci1: <SiI 0680 UDMA133 controller> port 0xa800-0xa807,0xa400-0xa403,0xa000-0xa007,0x9800-0x9803,0x9400-0x940f irq 21 at device 11.0 on pci1
atapci1: Reserved 0x10 bytes for rid 0x20 type 4 at 0x9400
ioapic0: routing intpin 21 (PCI IRQ 21) to vector 54
atapci1: [MPSAFE]
atapci1: [ITHREAD]
ata4: <ATA channel 0> on atapci1
atapci1: Reserved 0x8 bytes for rid 0x10 type 4 at 0xa800
atapci1: Reserved 0x4 bytes for rid 0x14 type 4 at 0xa400
ata4: reset tp1 mask=03 ostat0=50 ostat1=00
ata4: stat0=0x00 err=0x01 lsb=0x14 msb=0xeb
ata4: stat1=0x00 err=0x04 lsb=0x0e msb=0x00
ata4: reset tp2 stat0=00 stat1=00 devices=0x4<ATAPI_MASTER>
ata4: [MPSAFE]
ata4: [ITHREAD]
ata5: <ATA channel 1> on atapci1
atapci1: Reserved 0x8 bytes for rid 0x18 type 4 at 0xa000
atapci1: Reserved 0x4 bytes for rid 0x1c type 4 at 0x9800
ata5: reset tp1 mask=03 ostat0=7f ostat1=7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat0=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: stat1=0x7f err=0x7f lsb=0x7f msb=0x7f
ata5: reset tp2 stat0=ff stat1=ff devices=0x0
ata5: [MPSAFE]
ata5: [ITHREAD]
isab0: <PCI-ISA bridge> at device 31.0 on pci0
...
ata4-master: pio=PIO4 wdma=WDMA2 udma=UDMA33 cable=40 wire
acd0: setting PIO4 on 0680 chip
acd0: setting UDMA33 on 0680 chip
acd0: <NEC DVD RW ND-4570A/1.02> DVDR drive at ata4 as master
acd0: read 8268KB/s (8268KB/s) write 8268KB/s (8268KB/s), 2048KB buffer, UDMA33
acd0: Reads: CDR, CDRW, CDDA stream, DVDROM, DVDR, DVDRAM, packet
acd0: Writes: CDR, CDRW, DVDR, DVDRAM, test write, burnproof
acd0: Audio: play, 256 volume levels
acd0: Mechanism: ejectable tray, unlocked
acd0: Medium: no/blank disc 

>How-To-Repeat:
	Can be repeated on some buggy(?) controllers.
>Fix:

	

--- sii_680_alloc_resource_fallback_path.diff begins here ---
--- ata-chipset.c.orig	2008-03-25 13:32:44.000000000 +0300
+++ ata-chipset.c	2008-03-25 14:25:32.000000000 +0300
@@ -4514,12 +4514,15 @@ ata_sii_chipinit(device_t dev)
 	ctlr->r_type2 = SYS_RES_MEMORY;
 	ctlr->r_rid2 = PCIR_BAR(5);
 	if (!(ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2,
-						    &ctlr->r_rid2, RF_ACTIVE)))
-	    return ENXIO;
+						    &ctlr->r_rid2, RF_ACTIVE))) {
+	    if (ctlr->chip->chipid != ATA_SII0680 ||
+			    (pci_read_config(dev, 0x8a, 1) & 1))
+		return ENXIO;
+	}
 
 	if (ctlr->chip->cfg2 & SIISETCLK) {
 	    if ((pci_read_config(dev, 0x8a, 1) & 0x30) != 0x10)
-		pci_write_config(dev, 0x8a, 
+		pci_write_config(dev, 0x8a,
 				 (pci_read_config(dev, 0x8a, 1) & 0xcf)|0x10,1);
 	    if ((pci_read_config(dev, 0x8a, 1) & 0x30) != 0x10)
 		device_printf(dev, "%s could not set ATA133 clock\n",
@@ -4539,7 +4542,9 @@ ata_sii_chipinit(device_t dev)
 	/* enable PCI interrupt as BIOS might not */
 	pci_write_config(dev, 0x8a, (pci_read_config(dev, 0x8a, 1) & 0x3f), 1);
 
-	ctlr->allocate = ata_sii_allocate;
+	if (ctlr->r_res2)
+	    ctlr->allocate = ata_sii_allocate;
+
 	if (ctlr->chip->max_dma >= ATA_SA150) {
 	    ctlr->reset = ata_sii_reset;
 	    ctlr->setmode = ata_sata_setmode;
--- sii_680_alloc_resource_fallback_path.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->remko 
Responsible-Changed-By: remko 
Responsible-Changed-When: Wed Jul 9 11:01:22 UTC 2008 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=125421 
State-Changed-From-To: open->patched 
State-Changed-By: remko 
State-Changed-When: Wed Jul 9 15:11:00 UTC 2008 
State-Changed-Why:  
patched in current 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/125421: commit references a PR
Date: Wed,  9 Jul 2008 15:11:13 +0000 (UTC)

 remko       2008-07-09 15:10:53 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/dev/ata          ata-chipset.c 
   Log:
   SVN rev 180384 on 2008-07-09 15:10:53Z by remko
   
   Driver failed to allocate MMIO resources. Attached patch adds a fallback path.
   It uses generic IDE facilities if sii-specific allocations failed
   
   PR:             125421
   Submitted by:   Andrey V. Elsukov <bu7cher at yandex dot ru>
   Approved by:    imp (mentor, implicit)
   MFC after:      1 week
   
   Revision  Changes    Path
   1.223     +9 -4      src/sys/dev/ata/ata-chipset.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/125421: commit references a PR
Date: Sat,  2 Aug 2008 12:33:48 +0000 (UTC)

 remko       2008-08-02 12:33:28 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_7)
     sys/dev/ata          ata-chipset.c 
   Log:
   SVN rev 181166 on 2008-08-02 12:33:28Z by remko
   
   MFC r180384
   
     Driver failed to allocate MMIO resources. Attached patch adds a fallback path.
     It uses generic IDE facilities if sii-specific allocations failed
   
     PR:           125421
     Submitted by: Andrey V. Elsukov <bu7cher at yandex dot ru>
     Approved by:  imp (mentor, implicit)
     MFC after:    1 week
   
   Approved by:    imp (mentor, implicit)
   
   Revision    Changes    Path
   1.202.2.10  +9 -4      src/sys/dev/ata/ata-chipset.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/125421: commit references a PR
Date: Sat,  2 Aug 2008 12:39:43 +0000 (UTC)

 remko       2008-08-02 12:39:23 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     sys/dev/ata          ata-chipset.c 
   Log:
   SVN rev 181171 on 2008-08-02 12:39:23Z by remko
   
   MFC r180384
   
       Driver failed to allocate MMIO resources. Attached patch adds a fallback path.
       It uses generic IDE facilities if sii-specific allocations failed
   
       PR:           125421
       Submitted by: Andrey V. Elsukov <bu7cher at yandex dot ru>
       Approved by:  imp (mentor, implicit)
       MFC after:    1 week
   
   Approved by:    imp (mentor, implicit)
   
   Revision    Changes    Path
   1.126.2.30  +9 -4      src/sys/dev/ata/ata-chipset.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: remko 
State-Changed-When: Sat Aug 2 12:41:31 UTC 2008 
State-Changed-Why:  
Committed. Thanks! 

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