NetBSD Problem Report #47390

From o.vd.linden@quicknet.nl  Tue Jan  1 13:45:48 2013
Return-Path: <o.vd.linden@quicknet.nl>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 656DA63E648
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  1 Jan 2013 13:45:48 +0000 (UTC)
Message-Id: <20130101134542.GA1332@sheep>
Date: Tue, 1 Jan 2013 14:45:42 +0100
From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: gnats-bugs@netbsd.org
Subject: simplify/cleanup satalink(4) device detection

>Number:         47390
>Category:       kern
>Synopsis:       simplify/cleanup satalink(4) device detection
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 01 13:50:01 +0000 2013
>Originator:     Onno van der Linden
>Release:        NetBSD 6.99.16
>Organization:

>Environment:


System: NetBSD sheep 6.99.16 NetBSD 6.99.16 (SHEEP) #38: Tue Jan 1 09:50:29 MET 2013 root@sheep:/usr/src/sys/arch/i386/compile/SHEEP i386
Architecture: i386
Machine: i386
>Description:
Comment in /sys/dev/pci/satalink.c says

 * XXX ATAPI detection doesn't currently work.  Don't
 * XXX know why.  But, it's not like the standard method
 * XXX can detect an ATAPI device connected via a SATA/PATA
 * XXX bridge, so at least this is no worse.  --thorpej

>How-To-Repeat:
Read the source .....
>Fix:

Add satalink FIS registers and read device signature
directly from them (comparable to /sys/dev/ic/siisata.c)

*** /usr/src/sys/dev/pci/satalink.c.orig	Sun Oct 28 07:59:53 2012
--- /usr/src/sys/dev/pci/satalink.c	Tue Jan  1 13:45:19 2013
***************
*** 88,93 ****
--- 88,100 ----
  	bus_addr_t	ba5_PHY_CONFIG;
  	bus_addr_t	ba5_SIEN;
  	bus_addr_t	ba5_SFISCfg;
+ 	bus_addr_t	ba5_RxFIS0;
+ 	bus_addr_t	ba5_RxFIS1;
+ 	bus_addr_t	ba5_RxFIS2;
+ 	bus_addr_t	ba5_RxFIS3;
+ 	bus_addr_t	ba5_RxFIS4;
+ 	bus_addr_t	ba5_RxFIS5;
+ 	bus_addr_t	ba5_RxFIS6;
  } satalink_ba5_regmap[] = {
  	{	/* Channel 0 */
  		.ba5_IDEDMA_CMD		=	0x000,
***************
*** 128,133 ****
--- 135,147 ----
  		.ba5_PHY_CONFIG		=	0x144,
  		.ba5_SIEN		=	0x148,
  		.ba5_SFISCfg		=	0x14c,
+ 		.ba5_RxFIS0		=	0x160,
+ 		.ba5_RxFIS1		=	0x164,
+ 		.ba5_RxFIS2		=	0x168,
+ 		.ba5_RxFIS3		=	0x16c,
+ 		.ba5_RxFIS4		=	0x170,
+ 		.ba5_RxFIS5		=	0x174,
+ 		.ba5_RxFIS6		=	0x178,
  	},
  	{	/* Channel 1 */
  		.ba5_IDEDMA_CMD		=	0x008,
***************
*** 168,173 ****
--- 182,194 ----
  		.ba5_PHY_CONFIG		=	0x1c4,
  		.ba5_SIEN		=	0x1c8,
  		.ba5_SFISCfg		=	0x1cc,
+ 		.ba5_RxFIS0		=	0x1e0,
+ 		.ba5_RxFIS1		=	0x1e4,
+ 		.ba5_RxFIS2		=	0x1e8,
+ 		.ba5_RxFIS3		=	0x1ec,
+ 		.ba5_RxFIS4		=	0x1f0,
+ 		.ba5_RxFIS5		=	0x1f4,
+ 		.ba5_RxFIS6		=	0x1f8,
  	},
  	{	/* Channel 2 (3114) */
  		.ba5_IDEDMA_CMD		=	0x200,
***************
*** 208,213 ****
--- 229,241 ----
  		.ba5_PHY_CONFIG		=	0x344,
  		.ba5_SIEN		=	0x348,
  		.ba5_SFISCfg		=	0x34c,
+ 		.ba5_RxFIS0		=	0x360,
+ 		.ba5_RxFIS1		=	0x364,
+ 		.ba5_RxFIS2		=	0x368,
+ 		.ba5_RxFIS3		=	0x36c,
+ 		.ba5_RxFIS4		=	0x370,
+ 		.ba5_RxFIS5		=	0x374,
+ 		.ba5_RxFIS6		=	0x378,
  	},
  	{	/* Channel 3 (3114) */
  		.ba5_IDEDMA_CMD		=	0x208,
***************
*** 248,253 ****
--- 276,288 ----
  		.ba5_PHY_CONFIG		=	0x3c4,
  		.ba5_SIEN		=	0x3c8,
  		.ba5_SFISCfg		=	0x3cc,
+ 		.ba5_RxFIS0		=	0x3e0,
+ 		.ba5_RxFIS1		=	0x3e4,
+ 		.ba5_RxFIS2		=	0x3e8,
+ 		.ba5_RxFIS3		=	0x3ec,
+ 		.ba5_RxFIS4		=	0x3f0,
+ 		.ba5_RxFIS5		=	0x3f4,
+ 		.ba5_RxFIS6		=	0x3f8,
  	},
  };

***************
*** 793,802 ****
  sii3112_drv_probe(struct ata_channel *chp)
  {
  	struct pciide_softc *sc = CHAN_TO_PCIIDE(chp);
! 	struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
! 	uint32_t scontrol, sstatus;
! 	uint8_t scnt, sn, cl, ch;
! 	int s;

  	/*
  	 * The 3112 is a 2-port part, and only has one drive per channel
--- 828,834 ----
  sii3112_drv_probe(struct ata_channel *chp)
  {
  	struct pciide_softc *sc = CHAN_TO_PCIIDE(chp);
! 	uint32_t scontrol, sstatus, sig;

  	/*
  	 * The 3112 is a 2-port part, and only has one drive per channel
***************
*** 847,888 ****
  		break;

  	case SStatus_DET_DEV:
! 		/*
! 		 * XXX ATAPI detection doesn't currently work.  Don't
! 		 * XXX know why.  But, it's not like the standard method
! 		 * XXX can detect an ATAPI device connected via a SATA/PATA
! 		 * XXX bridge, so at least this is no worse.  --thorpej
! 		 */
! 		bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
! 		    WDSD_IBM | (0 << 4));
! 		delay(10);	/* 400ns delay */
! 		/* Save register contents. */
! 		scnt = bus_space_read_1(wdr->cmd_iot,
! 				        wdr->cmd_iohs[wd_seccnt], 0);
! 		sn = bus_space_read_1(wdr->cmd_iot,
! 				      wdr->cmd_iohs[wd_sector], 0);
! 		cl = bus_space_read_1(wdr->cmd_iot,
! 				      wdr->cmd_iohs[wd_cyl_lo], 0);
! 		ch = bus_space_read_1(wdr->cmd_iot,
! 				      wdr->cmd_iohs[wd_cyl_hi], 0);
! #if 0
! 		printf("%s: port %d: scnt=0x%x sn=0x%x cl=0x%x ch=0x%x\n",
! 		    device_xname(sc->sc_wdcdev.sc_atac.atac_dev), chp->ch_channel,
! 		    scnt, sn, cl, ch);
! #endif
! 		if (atabus_alloc_drives(chp, 1) != 0)
! 			return;
! 		/*
! 		 * scnt and sn are supposed to be 0x1 for ATAPI, but in some
! 		 * cases we get wrong values here, so ignore it.
! 		 */
! 		s = splbio();
! 		if (cl == 0x14 && ch == 0xeb)
! 			chp->ch_drive[0].drive_type = ATA_DRIVET_ATAPI;
! 		else
! 			chp->ch_drive[0].drive_type = ATA_DRIVET_ATA;
! 		splx(s);
! 
  		aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev,
  		    "port %d: device present, speed: %s\n",
  		    chp->ch_channel,
--- 879,890 ----
  		break;

  	case SStatus_DET_DEV:
! 		sig = (BA5_READ_4(sc, chp->ch_channel, ba5_RxFIS1) &
!  			0x00fffffff) << 8;
!  		sig |= (BA5_READ_4(sc, chp->ch_channel, ba5_RxFIS3) & 0xff);
!  
! 		sata_interpret_sig(chp, 0, sig);
!   
  		aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev,
  		    "port %d: device present, speed: %s\n",
  		    chp->ch_channel,

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.