Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp116583pxb; Tue, 28 Sep 2021 16:58:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoVmdXaI1Ckf9vR+rZGXIiiKAlTY4+njXJTB2D5PbgJ6LhngjeGaZIv7A4VuG7tj9aZqP2 X-Received: by 2002:a05:6402:1b8d:: with SMTP id cc13mr11138676edb.235.1632873515069; Tue, 28 Sep 2021 16:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632873515; cv=none; d=google.com; s=arc-20160816; b=Kkxv+IA8L2ASKp8/vnLAk/VS1ui7Q4FOfndTdSgJ+SGaL/gelUTPg7R84rlk3ZekT5 6+zEesPk4AX+w/vEL2hnWnBDXHbi1Tra0CPUCepXZUqSsXZADT+FT+1tdlqO+2jHYCI2 GFxxuJKqUXees99Dxv9zMEDO9MIOOlUuxI5dtzxxFJuGvEf3cXz3dM4xOuAjtO4Ub6SB VhjOV6EV1UCHUjgNv5432TRoILlkwyAqhlUJ6b6U2AnspBIun5wnuakxTn+65Fz+7Sjf IqEuEe8g9qeO874ZWn5EaTGBH2zSG3iR/t4I99AvSO2cO3xUs3E6hOJupCTtM4Gm6ycG guhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:dkim-signature; bh=ON3U1YJ0uFV2d4ZGea9rZjKimy5cmUxEEM5T76KWOlE=; b=sFjfDkZa3liTpUe48DyxDOnQ8X29xNYcW+mdWs0AQCbOrOCfOlNxlAl1F2LAqc2rUn dhWX7X0kuTp0eleL3K74oq+EdHDW+j1ys4DD3amQuHMz5T+1+ExXr+AkIxlqJvHFkfeT 2rLEDnrIIhfqa9o6vROfsPe01E45oxOn+Zu0SlWwg+0e3vcUw9YaZZkItoVBet5w74Vb krFR92tYfbQxBAaGvcA93QqX+usB7c5oy17XNzTc5LJfA5sNUnFM4YkgJa3R1B4N2du9 oBmLOeEIWxOi4yCDsO1eSLU01IQ/0gieJPxShUm13BRhbCZ/pwggcd6Mi5q0YbKp3vwF 00Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=wo8YcL8z; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si1131937edd.121.2021.09.28.16.58.11; Tue, 28 Sep 2021 16:58:35 -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=fail header.i=@microchip.com header.s=mchp header.b=wo8YcL8z; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243544AbhI1X5P (ORCPT + 99 others); Tue, 28 Sep 2021 19:57:15 -0400 Received: from esa.microchip.iphmx.com ([68.232.153.233]:8293 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243340AbhI1X4Z (ORCPT ); Tue, 28 Sep 2021 19:56:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1632873285; x=1664409285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zdezOWEhW3/5HdpEPOhQOJHyudmdngHpbeuI1s44LkU=; b=wo8YcL8zjSfuPglORJnT+FPdKtK2KvpWG+pRwn6LELD9wzcjDTWGiZ1a lcNN7BeUB1G/kuqx5NL7o5g4zpDTbIsT2V5ioM0C+WYcjhyLv8zH/Dr/S 7OtjsJCjc/WvMKDmXh6d18RKWlDPuxdfALgn/IYrndsk/y3jsaosMWtSW 3mV/wY86GHCmn/23vmtyXU2zZ+YaaMPCn/w4K93iUp79VT5Mx9wSbuobJ mF0yqftf8o2ctjdjjoXO7e4srrfF/IrOCrb35AvRGlJcf4JJpCh9M80js l9pmES/CkqQrC0rCJXYMaLSiYg+MrXSHqdbt7SGIFovxOvVVurVKJcDOv g==; IronPort-SDR: 5nP//pEbyCTdZgnGZ3rslDBTxN7cInWKsdjOG5icIEtLsuMVS8OfF6ag/sBTOkT+Amz5nWSJiT I744TIC/sP95XWDrtQNXdpu5HTkE47gD/0IVeHGnQKJJPHb32mmOPVqni4Q+uhugWCbSi+TaDe 2SUy/+bmMADjBTNHKupfPn12XHy1ezY9v2kV1QIiT/pRInPca2QQS3mY//hVWdZGyDNPRYlWc7 eXxOs9fAd/YK7Ied46f0cDReR2N62RkiUi64Oqa6lt36Bd8OB9BDrJkVMhGyIFB7CKqBBSqVHA A82B1aPCcIU6gwO0nyFZpGw3 X-IronPort-AV: E=Sophos;i="5.85,330,1624345200"; d="scan'208";a="138333253" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Sep 2021 16:54:44 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Tue, 28 Sep 2021 16:54:42 -0700 Received: from brunhilda.pdev.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 28 Sep 2021 16:54:42 -0700 Received: by brunhilda.pdev.net (Postfix, from userid 1467) id 78042702883; Tue, 28 Sep 2021 18:54:42 -0500 (CDT) From: Don Brace To: , , , CC: , , , , , , , , , , , , , , , Subject: [smartpqi updates PATCH V2 05/11] smartpqi: add tur check for sanitize operation Date: Tue, 28 Sep 2021 18:54:36 -0500 Message-ID: <20210928235442.201875-6-don.brace@microchip.com> X-Mailer: git-send-email 2.28.0.rc1.9.ge7ae437ac1 In-Reply-To: <20210928235442.201875-1-don.brace@microchip.com> References: <20210928235442.201875-1-don.brace@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add in a TUR to HBA disks and do not present them to the OS if 0x02/0x04/0x1b (sanitize in progress) is returned. During boot-up, some OSes appear to hang when there are one or more disks undergoing sanitize. According to SCSI SBC4 specification section 4.11.2 Commands allowed during sanitize, some SCSI commands are permitted, but read/write operations are not. When the OS attempts to read the disk partition table a CHECK CONDITION ASC 0x04 ASCQ 0x1b is returned which causes the OS to retry the read until sanitize has completed. This can take hours. Note: According to document HPE Smart Storage Administrator User Guide Link: https://support.hpe.com/hpesc/public/docDisplay?docLocale=en_US&docId=c03909334 During the sanitize erase operation, the drive is unusable. I.E. The expected behavior for sanitize is the that disk remains offline even after sanitize has completed. The customer is expected to re-enable the disk using the management utility. Reviewed-by: Scott Benesh Reviewed-by: Scott Teel Reviewed-by: Mike McGowen Signed-off-by: Don Brace --- drivers/scsi/smartpqi/smartpqi_init.c | 87 +++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 01330fd67500..838274d8fadf 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -555,6 +555,10 @@ static int pqi_build_raid_path_request(struct pqi_ctrl_info *ctrl_info, cdb = request->cdb; switch (cmd) { + case TEST_UNIT_READY: + request->data_direction = SOP_READ_FLAG; + cdb[0] = TEST_UNIT_READY; + break; case INQUIRY: request->data_direction = SOP_READ_FLAG; cdb[0] = INQUIRY; @@ -1575,6 +1579,85 @@ static int pqi_get_logical_device_info(struct pqi_ctrl_info *ctrl_info, return rc; } +/* + * Prevent adding drive to OS for some corner cases such as a drive + * undergoing a sanitize operation. Some OSes will continue to poll + * the drive until the sanitize completes, which can take hours, + * resulting in long bootup delays. Commands such as TUR, READ_CAP + * are allowed, but READ/WRITE cause check condition. So the OS + * cannot check/read the partition table. + * Note: devices that have completed sanitize must be re-enabled + * using the management utility. + */ +static bool pqi_keep_device_offline(struct pqi_ctrl_info *ctrl_info, + struct pqi_scsi_dev *device) +{ + u8 scsi_status; + int rc; + enum dma_data_direction dir; + char *buffer; + int buffer_length = 64; + size_t sense_data_length; + struct scsi_sense_hdr sshdr; + struct pqi_raid_path_request request; + struct pqi_raid_error_info error_info; + bool offline = false; /* Assume keep online */ + + /* Do not check controllers. */ + if (pqi_is_hba_lunid(device->scsi3addr)) + return false; + + /* Do not check LVs. */ + if (pqi_is_logical_device(device)) + return false; + + buffer = kmalloc(buffer_length, GFP_KERNEL); + if (!buffer) + return false; /* Assume not offline */ + + /* Check for SANITIZE in progress using TUR */ + rc = pqi_build_raid_path_request(ctrl_info, &request, + TEST_UNIT_READY, RAID_CTLR_LUNID, buffer, + buffer_length, 0, &dir); + if (rc) + goto out; /* Assume not offline */ + + memcpy(request.lun_number, device->scsi3addr, sizeof(request.lun_number)); + + rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, 0, &error_info); + + if (rc) + goto out; /* Assume not offline */ + + scsi_status = error_info.status; + sense_data_length = get_unaligned_le16(&error_info.sense_data_length); + if (sense_data_length == 0) + sense_data_length = + get_unaligned_le16(&error_info.response_data_length); + if (sense_data_length) { + if (sense_data_length > sizeof(error_info.data)) + sense_data_length = sizeof(error_info.data); + + /* + * Check for sanitize in progress: asc:0x04, ascq: 0x1b + */ + if (scsi_status == SAM_STAT_CHECK_CONDITION && + scsi_normalize_sense(error_info.data, + sense_data_length, &sshdr) && + sshdr.sense_key == NOT_READY && + sshdr.asc == 0x04 && + sshdr.ascq == 0x1b) { + device->device_offline = true; + offline = true; + goto out; /* Keep device offline */ + } + } + +out: + kfree(buffer); + return offline; +} + static int pqi_get_device_info(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev *device, struct bmic_identify_physical_device *id_phys) @@ -2296,6 +2379,10 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info) if (!pqi_is_supported_device(device)) continue; + /* Do not present disks that the OS cannot fully probe */ + if (pqi_keep_device_offline(ctrl_info, device)) + continue; + /* Gather information about the device. */ rc = pqi_get_device_info(ctrl_info, device, id_phys); if (rc == -ENOMEM) { -- 2.28.0.rc1.9.ge7ae437ac1