Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp333298ybh; Sat, 18 Jul 2020 05:32:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpMgSmRVjsVW+TdBcfa/UMJ9wYI9ALXxSAQdDq/zO5DBiNBWEyrB9GtsFCgesr7d3rYFvn X-Received: by 2002:a17:906:4050:: with SMTP id y16mr13288835ejj.541.1595075578182; Sat, 18 Jul 2020 05:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595075578; cv=none; d=google.com; s=arc-20160816; b=I/oC0ZfqzA0RuR2vvfAvXwzAO91X6fN1n/dFBS2jBrXNBBHJRCNCx1EZ+s6G4FbxrR 6PIZI+aywrxZi/HqHoPqJweEfM197KLg0M5aBoEbvwCylcivpcOpMObpja+oaxITumBb yUY4UaE0mc09mrp20i1ZWN9fYWvduURQQYBjYnwX1FOhfmvOskHT+j8TSLL6JKSiCT+L WDC5OSo2dd7H0uY2kqpiHjKzKBRRR+LwwHXiF6HXfowVuvJUNlE28hlemaW/AuAFkmhA hjEGooOojhoOoLQ8VpmmiIgF+Zry4KBGC6LTgMab7J0afwcdckpvlRWhnorwNUUnYKZ8 1iDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=WW3JHOJpG1oFfN35pbDS3rUkj/3BW1ohyYmfdomhkuo=; b=GayTqjRL3Zpad7h5KfCFpLkvaiszcL4ChhLE/8d5iWW54Znn+3YqygaOHuZ2X6Rf8F SoFp6nim+zf/U3Pg2Pod30wmFQzq+MfzWLtd2tbx+yYZYPnB/tgKK5k6bvFA2kOdKilB Ike7xsDDO0u7lrMgycFwwjfXTfvwdkQjoFFKtLZRCDQnwIiOh/ufXELxfTy1Z8oWsSV+ 2AQj49IW1ExElfKzU8npEA5tj00bQIjh/VlaVvk2LU9Q3MIsFQCTe2n2jAPVh5viToBJ AWOrjUXXBgN7oWE/b2hNZa195ww51iRrajFGFaCTMXwL3LE+PwIQ9ZrAhTfYHuVpDgZb u3vA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si6895842ejw.53.2020.07.18.05.32.34; Sat, 18 Jul 2020 05:32:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726777AbgGRMcU (ORCPT + 99 others); Sat, 18 Jul 2020 08:32:20 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:53360 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbgGRMcU (ORCPT ); Sat, 18 Jul 2020 08:32:20 -0400 Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.93.0.4) (envelope-from ) id 1jwm0m-0004fW-J7; Sat, 18 Jul 2020 14:32:16 +0200 From: "Maciej S. Szmigiero" To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] hwmon: (drivetemp) Avoid SCT usage on Toshiba DT01ACA family drives Date: Sat, 18 Jul 2020 14:32:10 +0200 Message-Id: <0cb2e7022b66c6d21d3f189a12a97878d0e7511b.1595075458.git.mail@maciej.szmigiero.name> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It has been observed that Toshiba DT01ACA family drives have WRITE FPDMA QUEUED command timeouts and sometimes just freeze until power-cycled under heavy write loads when their temperature is getting polled in SCT mode. The SMART mode seems to be fine, though. Let's make sure we don't use SCT mode for these drives then. While only the 3 TB model was actually caught exhibiting the problem let's play safe here to avoid data corruption and extend the ban to the whole family. Fixes: 5b46903d8bf3 ("hwmon: Driver for disk and solid state drives with temperature sensors") Cc: stable@vger.kernel.org Signed-off-by: Maciej S. Szmigiero --- Notes: This behavior was observed on two different DT01ACA3 drives. Usually, a series of queued WRITE FPDMA QUEUED commands just time out, but sometimes the whole drive freezes. Merely disconnecting and reconnecting SATA interface cable then does not unfreeze the drive. One has to disconnect and reconnect the drive power connector for the drive to be detected again (suggesting the drive firmware itself has crashed). This only happens when the drive temperature is polled very often (like every second), so occasional SCT usage via smartmontools is probably safe. Changes from v1: 'SCT blacklist' -> 'SCT avoid models' Changes from v2: * Switch to prefix matching and use it to match the DT01ACAx family, * Use "!" instead of "== 0", * Add a comment about the contents of the "model" field. drivers/hwmon/drivetemp.c | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/hwmon/drivetemp.c b/drivers/hwmon/drivetemp.c index 0d4f3d97ffc6..72c760373957 100644 --- a/drivers/hwmon/drivetemp.c +++ b/drivers/hwmon/drivetemp.c @@ -285,6 +285,42 @@ static int drivetemp_get_scttemp(struct drivetemp_data *st, u32 attr, long *val) return err; } +static const char * const sct_avoid_models[] = { +/* + * These drives will have WRITE FPDMA QUEUED command timeouts and sometimes just + * freeze until power-cycled under heavy write loads when their temperature is + * getting polled in SCT mode. The SMART mode seems to be fine, though. + * + * While only the 3 TB model (DT01ACA3) was actually caught exhibiting the + * problem let's play safe here to avoid data corruption and ban the whole + * DT01ACAx family. + + * The models from this array are prefix-matched. + */ + "TOSHIBA DT01ACA", +}; + +static bool drivetemp_sct_avoid(struct drivetemp_data *st) +{ + struct scsi_device *sdev = st->sdev; + unsigned int ctr; + + if (!sdev->model) + return false; + + /* + * The "model" field contains just the raw SCSI INQUIRY response + * "product identification" field, which has a width of 16 bytes. + * This field is space-filled, but is NOT NULL-terminated. + */ + for (ctr = 0; ctr < ARRAY_SIZE(sct_avoid_models); ctr++) + if (!strncmp(sdev->model, sct_avoid_models[ctr], + strlen(sct_avoid_models[ctr]))) + return true; + + return false; +} + static int drivetemp_identify_sata(struct drivetemp_data *st) { struct scsi_device *sdev = st->sdev; @@ -326,6 +362,13 @@ static int drivetemp_identify_sata(struct drivetemp_data *st) /* bail out if this is not a SATA device */ if (!is_ata || !is_sata) return -ENODEV; + + if (have_sct && drivetemp_sct_avoid(st)) { + dev_notice(&sdev->sdev_gendev, + "will avoid using SCT for temperature monitoring\n"); + have_sct = false; + } + if (!have_sct) goto skip_sct;