From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 17 21:08:13 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3BB41065695; Tue, 17 Nov 2009 21:08:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DFB978FC15; Tue, 17 Nov 2009 21:08:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nAHL8CLA038948; Tue, 17 Nov 2009 21:08:12 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nAHL8Crv038941; Tue, 17 Nov 2009 21:08:12 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200911172108.nAHL8Crv038941@svn.freebsd.org> From: Alexander Motin Date: Tue, 17 Nov 2009 21:08:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199443 - in stable/8: . contrib/top lib/libusb sbin/camcontrol sys/cam/ata sys/sys tools/regression/lib/msun tools/regression/usr.bin/pkill tools/tools/ath/common tools/tools/termcap u... X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2009 21:08:13 -0000 Author: mav Date: Tue Nov 17 21:08:12 2009 New Revision: 199443 URL: http://svn.freebsd.org/changeset/base/199443 Log: MFC r198897: - Add support for sector size > 512 bytes and physical sector of several logical sectors, introduced by ATA-7 specification. - Remove some obsoleted code. Modified: stable/8/sbin/camcontrol/camcontrol.c stable/8/sys/cam/ata/ata_all.c stable/8/sys/cam/ata/ata_all.h stable/8/sys/cam/ata/ata_da.c stable/8/sys/cam/ata/ata_xpt.c stable/8/sys/sys/ata.h Directory Properties: stable/8/ (props changed) stable/8/ObsoleteFiles.inc (props changed) stable/8/UPDATING (props changed) stable/8/bin/csh/ (props changed) stable/8/bin/sh/ (props changed) stable/8/cddl/compat/opensolaris/ (props changed) stable/8/cddl/contrib/opensolaris/ (props changed) stable/8/cddl/lib/libnvpair/ (props changed) stable/8/contrib/bind9/ (props changed) stable/8/contrib/bzip2/ (props changed) stable/8/contrib/cpio/ (props changed) stable/8/contrib/csup/ (props changed) stable/8/contrib/ee/ (props changed) stable/8/contrib/file/ (props changed) stable/8/contrib/gdb/ (props changed) stable/8/contrib/gdtoa/ (props changed) stable/8/contrib/less/ (props changed) stable/8/contrib/libpcap/ (props changed) stable/8/contrib/ncurses/ (props changed) stable/8/contrib/netcat/ (props changed) stable/8/contrib/ntp/ (props changed) stable/8/contrib/openbsm/ (props changed) stable/8/contrib/openpam/ (props changed) stable/8/contrib/pf/ (props changed) stable/8/contrib/sendmail/ (props changed) stable/8/contrib/tcpdump/ (props changed) stable/8/contrib/tcsh/ (props changed) stable/8/contrib/top/ (props changed) stable/8/contrib/top/install-sh (props changed) stable/8/contrib/traceroute/ (props changed) stable/8/contrib/wpa/ (props changed) stable/8/crypto/openssh/ (props changed) stable/8/crypto/openssl/ (props changed) stable/8/etc/ (props changed) stable/8/games/fortune/ (props changed) stable/8/games/fortune/datfiles/ (props changed) stable/8/gnu/usr.bin/groff/ (props changed) stable/8/gnu/usr.bin/patch/ (props changed) stable/8/include/ (props changed) stable/8/kerberos5/lib/libgssapi_krb5/ (props changed) stable/8/kerberos5/lib/libgssapi_spnego/ (props changed) stable/8/lib/libarchive/ (props changed) stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libdevinfo/ (props changed) stable/8/lib/libdisk/ (props changed) stable/8/lib/libkvm/ (props changed) stable/8/lib/libradius/ (props changed) stable/8/lib/libstand/ (props changed) stable/8/lib/libthr/ (props changed) stable/8/lib/libusb/ (props changed) stable/8/lib/libusb/usb.h (props changed) stable/8/lib/libutil/ (props changed) stable/8/libexec/rtld-elf/ (props changed) stable/8/release/ (props changed) stable/8/release/doc/ (props changed) stable/8/release/doc/en_US.ISO8859-1/hardware/ (props changed) stable/8/sbin/ (props changed) stable/8/sbin/bsdlabel/ (props changed) stable/8/sbin/camcontrol/ (props changed) stable/8/sbin/ddb/ (props changed) stable/8/sbin/dhclient/ (props changed) stable/8/sbin/geom/ (props changed) stable/8/sbin/ifconfig/ (props changed) stable/8/sbin/ipfw/ (props changed) stable/8/sbin/mksnap_ffs/ (props changed) stable/8/sbin/mount/ (props changed) stable/8/sbin/mount_nfs/ (props changed) stable/8/sbin/umount/ (props changed) stable/8/secure/usr.bin/bdes/ (props changed) stable/8/share/man/man4/ (props changed) stable/8/share/man/man5/ (props changed) stable/8/share/man/man7/ (props changed) stable/8/share/man/man9/ (props changed) stable/8/share/misc/ (props changed) stable/8/share/timedef/ (props changed) stable/8/share/zoneinfo/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/tools/kerneldoc/subsys/ (props changed) stable/8/tools/regression/bin/sh/ (props changed) stable/8/tools/regression/lib/msun/test-conj.t (props changed) stable/8/tools/regression/poll/ (props changed) stable/8/tools/regression/priv/ (props changed) stable/8/tools/regression/usr.bin/pkill/pgrep-_g.t (props changed) stable/8/tools/regression/usr.bin/pkill/pgrep-_s.t (props changed) stable/8/tools/regression/usr.bin/pkill/pkill-_g.t (props changed) stable/8/tools/tools/ath/common/dumpregs.h (props changed) stable/8/tools/tools/ath/common/dumpregs_5210.c (props changed) stable/8/tools/tools/ath/common/dumpregs_5211.c (props changed) stable/8/tools/tools/ath/common/dumpregs_5212.c (props changed) stable/8/tools/tools/ath/common/dumpregs_5416.c (props changed) stable/8/tools/tools/termcap/termcap.pl (props changed) stable/8/tools/tools/vimage/ (props changed) stable/8/usr.bin/calendar/calendars/calendar.freebsd (props changed) stable/8/usr.bin/csup/ (props changed) stable/8/usr.bin/find/ (props changed) stable/8/usr.bin/fstat/ (props changed) stable/8/usr.bin/gcore/ (props changed) stable/8/usr.bin/locale/ (props changed) stable/8/usr.bin/look/ (props changed) stable/8/usr.bin/netstat/ (props changed) stable/8/usr.bin/procstat/ (props changed) stable/8/usr.bin/systat/ (props changed) stable/8/usr.bin/vmstat/ (props changed) stable/8/usr.bin/w/ (props changed) stable/8/usr.bin/whois/ (props changed) stable/8/usr.sbin/ (props changed) stable/8/usr.sbin/acpi/ (props changed) stable/8/usr.sbin/arp/ (props changed) stable/8/usr.sbin/cdcontrol/ (props changed) stable/8/usr.sbin/crashinfo/ (props changed) stable/8/usr.sbin/dumpcis/cardinfo.h (props changed) stable/8/usr.sbin/dumpcis/cis.h (props changed) stable/8/usr.sbin/freebsd-update/ (props changed) stable/8/usr.sbin/iostat/ (props changed) stable/8/usr.sbin/jail/ (props changed) stable/8/usr.sbin/jls/ (props changed) stable/8/usr.sbin/lpr/ (props changed) stable/8/usr.sbin/makefs/ffs/ffs_bswap.c (props changed) stable/8/usr.sbin/makefs/ffs/ffs_subr.c (props changed) stable/8/usr.sbin/makefs/ffs/ufs_bswap.h (props changed) stable/8/usr.sbin/makefs/getid.c (props changed) stable/8/usr.sbin/mfiutil/mfiutil.8 (props changed) stable/8/usr.sbin/ndp/ (props changed) stable/8/usr.sbin/ntp/ (props changed) stable/8/usr.sbin/ppp/ (props changed) stable/8/usr.sbin/pstat/ (props changed) stable/8/usr.sbin/sysinstall/ (props changed) stable/8/usr.sbin/traceroute6/ (props changed) stable/8/usr.sbin/usbconfig/ (props changed) stable/8/usr.sbin/wpa/ (props changed) stable/8/usr.sbin/zic/ (props changed) Modified: stable/8/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/8/sbin/camcontrol/camcontrol.c Tue Nov 17 21:08:10 2009 (r199442) +++ stable/8/sbin/camcontrol/camcontrol.c Tue Nov 17 21:08:12 2009 (r199443) @@ -1061,6 +1061,10 @@ atacapprint(struct ata_params *parm) printf("cylinders %d\n", parm->cylinders); printf("heads %d\n", parm->heads); printf("sectors/track %d\n", parm->sectors); + printf("sector size logical %u, physical %lu, offset %lu\n", + ata_logical_sector_size(parm), + (unsigned long)ata_physical_sector_size(parm), + (unsigned long)ata_logical_sector_offset(parm)); if (parm->config == ATA_PROTO_CFA || (parm->support.command2 & ATA_SUPPORT_CFA)) Modified: stable/8/sys/cam/ata/ata_all.c ============================================================================== --- stable/8/sys/cam/ata/ata_all.c Tue Nov 17 21:08:10 2009 (r199442) +++ stable/8/sys/cam/ata/ata_all.c Tue Nov 17 21:08:12 2009 (r199443) @@ -271,6 +271,38 @@ ata_print_ident(struct ata_params *ident printf(" device\n"); } +uint32_t +ata_logical_sector_size(struct ata_params *ident_data) +{ + if ((ident_data->pss & 0xc000) == 0x4000 && + (ident_data->pss & ATA_PSS_LSSABOVE512)) { + return ((u_int32_t)ident_data->lss_1 | + ((u_int32_t)ident_data->lss_2 << 16)); + } + return (512); +} + +uint64_t +ata_physical_sector_size(struct ata_params *ident_data) +{ + if ((ident_data->pss & 0xc000) == 0x4000 && + (ident_data->pss & ATA_PSS_MULTLS)) { + return ((uint64_t)ata_logical_sector_size(ident_data) * + (1 << (ident_data->pss & ATA_PSS_LSPPS))); + } + return (512); +} + +uint64_t +ata_logical_sector_offset(struct ata_params *ident_data) +{ + if ((ident_data->lsalign & 0xc000) == 0x4000) { + return ((uint64_t)ata_logical_sector_size(ident_data) * + (ident_data->lsalign & 0x3fff)); + } + return (0); +} + void ata_28bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features, uint32_t lba, uint8_t sector_count) Modified: stable/8/sys/cam/ata/ata_all.h ============================================================================== --- stable/8/sys/cam/ata/ata_all.h Tue Nov 17 21:08:10 2009 (r199442) +++ stable/8/sys/cam/ata/ata_all.h Tue Nov 17 21:08:12 2009 (r199443) @@ -91,6 +91,10 @@ int ata_res_sbuf(struct ccb_ataio *ataio void ata_print_ident(struct ata_params *ident_data); +uint32_t ata_logical_sector_size(struct ata_params *ident_data); +uint64_t ata_physical_sector_size(struct ata_params *ident_data); +uint64_t ata_logical_sector_offset(struct ata_params *ident_data); + void ata_28bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features, uint32_t lba, uint8_t sector_count); void ata_48bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint16_t features, Modified: stable/8/sys/cam/ata/ata_da.c ============================================================================== --- stable/8/sys/cam/ata/ata_da.c Tue Nov 17 21:08:10 2009 (r199442) +++ stable/8/sys/cam/ata/ata_da.c Tue Nov 17 21:08:12 2009 (r199443) @@ -95,16 +95,14 @@ typedef enum { struct disk_params { u_int8_t heads; - u_int32_t cylinders; u_int8_t secs_per_track; - u_int32_t secsize; /* Number of bytes/sector */ - u_int64_t sectors; /* total number sectors */ + u_int32_t cylinders; + u_int32_t secsize; /* Number of bytes/logical sector */ + u_int64_t sectors; /* Total number sectors */ }; struct ada_softc { struct bio_queue_head bio_queue; - SLIST_ENTRY(ada_softc) links; - LIST_HEAD(, ccb_hdr) pending_ccbs; ada_state state; ada_flags flags; ada_quirks quirks; @@ -142,7 +140,7 @@ static void adadone(struct cam_periph * union ccb *done_ccb); static int adaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags); -static void adasetgeom(struct cam_periph *periph, +static void adagetparams(struct cam_periph *periph, struct ccb_getdev *cgd); static timeout_t adasendorderedtag; static void adashutdown(void *arg, int howto); @@ -613,7 +611,6 @@ adaregister(struct cam_periph *periph, v return(CAM_REQ_CMP_ERR); } - LIST_INIT(&softc->pending_ccbs); bioq_init(&softc->bio_queue); if (cgd->ident_data.capabilities1 & ATA_SUPPORT_DMA) @@ -658,6 +655,7 @@ adaregister(struct cam_periph *periph, v * Register this media as a disk */ mtx_unlock(periph->sim->mtx); + adagetparams(periph, cgd); softc->disk = disk_alloc(); softc->disk->d_open = adaopen; softc->disk->d_close = adaclose; @@ -671,9 +669,9 @@ adaregister(struct cam_periph *periph, v else if (maxio > MAXPHYS) maxio = MAXPHYS; /* for safety */ if (cgd->ident_data.support.command2 & ATA_SUPPORT_ADDRESS48) - maxio = min(maxio, 65536 * 512); + maxio = min(maxio, 65536 * softc->params.secsize); else /* 28bit ATA command limit */ - maxio = min(maxio, 256 * 512); + maxio = min(maxio, 256 * softc->params.secsize); softc->disk->d_maxsize = maxio; softc->disk->d_unit = periph->unit_number; softc->disk->d_flags = 0; @@ -682,9 +680,12 @@ adaregister(struct cam_periph *periph, v strlcpy(softc->disk->d_ident, cgd->serial_num, MIN(sizeof(softc->disk->d_ident), cgd->serial_num_len + 1)); - adasetgeom(periph, cgd); softc->disk->d_sectorsize = softc->params.secsize; - softc->disk->d_mediasize = softc->params.secsize * (off_t)softc->params.sectors; + softc->disk->d_mediasize = (off_t)softc->params.sectors * + softc->params.secsize; + softc->disk->d_stripesize = ata_physical_sector_size(&cgd->ident_data); + softc->disk->d_stripeoffset = softc->disk->d_stripesize - + ata_logical_sector_offset(&cgd->ident_data); /* XXX: these are not actually "firmware" values, so they may be wrong */ softc->disk->d_fwsectors = softc->params.secs_per_track; softc->disk->d_fwheads = softc->params.heads; @@ -852,19 +853,10 @@ adastart(struct cam_periph *periph, unio break; } start_ccb->ccb_h.ccb_state = ADA_CCB_BUFFER_IO; - - /* - * Block out any asyncronous callbacks - * while we touch the pending ccb list. - */ - LIST_INSERT_HEAD(&softc->pending_ccbs, - &start_ccb->ccb_h, periph_links.le); - softc->outstanding_cmds++; - start_ccb->ccb_h.ccb_bp = bp; - bp = bioq_first(&softc->bio_queue); - + softc->outstanding_cmds++; xpt_action(start_ccb); + bp = bioq_first(&softc->bio_queue); } if (bp != NULL) { @@ -941,12 +933,6 @@ adadone(struct cam_periph *periph, union if (ataio->resid > 0) bp->bio_flags |= BIO_ERROR; } - - /* - * Block out any asyncronous callbacks - * while we touch the pending ccb list. - */ - LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); softc->outstanding_cmds--; if (softc->outstanding_cmds == 0) softc->flags |= ADA_FLAG_WENT_IDLE; @@ -983,14 +969,14 @@ adaerror(union ccb *ccb, u_int32_t cam_f } static void -adasetgeom(struct cam_periph *periph, struct ccb_getdev *cgd) +adagetparams(struct cam_periph *periph, struct ccb_getdev *cgd) { struct ada_softc *softc = (struct ada_softc *)periph->softc; struct disk_params *dp = &softc->params; u_int64_t lbasize48; u_int32_t lbasize; - dp->secsize = 512; + dp->secsize = ata_logical_sector_size(&cgd->ident_data); if ((cgd->ident_data.atavalid & ATA_FLAG_54_58) && cgd->ident_data.current_heads && cgd->ident_data.current_sectors) { dp->heads = cgd->ident_data.current_heads; Modified: stable/8/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/8/sys/cam/ata/ata_xpt.c Tue Nov 17 21:08:10 2009 (r199442) +++ stable/8/sys/cam/ata/ata_xpt.c Tue Nov 17 21:08:12 2009 (r199443) @@ -363,10 +363,12 @@ probestart(struct cam_periph *periph, un cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS; cts.type = CTS_TYPE_CURRENT_SETTINGS; if (path->device->transport == XPORT_ATA) { - cts.xport_specific.ata.bytecount = sectors * 512; + cts.xport_specific.ata.bytecount = sectors * + ata_logical_sector_size(ident_buf); cts.xport_specific.ata.valid = CTS_ATA_VALID_BYTECOUNT; } else { - cts.xport_specific.sata.bytecount = sectors * 512; + cts.xport_specific.sata.bytecount = sectors * + ata_logical_sector_size(ident_buf); cts.xport_specific.sata.valid = CTS_SATA_VALID_BYTECOUNT; } xpt_action((union ccb *)&cts); Modified: stable/8/sys/sys/ata.h ============================================================================== --- stable/8/sys/sys/ata.h Tue Nov 17 21:08:10 2009 (r199442) +++ stable/8/sys/sys/ata.h Tue Nov 17 21:08:12 2009 (r199443) @@ -234,7 +234,7 @@ struct ata_params { /*176*/ u_int8_t media_serial[60]; /*206*/ u_int16_t sct; u_int16_t reserved206[2]; -/*209*/ u_int16_t lbalign; +/*209*/ u_int16_t lsalign; /*210*/ u_int16_t wrv_sectors_m3_1; u_int16_t wrv_sectors_m3_2; /*212*/ u_int16_t wrv_sectors_m2_1;