Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2669337pxj; Mon, 31 May 2021 07:52:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo45U5Ph0lIVw6YUMCTAf04tjEZPwj07wT+A3pOdO/4m4e4VL2fGZhxTF6G2kGbmkK+FLv X-Received: by 2002:a05:6e02:5a3:: with SMTP id k3mr4988744ils.302.1622472743554; Mon, 31 May 2021 07:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472743; cv=none; d=google.com; s=arc-20160816; b=v1Z4+pTl+DQzDm5gUpTQsHoAUyFCXP7WVo6T4enw/W51sAmDTinfWibgSEZoVnIW47 MGsbMAVXp/nQvPnoPjEw0wVI3z4EPvGlhQdI7Dz5FfSaZ2ZK5LgoebZrTrbfLJjU95Tk IyHgX0+Tf+tbX9Vw/dNT92/VXgax/GMNKwfNCQOj/lcZinth9f41hMQHI5xIkCcuoXcG HU3UGsuc3brMRl7DlgJmUK0m3FM7alfMEiRxEKQM2RrU4/GnK/7XAq9ZM2As7ShU359C +zs0QaAm3Cqsal6ThhNKvXIbdCwu708MVixutwDL3EKxjxoMvqn1Aqrlxx8mGllvHu6s gygQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=urdaeZIpxDLnKCiKlYCQbQlKPebju53S4b1iCL9mnYg=; b=yEgHWpkkI4wnkM/x/EdPMnpSOm1eLcN8DIZ2NlrkBOcVrqikCAEKgXD5yLnJu52mOC GKezIicJDsQgfJbSU3efTmcqfS9r/o5WGjmCZXXLjWH/c4EOqtS+bV2YHMsRyco19cjV wbD8jO49nQNi+Ro0NdosyfzLZnfOpqMTAKnvSBQT49T0cjnSzS6iy4kTyGxuDl0eByig sdnDjIa2b+Rg6P+EJlrt7ZM5hadsVlAJEzZaopTxZEjGx1MHpz7AmNVFPy8pWWGkC6yz t40Kwz6j8m2oMOkO1/Uj3sVDRPsAF4yAFtwuU/QIAYA0eJn0l2Q0ReDr9/NRFyIp0kKU mfjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EqJpYngt; 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=pass (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 v7si14225084jal.113.2021.05.31.07.52.10; Mon, 31 May 2021 07:52:23 -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=@linuxfoundation.org header.s=korg header.b=EqJpYngt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233015AbhEaOxN (ORCPT + 99 others); Mon, 31 May 2021 10:53:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:36738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233179AbhEaODM (ORCPT ); Mon, 31 May 2021 10:03:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 152136194F; Mon, 31 May 2021 13:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468253; bh=1/KlnCRWtF0vKGhkPgGjzun0pYQzldw/2erBmmt1otM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EqJpYngtkqQQ8iGsk9eKLYsT6YX/vITP85QG7mDhH07SfS/ZcUe+2plF+hTeFuGeB DhhNFRxF69ZbQJvwaKQ7T9dVRHOf5u+Cdi0wIvKHvLLFmEZd4yVivkiPZhtSZ/Mspy avwuUwk+ee8dLq+ZHEl9mD+lByPww9/M1Ud8HlO4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ajish Koshy , Viswas G , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 174/252] scsi: pm80xx: Fix drives missing during rmmod/insmod loop Date: Mon, 31 May 2021 15:13:59 +0200 Message-Id: <20210531130703.916733392@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ajish Koshy [ Upstream commit d1acd81bd6eb685aa9fef25624fb36d297f6404e ] When driver is loaded after rmmod some drives are not showing up during discovery. SATA drives are directly attached to the controller connected phys. During device discovery, the IDENTIFY command (qc timeout (cmd 0xec)) is timing out during revalidation. This will trigger abort from host side and controller successfully aborts the command and returns success. Post this successful abort response ATA library decides to mark the disk as NODEV. To overcome this, inside pm8001_scan_start() after phy_start() call, add get start response and wait for few milliseconds to trigger next phy start. This millisecond delay will give sufficient time for the controller state machine to accept next phy start. Link: https://lore.kernel.org/r/20210505120103.24497-1-ajish.koshy@microchip.com Signed-off-by: Ajish Koshy Signed-off-by: Viswas G Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/pm8001/pm8001_hwi.c | 10 ++++++---- drivers/scsi/pm8001/pm8001_init.c | 2 +- drivers/scsi/pm8001/pm8001_sas.c | 7 ++++++- drivers/scsi/pm8001/pm80xx_hwi.c | 12 ++++++------ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 355d1c5f2194..2114d2dd3501 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -3703,11 +3703,13 @@ static int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void* piomb) case HW_EVENT_PHY_START_STATUS: pm8001_dbg(pm8001_ha, MSG, "HW_EVENT_PHY_START_STATUS status = %x\n", status); - if (status == 0) { + if (status == 0) phy->phy_state = 1; - if (pm8001_ha->flags == PM8001F_RUN_TIME && - phy->enable_completion != NULL) - complete(phy->enable_completion); + + if (pm8001_ha->flags == PM8001F_RUN_TIME && + phy->enable_completion != NULL) { + complete(phy->enable_completion); + phy->enable_completion = NULL; } break; case HW_EVENT_SAS_PHY_UP: diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 7657d68e12d5..0c0c886c7371 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1139,8 +1139,8 @@ static int pm8001_pci_probe(struct pci_dev *pdev, goto err_out_shost; } list_add_tail(&pm8001_ha->list, &hba_list); - scsi_scan_host(pm8001_ha->shost); pm8001_ha->flags = PM8001F_RUN_TIME; + scsi_scan_host(pm8001_ha->shost); return 0; err_out_shost: diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 474468df2a78..39de9a9360d3 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -264,12 +264,17 @@ void pm8001_scan_start(struct Scsi_Host *shost) int i; struct pm8001_hba_info *pm8001_ha; struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); + DECLARE_COMPLETION_ONSTACK(completion); pm8001_ha = sha->lldd_ha; /* SAS_RE_INITIALIZATION not available in SPCv/ve */ if (pm8001_ha->chip_id == chip_8001) PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha); - for (i = 0; i < pm8001_ha->chip->n_phy; ++i) + for (i = 0; i < pm8001_ha->chip->n_phy; ++i) { + pm8001_ha->phy[i].enable_completion = &completion; PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i); + wait_for_completion(&completion); + msleep(300); + } } int pm8001_scan_finished(struct Scsi_Host *shost, unsigned long time) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 27b354860a16..a203a4fc2674 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -3432,13 +3432,13 @@ static int mpi_phy_start_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_dbg(pm8001_ha, INIT, "phy start resp status:0x%x, phyid:0x%x\n", status, phy_id); - if (status == 0) { + if (status == 0) phy->phy_state = PHY_LINK_DOWN; - if (pm8001_ha->flags == PM8001F_RUN_TIME && - phy->enable_completion != NULL) { - complete(phy->enable_completion); - phy->enable_completion = NULL; - } + + if (pm8001_ha->flags == PM8001F_RUN_TIME && + phy->enable_completion != NULL) { + complete(phy->enable_completion); + phy->enable_completion = NULL; } return 0; -- 2.30.2