From owner-freebsd-current@FreeBSD.ORG Fri Jan 28 11:26:24 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6BD4516A4CE for ; Fri, 28 Jan 2005 11:26:24 +0000 (GMT) Received: from omgo.iij.ad.jp (omgo.iij.ad.jp [202.232.30.157]) by mx1.FreeBSD.org (Postfix) with ESMTP id E697543D39 for ; Fri, 28 Jan 2005 11:26:22 +0000 (GMT) (envelope-from shigeru@iij.ad.jp) Received: OMGO id j0SBQLe8004142; Fri, 28 Jan 2005 20:26:21 +0900 (JST) Received: OTM-MIX0 id j0SBQLUc008324; Fri, 28 Jan 2005 20:26:21 +0900 (JST) Received: JC-SMTP from localhost (mercury.iij.ad.jp [192.168.184.90]) for id j0SBQLwT005602; Fri, 28 Jan 2005 20:26:21 +0900 (JST) Date: Fri, 28 Jan 2005 20:26:20 +0900 (JST) Message-Id: <20050128.202620.28780845.shigeru@iij.ad.jp> To: freebsd-current@freebsd.org From: Yamamoto Shigeru X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_Jan_28_20:26:20_2005_540)--" Content-Transfer-Encoding: 7bit Subject: USB Memory support quick hack X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2005 11:26:24 -0000 ----Next_Part(Fri_Jan_28_20:26:20_2005_540)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi all, I write a small patch to support USB memory without adding an entry to da_quirk_table[]. Idea in this patch is disable SYNC_CACHE when synchronize cache failed. This new feature is controled by "kern.cam.da.fallback_no_sync_cache". I test my USB memory (TOSHIBA TransMemory) which is not in da_quirk_table[]. [test resutl] # sysctl kern.cam.da.fallback_no_sync_cache kern.cam.da.fallback_no_sync_cache: 0 # umass1: TOSHIBA TransMemory, rev 2.00/1.00, addr 2 da2 at umass-sim1 bus 1 target 0 lun 0 da2: Removable Direct Access SCSI-0 device da2: 1.000MB/s transfers da2: 240MB (492544 512 byte sectors: 64H 32S/T 240C) umass1: Phase Error, residue = 0 (da2:umass-sim1:1:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0 umass1: Phase Error, residue = 0 (da2:umass-sim1:1:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0 umass1: Phase Error, residue = 0 (da2:umass-sim1:1:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0 umass1: Phase Error, residue = 0 (da2:umass-sim1:1:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0 umass1: Phase Error, residue = 0 (da2:umass-sim1:1:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0 umass1: Phase Error, residue = 0 (da2:umass-sim1:1:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0 umass1: Phase Error, residue = 0 (da2:umass-sim1:1:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0 # sysctl -w kern.cam.da.fallback_no_sync_cache=1 kern.cam.da.fallback_no_sync_cache: 0 -> 1 # umass1: TOSHIBA TransMemory, rev 2.00/1.00, addr 2 da2 at umass-sim1 bus 1 target 0 lun 0 da2: Removable Direct Access SCSI-0 device da2: 1.000MB/s transfers da2: 240MB (492544 512 byte sectors: 64H 32S/T 240C) umass1: Phase Error, residue = 0 (da2:umass-sim1:1:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0 (da2:umass-sim1:1:0:0): Disable SYNC_CACHE If you have interest my patch, please try it. Thanks, ------- YAMAMOTO Shigeru ----Next_Part(Fri_Jan_28_20:26:20_2005_540)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="scsi_da.c.diff" Index: sys/cam/scsi/scsi_da.c =================================================================== RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/cam/scsi/scsi_da.c,v retrieving revision 1.173 diff -u -r1.173 scsi_da.c --- sys/cam/scsi/scsi_da.c 5 Jan 2005 22:34:34 -0000 1.173 +++ sys/cam/scsi/scsi_da.c 28 Jan 2005 08:19:15 -0000 @@ -348,6 +348,7 @@ static int da_retry_count = DA_DEFAULT_RETRY; static int da_default_timeout = DA_DEFAULT_TIMEOUT; +static int da_fallback_no_sync_cache = 0; SYSCTL_NODE(_kern_cam, OID_AUTO, da, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); @@ -357,6 +358,9 @@ SYSCTL_INT(_kern_cam_da, OID_AUTO, default_timeout, CTLFLAG_RW, &da_default_timeout, 0, "Normal I/O timeout (in seconds)"); TUNABLE_INT("kern.cam.da.default_timeout", &da_default_timeout); +SYSCTL_INT(_kern_cam_da, OID_AUTO, fallback_no_sync_cache, CTLFLAG_RW, + &da_fallback_no_sync_cache, 0, "Fallback to no sync cache"); +TUNABLE_INT("kern.cam.da.fallback_no_sync_cache", &da_fallback_no_sync_cache); /* * DA_ORDEREDTAG_INTERVAL determines how often, relative @@ -498,6 +502,11 @@ "== 0x%x, scsi status == 0x%x\n", ccb->csio.ccb_h.status, ccb->csio.scsi_status); + if (da_fallback_no_sync_cache) { + xpt_print_path(periph->path); + printf("Disable SYNC_CACHE\n"); + softc->quirks |= DA_Q_NO_SYNC_CACHE; + } } } @@ -669,6 +678,11 @@ printf("Synchronize cache failed, status " "== 0x%x, scsi status == 0x%x\n", csio.ccb_h.status, csio.scsi_status); + if (da_fallback_no_sync_cache) { + xpt_print_path(periph->path); + printf("Disable SYNC_CACHE\n"); + softc->quirks |= DA_Q_NO_SYNC_CACHE; + } } } } @@ -1818,6 +1832,11 @@ printf("Synchronize cache failed, status " "== 0x%x, scsi status == 0x%x\n", ccb.ccb_h.status, ccb.csio.scsi_status); + if (da_fallback_no_sync_cache) { + xpt_print_path(periph->path); + printf("Disable SYNC_CACHE\n"); + softc->quirks |= DA_Q_NO_SYNC_CACHE; + } } } ----Next_Part(Fri_Jan_28_20:26:20_2005_540)----