Lines Matching +full:i +full:- +full:drive
1 // SPDX-License-Identifier: GPL-2.0
13 * This drive supports reporting the temperature of SATA drives. It can be
16 * The primary means to read drive temperatures and temperature limits
18 * ATA8-ACS.
19 * It can be used to read the current drive temperature, temperature limits,
21 * feature set is documented in "AT Attachment 8 - ATA/ATAPI Command Set
22 * (ATA8-ACS)".
24 * If the SCT Command Transport feature set is not available, drive temperatures
28 * There are three SMART attributes which may report drive temperatures.
30 * http://www.cropel.com/library/smart-attribute-list.aspx).
33 * the drive. Raw value typicaly holds the actual
37 * the drive. Raw value typicaly holds the actual
41 * the drive. Raw value typicaly holds the actual
46 * 190 Temperature Value is equal to (100-temp. °C), allowing manufacturer
49 * Temperature 100 being a best-case value and lower values being
58 * Temperature A normalized value of 100 represents a new drive, with
60 * replacement. A value of 0 may mean that the drive is
61 * operating in read-only mode to allow data recovery.
62 * Previously (pre-2010) occasionally used for Drive
70 * - SAMSUNG SV0412H and SAMSUNG SV1204H) report the temperature in 10th
72 * - A few Maxtor drives report an unknown or bad value in attribute 194.
73 * - Certain Apple SSD drives report an unknown value in attribute 190.
85 * drive temperatures. At the same time, several drives report SSD life left
92 * - Otherwise, if SMART attribute 194 is supported, it is used to read
94 * - Otherwise, if SMART attribute 190 is supported, it is used to read
172 scsi_cmd[1] = (5 << 1); /* PIO Data-out */ in drivetemp_scsi_command()
180 scsi_cmd[1] = (4 << 1); /* PIO Data-in */ in drivetemp_scsi_command()
195 return scsi_execute_cmd(st->sdev, scsi_cmd, op, st->smartdata, in drivetemp_scsi_command()
209 u8 *buf = st->smartdata; in drivetemp_get_smarttemp()
214 int i; in drivetemp_get_smarttemp() local
222 for (i = 0; i < ATA_SECT_SIZE; i++) in drivetemp_get_smarttemp()
223 csum += buf[i]; in drivetemp_get_smarttemp()
225 dev_dbg(&st->sdev->sdev_gendev, in drivetemp_get_smarttemp()
227 return -EIO; in drivetemp_get_smarttemp()
230 for (i = 0; i < ATA_MAX_SMART_ATTRS; i++) { in drivetemp_get_smarttemp()
231 u8 *attr = buf + i * 12; in drivetemp_get_smarttemp()
253 return -ENXIO; in drivetemp_get_smarttemp()
258 u8 *buf = st->smartdata; in drivetemp_get_scttemp()
267 return -ENODATA; in drivetemp_get_scttemp()
272 return -ENODATA; in drivetemp_get_scttemp()
277 return -ENODATA; in drivetemp_get_scttemp()
281 err = -EINVAL; in drivetemp_get_scttemp()
290 * freeze until power-cycled under heavy write loads when their temperature is
297 * The models from this array are prefix-matched.
304 struct scsi_device *sdev = st->sdev; in drivetemp_sct_avoid()
307 if (!sdev->model) in drivetemp_sct_avoid()
313 * This field is space-filled, but is NOT NULL-terminated. in drivetemp_sct_avoid()
316 if (!strncmp(sdev->model, sct_avoid_models[ctr], in drivetemp_sct_avoid()
325 struct scsi_device *sdev = st->sdev; in drivetemp_identify_sata()
326 u8 *buf = st->smartdata; in drivetemp_identify_sata()
338 /* SCSI-ATA Translation present? */ in drivetemp_identify_sata()
340 vpd = rcu_dereference(sdev->vpd_pg89); in drivetemp_identify_sata()
344 * VPD and that the drive implements the SATA protocol. in drivetemp_identify_sata()
346 if (!vpd || vpd->len < 572 || vpd->data[56] != ATA_CMD_ID_ATA || in drivetemp_identify_sata()
347 vpd->data[36] != 0x34) { in drivetemp_identify_sata()
349 return -ENODEV; in drivetemp_identify_sata()
351 ata_id = (u16 *)&vpd->data[60]; in drivetemp_identify_sata()
363 return -ENODEV; in drivetemp_identify_sata()
366 dev_notice(&sdev->sdev_gendev, in drivetemp_identify_sata()
387 st->have_temp_lowest = temp_is_valid(buf[SCT_STATUS_TEMP_LOWEST]); in drivetemp_identify_sata()
388 st->have_temp_highest = temp_is_valid(buf[SCT_STATUS_TEMP_HIGHEST]); in drivetemp_identify_sata()
394 memset(buf, '\0', sizeof(st->smartdata)); in drivetemp_identify_sata()
408 * Temperature limits per AT Attachment 8 - in drivetemp_identify_sata()
409 * ATA/ATAPI Command Set (ATA8-ACS) in drivetemp_identify_sata()
411 st->have_temp_max = temp_is_valid(buf[6]); in drivetemp_identify_sata()
412 st->have_temp_crit = temp_is_valid(buf[7]); in drivetemp_identify_sata()
413 st->have_temp_min = temp_is_valid(buf[8]); in drivetemp_identify_sata()
414 st->have_temp_lcrit = temp_is_valid(buf[9]); in drivetemp_identify_sata()
416 st->temp_max = temp_from_sct(buf[6]); in drivetemp_identify_sata()
417 st->temp_crit = temp_from_sct(buf[7]); in drivetemp_identify_sata()
418 st->temp_min = temp_from_sct(buf[8]); in drivetemp_identify_sata()
419 st->temp_lcrit = temp_from_sct(buf[9]); in drivetemp_identify_sata()
423 st->get_temp = drivetemp_get_scttemp; in drivetemp_identify_sata()
428 return -ENODEV; in drivetemp_identify_sata()
429 st->get_temp = drivetemp_get_smarttemp; in drivetemp_identify_sata()
435 struct scsi_device *sdev = st->sdev; in drivetemp_identify()
438 if (!sdev->inquiry || sdev->inquiry_len < 16) in drivetemp_identify()
439 return -ENODEV; in drivetemp_identify()
442 if (sdev->type != TYPE_DISK && sdev->type != TYPE_ZBC) in drivetemp_identify()
443 return -ENODEV; in drivetemp_identify()
455 return -EINVAL; in drivetemp_read()
461 mutex_lock(&st->lock); in drivetemp_read()
462 err = st->get_temp(st, attr, val); in drivetemp_read()
463 mutex_unlock(&st->lock); in drivetemp_read()
466 *val = st->temp_lcrit; in drivetemp_read()
469 *val = st->temp_min; in drivetemp_read()
472 *val = st->temp_max; in drivetemp_read()
475 *val = st->temp_crit; in drivetemp_read()
478 err = -EINVAL; in drivetemp_read()
496 if (st->have_temp_lowest) in drivetemp_is_visible()
500 if (st->have_temp_highest) in drivetemp_is_visible()
504 if (st->have_temp_min) in drivetemp_is_visible()
508 if (st->have_temp_max) in drivetemp_is_visible()
512 if (st->have_temp_lcrit) in drivetemp_is_visible()
516 if (st->have_temp_crit) in drivetemp_is_visible()
550 * The device argument points to sdev->sdev_dev. Its parent is
551 * sdev->sdev_gendev, which we can use to get the scsi_device pointer.
555 struct scsi_device *sdev = to_scsi_device(dev->parent); in drivetemp_add()
561 return -ENOMEM; in drivetemp_add()
563 st->sdev = sdev; in drivetemp_add()
564 st->dev = dev; in drivetemp_add()
565 mutex_init(&st->lock); in drivetemp_add()
568 err = -ENODEV; in drivetemp_add()
572 st->hwdev = hwmon_device_register_with_info(dev->parent, "drivetemp", in drivetemp_add()
575 if (IS_ERR(st->hwdev)) { in drivetemp_add()
576 err = PTR_ERR(st->hwdev); in drivetemp_add()
580 list_add(&st->list, &drivetemp_devlist); in drivetemp_add()
593 if (st->dev == dev) { in drivetemp_remove()
594 list_del(&st->list); in drivetemp_remove()
595 hwmon_device_unregister(st->hwdev); in drivetemp_remove()
620 MODULE_AUTHOR("Guenter Roeck <linus@roeck-us.net>");
621 MODULE_DESCRIPTION("Hard drive temperature monitor");