xref: /titanic_44/usr/src/man/man9f/pm_trans_check.9f (revision 5fd03bc0f2e00e7ba02316c2e08f45d52aab15db)
te
Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
PM_TRANS_CHECK 9F "Jul 16, 2009"
NAME
pm_trans_check - Device power cycle advisory check
SYNOPSIS

#include <sys/sunddi.h>

int pm_trans_check(struct pm_trans_data *datap, time_t *intervalp);
INTERFACE LEVEL

Solaris DDI specific (Solaris DDI)

PARAMETERS
datap

Pointer to a pm_trans_data structure

intervalp

Pointer to time difference when next power cycle will be advised

DESCRIPTION

The pm_trans_check() function checks if a power-cycle is currently advised based on data in the pm_trans_data structure. This function is provided to prevent damage to devices from excess power cycles; drivers for devices that are sensitive to the number of power cycles should call pm_trans_check() from their power(9E) function before powering-off a device. If pm_trans_check() indicates that the device should not be power cycled, the driver should not attempt to power cycle the device and should fail the call to power(9E) entry point.

If pm_trans_check() returns that it is not advised to power cycle the device, it attempts to calculate when the next power cycle is advised, based on the supplied parameters. In such case, intervalp returns the time difference (in seconds) from the current time to when the next power cycle is advised. If the time for the next power cycle cannot be determined, intervalp indicates 0.

To avoid excessive calls to the power(9E) entry point during a period when power cycling is not advised, the driver should mark the corresponding device component busy for the intervalp time period (if interval is not 0). Conveniently, the driver can utilize the fact that calls to pm_busy_component(9F) are stacked. If power cycling is not advised, the driver can call pm_busy_component(9F) and issue a timeout(9F) for the intervalp time. The timeout() handler can issue the corresponding pm_idle_component(9F) call.

The format field of pm_trans_data accepts either DC_SCSI_FORMAT or DC_SMART_FORMAT. If the caller provides information from a SCSI Log Page, it should set the format field to DC_SCSI_FORMAT, and provide valid data in svc_date[], lifemax, ncycles and flag in the pm_scsi_cycles structure. If the caller provides information from a SMART feature attribute, it should set the format field to DC_SMART_FORMAT and provide valid data in allowed, usedup and flag in the pm_smart_count structure, where allowed indicates the normalized cycle count before reaching the borderline threshold cycle count, and usedup indicates the normalized consumed cycle count.

The flag field in both pm_scsi_cycles and pm_smart_count structures is reserved for future use and must be set to 0.

struct pm_trans_data {
 int format; /* data format */
 union {
 struct pm_scsi_cycles scsi_cycles;
 struct pm_smart_count smart_count;
 } un;
};
RETURN VALUES
1

Power cycle is advised.

0

Power cycle is not advised.

-1

Error due to invalid argument.

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Committed
SEE ALSO

power.conf(4), attributes(5), power(9E)

Writing Device Drivers

Using Power Management