Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp324763pxk; Fri, 11 Sep 2020 07:58:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6UtZKxsp8nrhiXBDv8Z5jdLWjHUIVDyM+yujrBvxX10NoNFRsRoM4ytXeut1Rb/jOmQ2e X-Received: by 2002:a17:906:bb06:: with SMTP id jz6mr2548421ejb.248.1599836300859; Fri, 11 Sep 2020 07:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599836300; cv=none; d=google.com; s=arc-20160816; b=FrDp9CgMuoRt+sC4TeDSYXYuupZ/PEgklupToqjXqbMQh2Gf/8LCM1ME8hXC4RXf35 4Lkrz1Ydoc9+wxAGMpXdr1r5Leu5wPH/upi/NxPSZuBleewtT3f3SG6azWwbrIgWxz1A ar/QgzwYolp3kgBXXlCuG6dFYk8GCTjvbKBDTpBwAZRQTAlsSL8iFi5MlT6tFt+4uITd WJxe3SElvBydwAW+l1wg+BEeCAJibU0NCYKo6yPSEIP4TVvm/zHJSJlmnPkBd8nzKejn fHtoHFgWvFPzzdfcc5X9QLGhKCi5dr0kRoXYrt+1snHL4s42PFUGZuKAovposy5K94Y6 QQBw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xeNU14/iwnjGKBmjiTbPBvv6CZ+wEfBQ+DB2+2JNhY8=; b=otiuuETb78Zczr11gWCPOyBN/s1l+CC11X8zz/s+Z6jJx90B3PFm6y/T4Geeh+gf9H ENSIcz9w7mybpS5Ej7ewSepJDxLhcIVo57qAY+0SN1UTuR1Q0W16B9FbxHPsmi7dFHO+ ijAxrwTNLq7H329MCk2FhfSmnvDLi0F8kagOTuNEhLxuIUbco+LVzdnSSIKp100VYv9N toJx9ObdoiGOn/ohCYGyysi7Mbaq0UwyFLlF6fS5VtqNFRGkAX+T90dafFbE/OGprsE1 +y5y4bW1SvPTcwctQOzsFmg4Wrum7H7QNCE9Dazz3CncYbDQ1Q7bk+hRPU9XO+qdDaJD 34xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yw9ArAMJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si1464614edv.36.2020.09.11.07.57.58; Fri, 11 Sep 2020 07:58:20 -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; dkim=pass header.i=@kernel.org header.s=default header.b=yw9ArAMJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725921AbgIKO5I (ORCPT + 99 others); Fri, 11 Sep 2020 10:57:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:52782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbgIKNCU (ORCPT ); Fri, 11 Sep 2020 09:02:20 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 19A212223E; Fri, 11 Sep 2020 12:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829045; bh=8H8bi/4fqFJP5lm0n3vTS8BL9cueu8eUwd/feLHSsRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yw9ArAMJGgQZRacAof8SVKkbN6T4SZvUOehu/qb+vkUUIUNitde1jO63XxYc+DlkW RXfnz10j1PQ3bOwUWEKj3eIHUM4Ld/HkHKNCDQUSLg92r8bUIFDqc8LZWxGloKckrW 7Z9IxNhRAUiydCxf2BJFkt1hmf34h1Z5V5QTycBQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tejun Heo , Karthik Shivaram , Jens Axboe Subject: [PATCH 4.9 45/71] libata: implement ATA_HORKAGE_MAX_TRIM_128M and apply to Sandisks Date: Fri, 11 Sep 2020 14:46:29 +0200 Message-Id: <20200911122507.174382370@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122504.928931589@linuxfoundation.org> References: <20200911122504.928931589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tejun Heo commit 3b5455636fe26ea21b4189d135a424a6da016418 upstream. All three generations of Sandisk SSDs lock up hard intermittently. Experiments showed that disabling NCQ lowered the failure rate significantly and the kernel has been disabling NCQ for some models of SD7's and 8's, which is obviously undesirable. Karthik worked with Sandisk to root cause the hard lockups to trim commands larger than 128M. This patch implements ATA_HORKAGE_MAX_TRIM_128M which limits max trim size to 128M and applies it to all three generations of Sandisk SSDs. Signed-off-by: Tejun Heo Cc: Karthik Shivaram Cc: stable@vger.kernel.org Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/ata/libata-core.c | 5 ++--- drivers/ata/libata-scsi.c | 8 +++++++- include/linux/libata.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4371,9 +4371,8 @@ static const struct ata_blacklist_entry /* https://bugzilla.kernel.org/show_bug.cgi?id=15573 */ { "C300-CTFDDAC128MAG", "0001", ATA_HORKAGE_NONCQ, }, - /* Some Sandisk SSDs lock up hard with NCQ enabled. Reported on - SD7SN6S256G and SD8SN8U256G */ - { "SanDisk SD[78]SN*G", NULL, ATA_HORKAGE_NONCQ, }, + /* Sandisk SD7/8/9s lock up hard on large trims */ + { "SanDisk SD[789]*", NULL, ATA_HORKAGE_MAX_TRIM_128M, }, /* devices which puke on READ_NATIVE_MAX */ { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, }, --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2314,6 +2314,7 @@ static unsigned int ata_scsiop_inq_89(st static unsigned int ata_scsiop_inq_b0(struct ata_scsi_args *args, u8 *rbuf) { + struct ata_device *dev = args->dev; u16 min_io_sectors; rbuf[1] = 0xb0; @@ -2339,7 +2340,12 @@ static unsigned int ata_scsiop_inq_b0(st * with the unmap bit set. */ if (ata_id_has_trim(args->id)) { - put_unaligned_be64(65535 * ATA_MAX_TRIM_RNUM, &rbuf[36]); + u64 max_blocks = 65535 * ATA_MAX_TRIM_RNUM; + + if (dev->horkage & ATA_HORKAGE_MAX_TRIM_128M) + max_blocks = 128 << (20 - SECTOR_SHIFT); + + put_unaligned_be64(max_blocks, &rbuf[36]); put_unaligned_be32(1, &rbuf[28]); } --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -435,6 +435,7 @@ enum { ATA_HORKAGE_NO_NCQ_LOG = (1 << 23), /* don't use NCQ for log read */ ATA_HORKAGE_NOTRIM = (1 << 24), /* don't use TRIM */ ATA_HORKAGE_MAX_SEC_1024 = (1 << 25), /* Limit max sects to 1024 */ + ATA_HORKAGE_MAX_TRIM_128M = (1 << 26), /* Limit max trim size to 128M */ /* DMA mask for user DMA control: User visible values; DO NOT renumber */