From owner-p4-projects@FreeBSD.ORG Sat Dec 5 19:20:30 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 81ABE1065672; Sat, 5 Dec 2009 19:20:30 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2DFAC106566C for ; Sat, 5 Dec 2009 19:20:30 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 1B3B08FC13 for ; Sat, 5 Dec 2009 19:20:30 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id nB5JKTf6066747 for ; Sat, 5 Dec 2009 19:20:29 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id nB5JKT3X066745 for perforce@freebsd.org; Sat, 5 Dec 2009 19:20:29 GMT (envelope-from mav@freebsd.org) Date: Sat, 5 Dec 2009 19:20:29 GMT Message-Id: <200912051920.nB5JKT3X066745@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 171419 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Dec 2009 19:20:30 -0000 http://p4web.freebsd.org/chv.cgi?CH=171419 Change 171419 by mav@mav_mavtest on 2009/12/05 19:20:27 Improve PIO transaction size negotiation. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#63 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#63 (text+ko) ==== @@ -366,7 +366,7 @@ cts.xport_specific.sata.valid = CTS_SATA_VALID_MODE; } xpt_action((union ccb *)&cts); - /* Fetch user modes from SIM. */ + /* Fetch current modes from SIM. */ bzero(&cts, sizeof(cts)); xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL); cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS; @@ -395,10 +395,25 @@ } case PROBE_SET_MULTI: { - u_int sectors; + u_int sectors, bytecount; - sectors = max(1, min(ident_buf->sectors_intr & 0xff, 16)); - + bytecount = 8192; /* SATA maximum */ + /* Fetch user bytecount from SIM. */ + bzero(&cts, sizeof(cts)); + xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL); + cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS; + cts.type = CTS_TYPE_USER_SETTINGS; + xpt_action((union ccb *)&cts); + if (path->device->transport == XPORT_ATA) { + if (cts.xport_specific.ata.valid & CTS_ATA_VALID_BYTECOUNT) + bytecount = cts.xport_specific.ata.bytecount; + } else { + if (cts.xport_specific.sata.valid & CTS_SATA_VALID_BYTECOUNT) + bytecount = cts.xport_specific.sata.bytecount; + } + /* Honor device capabilities. */ + sectors = max(1, min(ident_buf->sectors_intr & 0xff, + bytecount / ata_logical_sector_size(ident_buf))); /* Report bytecount to SIM. */ bzero(&cts, sizeof(cts)); xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL); @@ -414,6 +429,20 @@ cts.xport_specific.sata.valid = CTS_SATA_VALID_BYTECOUNT; } xpt_action((union ccb *)&cts); + /* Fetch current bytecount from SIM. */ + bzero(&cts, sizeof(cts)); + xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL); + cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS; + cts.type = CTS_TYPE_CURRENT_SETTINGS; + xpt_action((union ccb *)&cts); + if (path->device->transport == XPORT_ATA) { + if (cts.xport_specific.ata.valid & CTS_ATA_VALID_BYTECOUNT) + bytecount = cts.xport_specific.ata.bytecount; + } else { + if (cts.xport_specific.sata.valid & CTS_SATA_VALID_BYTECOUNT) + bytecount = cts.xport_specific.sata.bytecount; + } + sectors = bytecount / ata_logical_sector_size(ident_buf); cam_fill_ataio(ataio, 1, @@ -427,6 +456,45 @@ break; } case PROBE_INQUIRY: + { + u_int bytecount; + + bytecount = 8192; /* SATA maximum */ + /* Fetch user bytecount from SIM. */ + bzero(&cts, sizeof(cts)); + xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL); + cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS; + cts.type = CTS_TYPE_USER_SETTINGS; + xpt_action((union ccb *)&cts); + if (path->device->transport == XPORT_ATA) { + if (cts.xport_specific.ata.valid & CTS_ATA_VALID_BYTECOUNT) + bytecount = cts.xport_specific.ata.bytecount; + } else { + if (cts.xport_specific.sata.valid & CTS_SATA_VALID_BYTECOUNT) + bytecount = cts.xport_specific.sata.bytecount; + } + /* Honor device capabilities. */ + bytecount &= ~1; + bytecount = max(2, min(65534, bytecount)); + if (ident_buf->satacapabilities != 0x0000 && + ident_buf->satacapabilities != 0xffff) { + bytecount = min(8192, bytecount); + } + /* Report bytecount to SIM. */ + bzero(&cts, sizeof(cts)); + xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL); + 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 = bytecount; + cts.xport_specific.ata.valid = CTS_ATA_VALID_BYTECOUNT; + } else { + cts.xport_specific.sata.bytecount = bytecount; + cts.xport_specific.sata.valid = CTS_SATA_VALID_BYTECOUNT; + } + xpt_action((union ccb *)&cts); + /* FALLTHROUGH */ + } case PROBE_FULL_INQUIRY: { u_int inquiry_len;