From owner-svn-src-all@FreeBSD.ORG Fri Nov 16 03:05:28 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5CB96123; Fri, 16 Nov 2012 03:05:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 40EDC8FC14; Fri, 16 Nov 2012 03:05:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAG35S9f005600; Fri, 16 Nov 2012 03:05:28 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAG35S1d005594; Fri, 16 Nov 2012 03:05:28 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201211160305.qAG35S1d005594@svn.freebsd.org> From: Alexander Motin Date: Fri, 16 Nov 2012 03:05:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r243126 - in stable/8/sys/dev/ata: . chipsets X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Nov 2012 03:05:28 -0000 Author: mav Date: Fri Nov 16 03:05:27 2012 New Revision: 243126 URL: http://svnweb.freebsd.org/changeset/base/243126 Log: MFC r242156: Implement CAM_ATAIO_NEEDRESULT (fetching full set of result registers) for ata(4) driver in ATA_CAM mode. That slighty improves error reporting and also should fix `smartctl -l scterc /dev/adaX` operation. Modified: stable/8/sys/dev/ata/ata-all.c stable/8/sys/dev/ata/ata-all.h stable/8/sys/dev/ata/ata-lowlevel.c stable/8/sys/dev/ata/chipsets/ata-ahci.c stable/8/sys/dev/ata/chipsets/ata-siliconimage.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/ata/ (props changed) Modified: stable/8/sys/dev/ata/ata-all.c ============================================================================== --- stable/8/sys/dev/ata/ata-all.c Fri Nov 16 03:04:30 2012 (r243125) +++ stable/8/sys/dev/ata/ata-all.c Fri Nov 16 03:05:27 2012 (r243126) @@ -1491,6 +1491,8 @@ ata_cam_begin_transaction(device_t dev, request->u.ata.lba |= ((uint64_t)ccb->ataio.cmd.lba_high << 16) | ((uint64_t)ccb->ataio.cmd.lba_mid << 8) | (uint64_t)ccb->ataio.cmd.lba_low; + if (ccb->ataio.cmd.flags & CAM_ATAIO_NEEDRESULT) + request->flags |= ATA_R_NEEDRESULT; if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE && ccb->ataio.cmd.flags & CAM_ATAIO_DMA) request->flags |= ATA_R_DMA; Modified: stable/8/sys/dev/ata/ata-all.h ============================================================================== --- stable/8/sys/dev/ata/ata-all.h Fri Nov 16 03:04:30 2012 (r243125) +++ stable/8/sys/dev/ata/ata-all.h Fri Nov 16 03:05:27 2012 (r243126) @@ -397,6 +397,7 @@ struct ata_request { #define ATA_R_REQUEUE 0x00000400 #define ATA_R_THREAD 0x00000800 #define ATA_R_DIRECT 0x00001000 +#define ATA_R_NEEDRESULT 0x00002000 #define ATA_R_ATAPI16 0x00010000 #define ATA_R_ATAPI_INTR 0x00020000 Modified: stable/8/sys/dev/ata/ata-lowlevel.c ============================================================================== --- stable/8/sys/dev/ata/ata-lowlevel.c Fri Nov 16 03:04:30 2012 (r243125) +++ stable/8/sys/dev/ata/ata-lowlevel.c Fri Nov 16 03:05:27 2012 (r243126) @@ -116,6 +116,7 @@ ata_begin_transaction(struct ata_request } while (request->status & ATA_S_BUSY && timeout--); if (request->status & ATA_S_ERROR) request->error = ATA_IDX_INB(ch, ATA_ERROR); + ch->hw.tf_read(request); goto begin_finished; } @@ -253,8 +254,9 @@ ata_end_transaction(struct ata_request * if (request->flags & ATA_R_TIMEOUT) goto end_finished; - /* on control commands read back registers to the request struct */ - if (request->flags & ATA_R_CONTROL) { + /* Read back registers to the request struct. */ + if ((request->status & ATA_S_ERROR) || + (request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT))) { ch->hw.tf_read(request); } @@ -332,6 +334,12 @@ ata_end_transaction(struct ata_request * else if (!(request->flags & ATA_R_TIMEOUT)) request->donecount = request->bytecount; + /* Read back registers to the request struct. */ + if ((request->status & ATA_S_ERROR) || + (request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT))) { + ch->hw.tf_read(request); + } + /* release SG list etc */ ch->dma.unload(request); Modified: stable/8/sys/dev/ata/chipsets/ata-ahci.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-ahci.c Fri Nov 16 03:04:30 2012 (r243125) +++ stable/8/sys/dev/ata/chipsets/ata-ahci.c Fri Nov 16 03:05:27 2012 (r243126) @@ -555,8 +555,10 @@ ata_ahci_end_transaction(struct ata_requ if (request->status & ATA_S_ERROR) request->error = tf_data >> 8; - /* on control commands read back registers to the request struct */ - if (request->flags & ATA_R_CONTROL) { + /* Read back registers to the request struct. */ + if ((request->flags & ATA_R_ATAPI) == 0 && + ((request->status & ATA_S_ERROR) || + (request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT)))) { u_int8_t *fis = ch->dma.work + ATA_AHCI_FB_OFFSET + 0x40; request->u.ata.count = fis[12] | ((u_int16_t)fis[13] << 8); Modified: stable/8/sys/dev/ata/chipsets/ata-siliconimage.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-siliconimage.c Fri Nov 16 03:04:30 2012 (r243125) +++ stable/8/sys/dev/ata/chipsets/ata-siliconimage.c Fri Nov 16 03:05:27 2012 (r243126) @@ -658,8 +658,10 @@ ata_siiprb_end_transaction(struct ata_re } } - /* on control commands read back registers to the request struct */ - if (request->flags & ATA_R_CONTROL) { + /* Read back registers to the request struct. */ + if ((request->flags & ATA_R_ATAPI) == 0 && + ((request->status & ATA_S_ERROR) || + (request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT)))) { request->u.ata.count = prb->fis[12] | ((u_int16_t)prb->fis[13] << 8); request->u.ata.lba = prb->fis[4] | ((u_int64_t)prb->fis[5] << 8) | ((u_int64_t)prb->fis[6] << 16);