Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3709000ybv; Mon, 10 Feb 2020 05:06:28 -0800 (PST) X-Google-Smtp-Source: APXvYqxMMP/4mecgzdp3FfeoDvATAEGzLa4cJOeiZAKlnNb3nXNt2tQYs4PC1bxA7sHxU9gKaLZs X-Received: by 2002:aca:cdd5:: with SMTP id d204mr756702oig.134.1581339988461; Mon, 10 Feb 2020 05:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339988; cv=none; d=google.com; s=arc-20160816; b=q8fHmVEcXcY73i0oTjX7C2HZCeSIKThRITdhRGuxkGuDC/Q3bw/QwrFU1GQwaFKRV4 o1PpC4PdM6KuG/fhA3JCZT6E/Faw0Bys+LYQaKO4f4vjiX/M5xsUadAwsB/7F+4drxWl FxzHYTa+Yzy6dSrCkM9gy1q/ZHq0QhKzzuN2zwFzStNr1lFO/Sr90XVSGrt5148AOY/H 6hB0DrsmS0/Eqreb/zBWx7BNfhf28xf2wTpEnoYM0ovOuxPB0f5GPnwtNWzv81J8dzw/ 6WtHQbHTus06cMszO7vYI2zyhvVJd6ZiWdbiGU3bF5u8ER8gWmWkMGa1Cv2xa9lG2T/C 3Z3Q== 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=wTOTSisEDK3/Vf5FaCTPZMLakrTVl4Rwk1RsH4xd/gc=; b=rNh/Qi900ahN2Nk64qa7qEYGvemhfenqpGhtxYtOWyitlzdX5/T4/YUMDSUZ9r89/U dLR38ny2KX+ctIkMuYO2RzYOtBnMkjyPZ3umR0ewpb1s2UDMUVTra4AX1vr29NykwkSr 9Dw8dI/SDP84eTZOCGSCTiYCvJauiod3v1PybxVhmZTZzkso1nBZ3LLrwc5EnkBInOkb gHNLFFS3bsiaQtSt9f1GgA0z4piSBxEoxsLfAFL/rp7wt5OGLzcpdJSul58au28vFUBo uNKKk5/99ghJWMDrAZuo2mvxHmFDSOgU1guRZUdPIQRKTKOrp+fdy/vWRZlo1gHi6IIH 4DLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uT6Fx2ao; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d26si161810otc.6.2020.02.10.05.06.15; Mon, 10 Feb 2020 05:06:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uT6Fx2ao; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730345AbgBJNEg (ORCPT + 99 others); Mon, 10 Feb 2020 08:04:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:39770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729652AbgBJMkN (ORCPT ); Mon, 10 Feb 2020 07:40:13 -0500 Received: from localhost (unknown [209.37.97.194]) (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 8F7FC2051A; Mon, 10 Feb 2020 12:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338412; bh=KM0blz/sPOMcLJ1MQfWiz35/SGyUA2nMXUvLEnE2NGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uT6Fx2aop1FxhO8JDRleK6EntwO4jt3rOerWdzoTVTxJQ+xSBPdY7URqtlyu9eY7z 8bZg4csIMGtz/Apf1b2W39dNZKqqg0waqbZhMeUXiFXwzixEwc6OWuOuLEHPu8Sp2F 7tVYqNzN6GvM+PDDAN/Sc+11mHYdJaMUoUq1WWqg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shivasharan S , Anand Lodnoor , "Martin K. Petersen" Subject: [PATCH 5.5 124/367] scsi: megaraid_sas: Do not initiate OCR if controller is not in ready state Date: Mon, 10 Feb 2020 04:30:37 -0800 Message-Id: <20200210122436.271213720@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@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: Anand Lodnoor commit 6d7537270e3283b92f9b327da9d58a4de40fe8d0 upstream. Driver initiates OCR if a DCMD command times out. But there is a deadlock if the driver attempts to invoke another OCR before the mutex lock (reset_mutex) is released from the previous session of OCR. This patch takes care of the above scenario using new flag MEGASAS_FUSION_OCR_NOT_POSSIBLE to indicate if OCR is possible. Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/1579000882-20246-9-git-send-email-anand.lodnoor@broadcom.com Signed-off-by: Shivasharan S Signed-off-by: Anand Lodnoor Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/megaraid/megaraid_sas_base.c | 3 ++- drivers/scsi/megaraid/megaraid_sas_fusion.c | 3 ++- drivers/scsi/megaraid/megaraid_sas_fusion.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4392,7 +4392,8 @@ dcmd_timeout_ocr_possible(struct megasas if (instance->adapter_type == MFI_SERIES) return KILL_ADAPTER; else if (instance->unload || - test_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags)) + test_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, + &instance->reset_flags)) return IGNORE_TIMEOUT; else return INITIATE_OCR; --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -4847,6 +4847,7 @@ int megasas_reset_fusion(struct Scsi_Hos if (instance->requestorId && !instance->skip_heartbeat_timer_del) del_timer_sync(&instance->sriov_heartbeat_timer); set_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); + set_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, &instance->reset_flags); atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_POLLING); instance->instancet->disable_intr(instance); megasas_sync_irqs((unsigned long)instance); @@ -5046,7 +5047,7 @@ kill_hba: instance->skip_heartbeat_timer_del = 1; retval = FAILED; out: - clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); + clear_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, &instance->reset_flags); mutex_unlock(&instance->reset_mutex); return retval; } --- a/drivers/scsi/megaraid/megaraid_sas_fusion.h +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h @@ -89,6 +89,7 @@ enum MR_RAID_FLAGS_IO_SUB_TYPE { #define MEGASAS_FP_CMD_LEN 16 #define MEGASAS_FUSION_IN_RESET 0 +#define MEGASAS_FUSION_OCR_NOT_POSSIBLE 1 #define RAID_1_PEER_CMDS 2 #define JBOD_MAPS_COUNT 2 #define MEGASAS_REDUCE_QD_COUNT 64