From nobody@FreeBSD.org  Mon Nov  1 17:23:44 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 114081065675
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  1 Nov 2010 17:23:44 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id F3D4E8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  1 Nov 2010 17:23:43 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id oA1HNhI5016942
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 1 Nov 2010 17:23:43 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id oA1HNhl7016935;
	Mon, 1 Nov 2010 17:23:43 GMT
	(envelope-from nobody)
Message-Id: <201011011723.oA1HNhl7016935@www.freebsd.org>
Date: Mon, 1 Nov 2010 17:23:43 GMT
From: Bruce Cran <brucec@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: camcontrol(8): incorrect standby timer calculation
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         151871
>Category:       bin
>Synopsis:       [cam] camcontrol(8): incorrect standby timer calculation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brucec
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 01 17:30:09 UTC 2010
>Closed-Date:    Fri Nov 12 11:49:49 UTC 2010
>Last-Modified:  Fri Nov 12 11:49:49 UTC 2010
>Originator:     Bruce Cran
>Release:        9.0-CURRENT
>Organization:
>Environment:
FreeBSD core.nessbank 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r214509: Fri Oct 29 13:26:38 BST 2010     brucec@core.nessbank:/usr/obj/usr/src/head/sys/CORE  amd64
>Description:
Incorrect standby timer values are sent to the disk. According to t13, the values should be:

1-1200 seconds: (seconds / 5)
1260 seconds: 252
1800-19800 seconds: (minutes/30) + 240

Currently a timeout value of 1800s (30 minutes) is being programmed as 242, which will cause the drive to go into standby after 60 minutes.
>How-To-Repeat:
Compare the code on line 4315 of src/sbin/camcontrol/camcontrol.c with table 19 in T13 1532D Volume 1.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-scsi 
Responsible-Changed-By: arundel 
Responsible-Changed-When: Tue Nov 2 00:47:55 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151871 
State-Changed-From-To: open->patched  
State-Changed-By: brucec 
State-Changed-When: Thu Nov 4 15:26:29 UTC 2010 
State-Changed-Why:  
Fixed in r214781. 


Responsible-Changed-From-To: freebsd-scsi->brucec  
Responsible-Changed-By: brucec 
Responsible-Changed-When: Thu Nov 4 15:26:29 UTC 2010 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151871 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/151871: commit references a PR
Date: Thu,  4 Nov 2010 15:24:38 +0000 (UTC)

 Author: brucec
 Date: Thu Nov  4 15:24:32 2010
 New Revision: 214781
 URL: http://svn.freebsd.org/changeset/base/214781
 
 Log:
   Fix standby timer calculation: the timer was being set 30 minutes later
   than the user requested.
   Also, 21 minutes is encoded as 252 and 22-29 minutes cannot be encoded
   so must be rounded up to 30.
   
   PR:	bin/151871
 
 Modified:
   head/sbin/camcontrol/camcontrol.c
 
 Modified: head/sbin/camcontrol/camcontrol.c
 ==============================================================================
 --- head/sbin/camcontrol/camcontrol.c	Thu Nov  4 12:33:07 2010	(r214780)
 +++ head/sbin/camcontrol/camcontrol.c	Thu Nov  4 15:24:32 2010	(r214781)
 @@ -4316,10 +4316,17 @@ atapm(struct cam_device *device, int arg
  		sc = 0;
  	else if (t <= (240 * 5))
  		sc = t / 5;
 +	else if (t == (252 * 5))
 +		/* special encoding for 21 minutes */
 +		sc = 252;
 +	else if (t < (30 * 60))
 +		/* no encoding exists for 22-29 minutes, so set to 30 mins */
 +		sc = 241;
  	else if (t <= (11 * 30 * 60))
 -		sc = t / (30 * 60) + 241;
 +		sc = t / (30 * 60) + 240;
  	else
  		sc = 253;
 +
  	cam_fill_ataio(&ccb->ataio,
  		      retry_count,
  		      NULL,
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/151871: commit references a PR
Date: Fri, 12 Nov 2010 11:36:18 +0000 (UTC)

 Author: brucec
 Date: Fri Nov 12 11:36:12 2010
 New Revision: 215174
 URL: http://svn.freebsd.org/changeset/base/215174
 
 Log:
   MFC r214781, r214807:
   
   Improve rounding of standby timer.
   22-29 minutes can't be encoded so must be rounded up to 30.
   
   PR:	bin/151871
 
 Modified:
   stable/8/sbin/camcontrol/camcontrol.c
 Directory Properties:
   stable/8/sbin/camcontrol/   (props changed)
 
 Modified: stable/8/sbin/camcontrol/camcontrol.c
 ==============================================================================
 --- stable/8/sbin/camcontrol/camcontrol.c	Fri Nov 12 11:22:59 2010	(r215173)
 +++ stable/8/sbin/camcontrol/camcontrol.c	Fri Nov 12 11:36:12 2010	(r215174)
 @@ -4302,14 +4302,19 @@ atapm(struct cam_device *device, int arg
  		cmd = ATA_SLEEP;
  		t = -1;
  	}
 +
  	if (t < 0)
  		sc = 0;
  	else if (t <= (240 * 5))
 -		sc = t / 5;
 +		sc = (t + 4) / 5;
 +	else if (t <= (252 * 5))
 +		/* special encoding for 21 minutes */
 +		sc = 252;
  	else if (t <= (11 * 30 * 60))
 -		sc = t / (30 * 60) + 241;
 +		sc = (t - 1) / (30 * 60) + 241;
  	else
  		sc = 253;
 +
  	cam_fill_ataio(&ccb->ataio,
  		      retry_count,
  		      NULL,
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: brucec 
State-Changed-When: Fri Nov 12 11:49:25 UTC 2010 
State-Changed-Why:  
Fix committed to HEAD and stable/8. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151871 
>Unformatted:
