From patchwork Wed Feb 24 15:57:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 387520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A8C4C433DB for ; Wed, 24 Feb 2021 16:10:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDFF764EDD for ; Wed, 24 Feb 2021 16:10:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234363AbhBXQJu (ORCPT ); Wed, 24 Feb 2021 11:09:50 -0500 Received: from esa.microchip.iphmx.com ([68.232.153.233]:38001 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236635AbhBXPt5 (ORCPT ); Wed, 24 Feb 2021 10:49:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1614181791; x=1645717791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=nI5/bg6No1F8JoRKUbYwabAkQJqZx4lwIVciE3yr8Zw=; b=UQ4mtdpTdn5caoyCXtKLi2J4fi9DzzUS5AZzd7IiiEBRMTPe3SOM4V7h nhMeYNDh2KkNc810vMHaLNpW0Pcm19zcZpU0r2xQFeudzzKUEeodaCfaH fAsFoi5E7VDexar9p/nTbVNtdC+3bWQJahj3VZ3W7WsZ1QF3D91oewTTS T+pxkzB8EiPmFcndCe2NzYbEq5tVV9rDIOTYAiW8GsjOOpEY/P8mY74nv K6hIkNdOtWbAMirm4yRQZwLbmaG1O1JdeIxfigyDPwxdTmKfphnYTsFp9 UKIL/LEeHjX+ioc3jGxJ9Z+SstX/K1e58+7HHSyxMeApmuldETZ1VK2wQ w==; IronPort-SDR: wDWqeJ8zwX4ieTd/d/GsWfsykfdy7mU/3E8l4Km30UsDNT2OZXrXphVtQrA31sFT/VpLBHYII5 Aw2WJTptmHWj3ehzMeDWUgr4nXuEvLC5gVwouUbNAe3+vG0nLByHwY+0T/mZh4FsPES5pAiZQL gtFK5AMIhzl25jC990zlSLwQdkIdEUUaUSi2X3OnXY/wGZV+IFtU6N1eSyVbRXK3HgXtAtZsmL RxbQ2yqZ8Gr7UNIOTc6hVdLckQa0H5oneI/msfnZey/fClcv03Tx9yA5z9wOTv9gtQeSio7BKR b1s= X-IronPort-AV: E=Sophos;i="5.81,203,1610434800"; d="scan'208";a="116451446" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Feb 2021 08:48:18 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 24 Feb 2021 08:48:18 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 24 Feb 2021 08:48:18 -0700 From: Viswas G To: CC: , , , , , Subject: [PATCH 1/7] pm80xx: Add sysfs attribute to check mpi state Date: Wed, 24 Feb 2021 21:27:56 +0530 Message-ID: <20210224155802.13292-2-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210224155802.13292-1-Viswas.G@microchip.com> References: <20210224155802.13292-1-Viswas.G@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Vishakha Channapattan A new sysfs variable 'ctl_mpi_state' is being introduced to check the state of mpi. Tested: Using 'ctl_mpi_state' sysfs variable we check the mpi state mvae14:~# cat /sys/class/scsi_host/host*/ctl_mpi_state MPI-S=MPI is successfully initialized HMI_ERR=0 MPI-S=MPI is successfully initialized HMI_ERR=0 Signed-off-by: Vishakha Channapattan Signed-off-by: Viswas G Signed-off-by: Ruksar Devadi Signed-off-by: Ashokkumar N Signed-off-by: Radha Ramachandran --- drivers/scsi/pm8001/pm8001_ctl.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 12035baf0997..035969ed1c2e 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -41,6 +41,7 @@ #include #include "pm8001_sas.h" #include "pm8001_ctl.h" +#include "pm8001_chips.h" /* scsi host attributes */ @@ -883,9 +884,41 @@ static ssize_t pm8001_show_update_fw(struct device *cdev, flash_error_table[i].err_code, flash_error_table[i].reason); } - static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP, pm8001_show_update_fw, pm8001_store_update_fw); + +/** + * ctl_mpi_state_show - controller MPI state check + * @cdev: pointer to embedded class device + * @buf: the buffer returned + * + * A sysfs 'read-only' shost attribute. + */ + +char mpiStateText[][80] = { + "MPI is not initialized", + "MPI is successfully initialized", + "MPI termination is in progress", + "MPI initialization failed with error in [31:16]" +}; + +static ssize_t ctl_mpi_state_show(struct device *cdev, + struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(cdev); + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); + struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + unsigned int mpidw0 = 0; + int c; + + pm8001_dbg(pm8001_ha, IOCTL, "%s\n", __func__); + mpidw0 = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 0); + c = sprintf(buf, "MPI-S=%s\t HMI_ERR=%x\n", mpiStateText[mpidw0 & 0x0003], + ((mpidw0 & 0xff00) >> 16)); + return c; +} +static DEVICE_ATTR_RO(ctl_mpi_state); + struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, @@ -909,6 +942,7 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_ob_log, &dev_attr_ila_version, &dev_attr_inc_fw_ver, + &dev_attr_ctl_mpi_state, NULL, }; From patchwork Wed Feb 24 15:57:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 387517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14FEFC433E0 for ; Wed, 24 Feb 2021 16:11:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE7A764EDD for ; Wed, 24 Feb 2021 16:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235460AbhBXQLS (ORCPT ); Wed, 24 Feb 2021 11:11:18 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:18228 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236897AbhBXPyX (ORCPT ); Wed, 24 Feb 2021 10:54:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1614182061; x=1645718061; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=stIfhMc4/lme2/zXtnuz/DIVw9VyUA5VTfTReLh0opA=; b=gF9vAT7yd81dORvc5nyP54GWYZ057FMu9qUaRsEeyWE7miYb1+kaBQsi K1XjouFsiZ2Lmqg4wgIJwJIYle6mLbIwA/hjss1vDoVq/Pi1Vs/pKoLps ktSRKBkUst7B20DEZnad9+FhdEdoJAgfGfbazJ8cskQNS/WAoLMumihrm ZZqiVqkyg+FkbSqceHfhifWMpc+ZJodPp/MmWPw3pKwv8q8Kbb9AJKnws 5XZv7GIg/1oEIjOWh8A0NIRjxypFvZqY+fmSo6yd/X3y7ZM3JJQ8eTAg+ 5NjhrrBLHvrpeAKrh3dqIWHpByI2pj5YMs2zDZmC29hdDVLhegIjarW+R Q==; IronPort-SDR: bFtJYiqIHmYxsiXvGU3fq03R4qYRkH6Uw7bdql5Dkr7sXqZYluAOZbbBgPasaqzbUHDLTJ9bW3 jl9mtTJzlo5oa5RHXTwYXJLdP91sFqUSKCosoguuPpxgzOWgXUYBHFx8tzrq6ZLeDH6OwE/hoI rpI5WyBf7r5mLYXhLD3AYaN5e4rSYudV//HLSQnY17Ourdr4jNqgoS4R+boC3MenVhfQkyi61d rzG/FS4Q+RxDnqp+90QeSYWYLBaGj6y/SiLB4v9grAju6AYgPbTU+rzNetnLSzR9fZG3tBvsqr gA4= X-IronPort-AV: E=Sophos;i="5.81,203,1610434800"; d="scan'208";a="107803947" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Feb 2021 08:48:26 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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.1979.3; Wed, 24 Feb 2021 08:48:20 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 24 Feb 2021 08:48:19 -0700 From: Viswas G To: CC: , , , , , Subject: [PATCH 2/7] pm80xx: Add sysfs attribute to track RAAE count Date: Wed, 24 Feb 2021 21:27:57 +0530 Message-ID: <20210224155802.13292-3-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210224155802.13292-1-Viswas.G@microchip.com> References: <20210224155802.13292-1-Viswas.G@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Vishakha Channapattan A new sysfs variable 'ctl_raae_count' is being introduced that tells if the controller is alive by indicating controller ticks. If on subsequent run we see the ticks changing in RAAE count that indicates that controller is not dead. Tested: Using 'ctl_raae_count' sysfs variable we can see ticks incrementing mvae14:~# cat /sys/class/scsi_host/host*/ctl_raae_count MSGUTCNT=0x00002245 MSGUTCNT=0x00002253 MSGUTCNT=0x0000225e Signed-off-by: Vishakha Channapattan Signed-off-by: Viswas G Signed-off-by: Ruksar Devadi Signed-off-by: Ashokkumar N Signed-off-by: Radha Ramachandran --- drivers/scsi/pm8001/pm8001_ctl.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 035969ed1c2e..d415bb12718c 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -919,6 +919,30 @@ static ssize_t ctl_mpi_state_show(struct device *cdev, } static DEVICE_ATTR_RO(ctl_mpi_state); +/** + * ctl_raae_count_show - controller raae count check + * @cdev: pointer to embedded class device + * @buf: the buffer returned + * + * A sysfs 'read-only' shost attribute. + */ + +static ssize_t ctl_raae_count_show(struct device *cdev, + struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(cdev); + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); + struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + unsigned int raaecnt = 0; + int c; + + pm8001_dbg(pm8001_ha, IOCTL, "%s\n", __func__); + raaecnt = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 12); + c = sprintf(buf, "MSGUTCNT=0x%08x\n", raaecnt); + return c; +} +static DEVICE_ATTR_RO(ctl_raae_count); + struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, @@ -943,6 +967,7 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_ila_version, &dev_attr_inc_fw_ver, &dev_attr_ctl_mpi_state, + &dev_attr_ctl_raae_count, NULL, }; From patchwork Wed Feb 24 15:57:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 387045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53539C433E0 for ; Wed, 24 Feb 2021 16:10:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 120B364EDD for ; Wed, 24 Feb 2021 16:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234883AbhBXQK1 (ORCPT ); Wed, 24 Feb 2021 11:10:27 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:18228 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236741AbhBXPwC (ORCPT ); Wed, 24 Feb 2021 10:52:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1614181921; x=1645717921; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=zmLltU0OGUcdGzctbY7f7KjiWUSOh5riGeOwZXgQdyE=; b=nw9jHmIdKWhg1qC56lUnwEsD3fezUmfHs1BTHb5tycFrfUVrx6OVC9xx 4Vyu2XgMladfUieaFdzUdnbvgoZTkxXoaLQoVQnLhpjmqMKmvE3y7UJm4 qqGIPoa2tY83pUve46reIh7QwmAEijSdGZfxaPFHEFp0K2bgW99tjeKM8 z9hLzVtV3KlZgHEKhH5M83mA2C6N43aefq+gFdNWhUeGj93ExDsFZ6lIm HZSu1YdTNi7Rgei4lb9+khGLNH77EM0w2DRXS8ni4XOOlaxnkRANqtg7T rIJlpwxx1WddzesnZUpqIqbqZd/U2zjaHZKWrRHhI5E3E9/AAcXN8opl1 A==; IronPort-SDR: ZljGurdUJOwSIc6Njns+L5sgcHG+raaoCofAoEl46UmpFf5jJgaUKSVCqYezrL016/ki7AUz9O LTPZbawgLgxRcZC0WdBAWnXlQlIqA5wI/wibuCWmlD9M+oUPlD70xmlw4p4Fj7g84HdwVqcwmd 5u3U9/gI3oYTICI6+Hy4Oys8FDkgVtl6Gn5IX6ptFXFL6ThuiKGK5A1uqg09E6/saghP+X9une MAJ5Cd/hRN2yZOFIZsGbkEqxbjdB3AdLXi+f1rIAfjbxdmXqeG+LvRZxWfUkcQ8QSxHtPl0W0P oSA= X-IronPort-AV: E=Sophos;i="5.81,203,1610434800"; d="scan'208";a="107803937" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Feb 2021 08:48:22 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 24 Feb 2021 08:48:21 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 24 Feb 2021 08:48:21 -0700 From: Viswas G To: CC: , , , , , Subject: [PATCH 3/7] pm80xx: Add sysfs attribute to track iop0 count Date: Wed, 24 Feb 2021 21:27:58 +0530 Message-ID: <20210224155802.13292-4-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210224155802.13292-1-Viswas.G@microchip.com> References: <20210224155802.13292-1-Viswas.G@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Vishakha Channapattan A new sysfs variable 'ctl_iop0_count' is being introduced that tells if the controller is alive by indicating controller ticks. If on subsequent run we see the ticks changing that indicates that controller is not dead. Tested: Using 'ctl_iop0_count' sysfs variable we can see ticks incrementing mvae14:~# cat /sys/class/scsi_host/host*/ctl_iop0_count IOP0TCNT=0x000000a3 IOP0TCNT=0x000001db IOP0TCNT=0x000001e4 IOP0TCNT=0x000001e7 Signed-off-by: Vishakha Channapattan Signed-off-by: Viswas G Signed-off-by: Ruksar Devadi Signed-off-by: Ashokkumar N Signed-off-by: Radha Ramachandran --- drivers/scsi/pm8001/pm8001_ctl.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index d415bb12718c..8470bce2cee1 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -943,6 +943,30 @@ static ssize_t ctl_raae_count_show(struct device *cdev, } static DEVICE_ATTR_RO(ctl_raae_count); +/** + * ctl_iop0_count_show - controller iop0 count check + * @cdev: pointer to embedded class device + * @buf: the buffer returned + * + * A sysfs 'read-only' shost attribute. + */ + +static ssize_t ctl_iop0_count_show(struct device *cdev, + struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(cdev); + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); + struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + unsigned int iop0cnt = 0; + int c; + + pm8001_dbg(pm8001_ha, IOCTL, "%s\n", __func__); + iop0cnt = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 16); + c = sprintf(buf, "IOP0TCNT=0x%08x\n", iop0cnt); + return c; +} +static DEVICE_ATTR_RO(ctl_iop0_count); + struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, @@ -968,6 +992,7 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_inc_fw_ver, &dev_attr_ctl_mpi_state, &dev_attr_ctl_raae_count, + &dev_attr_ctl_iop0_count, NULL, }; From patchwork Wed Feb 24 15:57:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 387518 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DC5DC433E0 for ; Wed, 24 Feb 2021 16:11:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42D2B64EFC for ; Wed, 24 Feb 2021 16:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234915AbhBXQKn (ORCPT ); Wed, 24 Feb 2021 11:10:43 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:18579 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236753AbhBXPw5 (ORCPT ); Wed, 24 Feb 2021 10:52:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1614181976; x=1645717976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=hal2KVvrq3ILGNN4m5FQMkXls/sKc5qdU9z0q3U3DlQ=; b=d5obM2HWqwRjcbAf8eR/VEFPiVp1R55P3sByiJgxlcaNt/ZD/fR79EyL cuuaUqIC4aQibVICNYkPl7MCr+YQk9svIjhQp9xpxK9rmju6n920W1P3z hpP+E9RjhSt6NqUpJ6NfjvkVXTdgk+cuti9UKuIf1dwhUsTgmpo3sevH5 hpWCamsghXTf7bNrIQ8xxrEaucDzRmXct5K94AgI25XRn9abDatEXLZEg VDooWHOMsOkw9AW/VaVobbHYgNEb/xSgCXiFZkRAWQWsMtA9UvZ19Y5iP rpJhIb7h5gYjtb611nJEhZ8XHZv2rikzfIgeAxQryDNyFWmqXtZtWc6Ag Q==; IronPort-SDR: RoHdQQ2N6GKABL+QevLynnx50hr9EIxLG8ij4fxG90LJPQNYq642rDHIUoQK4MOlTgLF0XWNkT Em7JKITLyqRh3IqXa/M2AFKxYx1jkxjqMwEQbcuZVStGZlF849l8XWQnopW7Wyhny+xgcRt+MC +mEULxC1NpbsZuttQWzpbg8OC+J3dyY14QYVMHzzlQM7f+1lDya26E2bo2bggiOuzRjCMIjE36 tJcqqUeF4bLnk4xBJzxG2ELudFmMlbGj3c2vIxWpMee789bhuz1W8m5sMpK19jQtXVT1JHkoOR 1Qo= X-IronPort-AV: E=Sophos;i="5.81,203,1610434800"; d="scan'208";a="107803940" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Feb 2021 08:48:24 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 24 Feb 2021 08:48:23 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 24 Feb 2021 08:48:23 -0700 From: Viswas G To: CC: , , , , , Subject: [PATCH 4/7] pm80xx: Add sysfs attribute to track iop1 count Date: Wed, 24 Feb 2021 21:27:59 +0530 Message-ID: <20210224155802.13292-5-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210224155802.13292-1-Viswas.G@microchip.com> References: <20210224155802.13292-1-Viswas.G@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Vishakha Channapattan A new sysfs variable 'ctl_iop1_count' is being introduced that tells if the controller is alive by indicating controller ticks. If on subsequent run we see the ticks changing that indicates that controller is not dead. Tested: Using 'ctl_iop1_count' sysfs variable we can see ticks incrementing mvae14:~# cat /sys/class/scsi_host/host*/ctl_iop1_count IOP1TCNT=0x00000069 IOP1TCNT=0x0000006b IOP1TCNT=0x0000006d IOP1TCNT=0x00000072 Signed-off-by: Vishakha Channapattan Signed-off-by: Viswas G Signed-off-by: Ruksar Devadi Signed-off-by: Ashokkumar N Signed-off-by: Radha Ramachandran --- drivers/scsi/pm8001/pm8001_ctl.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 8470bce2cee1..9bc9ef446801 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -967,6 +967,30 @@ static ssize_t ctl_iop0_count_show(struct device *cdev, } static DEVICE_ATTR_RO(ctl_iop0_count); +/** + * ctl_iop1_count_show - controller iop1 count check + * @cdev: pointer to embedded class device + * @buf: the buffer returned + * + * A sysfs 'read-only' shost attribute. + */ + +static ssize_t ctl_iop1_count_show(struct device *cdev, + struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(cdev); + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); + struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + unsigned int iop1cnt = 0; + int c; + + pm8001_dbg(pm8001_ha, IOCTL, "%s\n", __func__); + iop1cnt = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 20); + c = sprintf(buf, "IOP1TCNT=0x%08x\n", iop1cnt); + return c; +} +static DEVICE_ATTR_RO(ctl_iop1_count); + struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, @@ -993,6 +1017,7 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_ctl_mpi_state, &dev_attr_ctl_raae_count, &dev_attr_ctl_iop0_count, + &dev_attr_ctl_iop1_count, NULL, }; From patchwork Wed Feb 24 15:58:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 387046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30239C433E9 for ; Wed, 24 Feb 2021 16:10:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC4FB64F02 for ; Wed, 24 Feb 2021 16:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234550AbhBXQKD (ORCPT ); Wed, 24 Feb 2021 11:10:03 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:58886 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232166AbhBXPt5 (ORCPT ); Wed, 24 Feb 2021 10:49:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1614181791; x=1645717791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=oEHHfiIHFwnetZn+i5MHGDoQJ+qGWiY8A8KprMx8KUg=; b=NGyWMVeDqf7t1+sw7TxPGIEPaxcs6xZ8IYgpmepENVKSzscNRt6gTNZi rGsszSWjVMcQkCi90lLSq4pwGIFjW2ULwGW/y3QD85MrxzBkNRYz+Ujga RjO7EhqjahvEulyPETNz0n9bEtgm19LPF+Yc61PguB1BxDClcCH4zVOEL snChT9CXpb5t7K7TFjMCRpktpZiDPPAj2Fo9FkhdWDDqEZzsK15CHRUNk 4eVpnRykCMPnAKvoIzoLVIBGoY0YEK6XYadd8f4Fp6oCT1HoddRam5ITw Gi2a3wvVuPmkPp32C6sUqdlEE8xjVi0I1MLtcNbtWJEmFOqonI5F6EK60 w==; IronPort-SDR: oKEgKvAYnqnNgS1sWXqXkFsCQ8WN1hlHBcVMlLl8rD3JJXulmej+M39PuChdo+tsvZ+mhlIQhp H6lETE5PFB/HhO3bDGsayyQHwUjTuvnHu88WX2Zp2/HKLXGceGe2Pqieb8KpbtDJzyrldTMyjs lk7rqaP1xgJUG++KR4nz1F2jYJbKWZGLiaAnA3CE0PfZ8hRvAQwDsH9DI8klJF8zt2DIPCdgs/ sH+qCa+7QbWM+iJIdfa/miC8OtAvQhVkkc1egiATrOS/V/bLrqcXOrOnx3cUhNGblmanFbHFzf XBk= X-IronPort-AV: E=Sophos;i="5.81,203,1610434800"; d="scan'208";a="45306028" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Feb 2021 08:48:26 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 24 Feb 2021 08:48:25 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 24 Feb 2021 08:48:25 -0700 From: Viswas G To: CC: , , , , , Subject: [PATCH 5/7] pm80xx: Completing pending IO after fatal error Date: Wed, 24 Feb 2021 21:28:00 +0530 Message-ID: <20210224155802.13292-6-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210224155802.13292-1-Viswas.G@microchip.com> References: <20210224155802.13292-1-Viswas.G@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Ruksar Devadi When controller runs into fatal error, IOs get stuck with no response, handler event is defined to complete the pending IOs (SAS task and internal task) and also perform the cleanup for the drives. Signed-off-by: Ruksar Devadi Signed-off-by: Viswas G Signed-off-by: Ashokkumar N Acked-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 66 ++++++++++++++++++++++++++++++++++++---- drivers/scsi/pm8001/pm8001_hwi.h | 1 + drivers/scsi/pm8001/pm8001_sas.c | 2 +- drivers/scsi/pm8001/pm8001_sas.h | 1 + drivers/scsi/pm8001/pm80xx_hwi.c | 1 + drivers/scsi/pm8001/pm80xx_hwi.h | 1 + 6 files changed, 65 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 49bf2f70a470..4e0ce044ac69 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1499,12 +1499,14 @@ void pm8001_work_fn(struct work_struct *work) * was cancelled. This nullification happens when the device * goes away. */ - pm8001_dev = pw->data; /* Most stash device structure */ - if ((pm8001_dev == NULL) - || ((pw->handler != IO_XFER_ERROR_BREAK) - && (pm8001_dev->dev_type == SAS_PHY_UNUSED))) { - kfree(pw); - return; + if (pw->handler != IO_FATAL_ERROR) { + pm8001_dev = pw->data; /* Most stash device structure */ + if ((pm8001_dev == NULL) + || ((pw->handler != IO_XFER_ERROR_BREAK) + && (pm8001_dev->dev_type == SAS_PHY_UNUSED))) { + kfree(pw); + return; + } } switch (pw->handler) { @@ -1668,6 +1670,58 @@ void pm8001_work_fn(struct work_struct *work) dev = pm8001_dev->sas_device; pm8001_I_T_nexus_reset(dev); break; + case IO_FATAL_ERROR: + { + struct pm8001_hba_info *pm8001_ha = pw->pm8001_ha; + struct pm8001_ccb_info *ccb; + struct task_status_struct *ts; + struct sas_task *task; + int i; + u32 tag, device_id; + + for (i = 0; ccb = NULL, i < PM8001_MAX_CCB; i++) { + ccb = &pm8001_ha->ccb_info[i]; + task = ccb->task; + ts = &task->task_status; + tag = ccb->ccb_tag; + /* check if tag is NULL */ + if (!tag) { + pm8001_dbg(pm8001_ha, FAIL, + "tag Null\n"); + continue; + } + if (task != NULL) { + dev = task->dev; + if (!dev) { + pm8001_dbg(pm8001_ha, FAIL, + "dev is NULL\n"); + continue; + } + /*complete sas task and update to top layer */ + pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + ts->resp = SAS_TASK_COMPLETE; + task->task_done(task); + } else if (tag != 0xFFFFFFFF) { + /* complete the internal commands/non-sas task */ + pm8001_dev = ccb->device; + if (pm8001_dev->dcompletion) { + complete(pm8001_dev->dcompletion); + pm8001_dev->dcompletion = NULL; + } + complete(pm8001_ha->nvmd_completion); + pm8001_tag_free(pm8001_ha, tag); + } + } + /* Deregsiter all the device ids */ + for (i = 0; i < PM8001_MAX_DEVICES; i++) { + pm8001_dev = &pm8001_ha->devices[i]; + device_id = pm8001_dev->device_id; + if (device_id) { + PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id); + pm8001_free_dev(pm8001_dev); + } + } + } break; } kfree(pw); } diff --git a/drivers/scsi/pm8001/pm8001_hwi.h b/drivers/scsi/pm8001/pm8001_hwi.h index 6d91e2446542..d1f3aa93325b 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.h +++ b/drivers/scsi/pm8001/pm8001_hwi.h @@ -805,6 +805,7 @@ struct set_dev_state_resp { #define IO_ABORT_IN_PROGRESS 0x40 #define IO_ABORT_DELAYED 0x41 #define IO_INVALID_LENGTH 0x42 +#define IO_FATAL_ERROR 0x51 /* WARNING: This error code must always be the last number. * If you add error code, modify this code also diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index a98d4496ff8b..edec599ac641 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -590,7 +590,7 @@ struct pm8001_device *pm8001_find_dev(struct pm8001_hba_info *pm8001_ha, return NULL; } -static void pm8001_free_dev(struct pm8001_device *pm8001_dev) +void pm8001_free_dev(struct pm8001_device *pm8001_dev) { u32 id = pm8001_dev->id; memset(pm8001_dev, 0, sizeof(*pm8001_dev)); diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 039ed91e9841..36cd37c8c29a 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -727,6 +727,7 @@ ssize_t pm80xx_get_non_fatal_dump(struct device *cdev, struct device_attribute *attr, char *buf); ssize_t pm8001_get_gsm_dump(struct device *cdev, u32, char *buf); int pm80xx_fatal_errors(struct pm8001_hba_info *pm8001_ha); +void pm8001_free_dev(struct pm8001_device *pm8001_dev); /* ctl shared API */ extern struct device_attribute *pm8001_host_attrs[]; diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 84315560e8e1..1aa3a499c85a 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4126,6 +4126,7 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec) pm8001_dbg(pm8001_ha, FAIL, "Firmware Fatal error! Regval:0x%x\n", regval); + pm8001_handle_event(pm8001_ha, NULL, IO_FATAL_ERROR); print_scratchpad_registers(pm8001_ha); return ret; } diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h index 2c8e85cfdbc4..c7e5d93bea92 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.h +++ b/drivers/scsi/pm8001/pm80xx_hwi.h @@ -1272,6 +1272,7 @@ typedef struct SASProtocolTimerConfig SASProtocolTimerConfig_t; #define IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE 0x47 #define IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED 0x48 #define IO_DS_INVALID 0x49 +#define IO_FATAL_ERROR 0x51 /* WARNING: the value is not contiguous from here */ #define IO_XFER_ERR_LAST_PIO_DATAIN_CRC_ERR 0x52 #define IO_XFER_DMA_ACTIVATE_TIMEOUT 0x53 From patchwork Wed Feb 24 15:58:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 387519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 082A5C433DB for ; Wed, 24 Feb 2021 16:10:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B004164EDD for ; Wed, 24 Feb 2021 16:10:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233912AbhBXQKQ (ORCPT ); Wed, 24 Feb 2021 11:10:16 -0500 Received: from esa.microchip.iphmx.com ([68.232.153.233]:45563 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233488AbhBXPuD (ORCPT ); Wed, 24 Feb 2021 10:50:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1614181797; x=1645717797; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=w+I8785vdoQ0HwGDTReBpi2ApzBHVLlsCl7k/uGKiKE=; b=PUBZiWwEKCP+XYXtMIaCkEpnZTgdEKqqumM4EG6c4apY/qyKLGhMQcZ1 GS1yUUbIdJY5RSHsuKZXpNQK0fftmB3y1CeBrSzO0z/SAQX7klIupSyIL L30jR3VYSYrBTxjsx646kenwKUcEXum2DUce8piPXnbYhzFJg1qWicv0f u7/UQLAwY/VCoQhxhDFCHgANUnCwahCHq9ephxIsg92bYX6ZFOP6U76g9 EQC1anAf8diPjOUhusYDmNlHmdQisEy0I6ybCN/YymuZ/8ugY4SwnhSUv 0Db+5WHRS776jtWkGB/4QaY2eWiuz+y7NwxlXUuqOZFidj0MqoXcKJGKk A==; IronPort-SDR: uPFPlMm169ePeR8r0q8EREzg5o7yjxsrzApVJ3OO/OyDouRZ3Vcjsa4mNVB+QfcX3ZOagv774Z rZRyWbpLgI2pu5h+LuFhy5hM46Bgx6uP7GSLvYC5NYr5mgoa0RGhwzQoh1rrPIbSN3sIPnb22D 2jsaNfNTNRXqAHCfmDb2/xduSpXT3byc1lQhWzAt9ckMGiVv7XmjhUhIG8inMSMw7P5TKimhVt H4mY9iiETcGjgDlHnrNZFkcI/ABwJ7lUpcWd+hSrVydJfb/1CMFtG+U5wngerAzmzL96DGuI0k DM4= X-IronPort-AV: E=Sophos;i="5.81,203,1610434800"; d="scan'208";a="110474144" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Feb 2021 08:48:30 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 24 Feb 2021 08:48:27 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 24 Feb 2021 08:48:27 -0700 From: Viswas G To: CC: , , , , , Subject: [PATCH 6/7] pm80xx: Reset PI and CI memory during re-initialize Date: Wed, 24 Feb 2021 21:28:01 +0530 Message-ID: <20210224155802.13292-7-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210224155802.13292-1-Viswas.G@microchip.com> References: <20210224155802.13292-1-Viswas.G@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Producer index(PI) outbound queue and consumer index(CI) for Outbound queue are in DMA memory. These values should be reset to 0 during driver reinitialization. Signed-off-by: Viswas G Signed-off-by: Ruksar Devadi Signed-off-by: Ashokkumar N Acked-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 2 ++ drivers/scsi/pm8001/pm80xx_hwi.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 4e0ce044ac69..783149b8b127 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -240,6 +240,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo; pm8001_ha->inbnd_q_tbl[i].ci_virt = pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr; + pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0, 0); offsetib = i * 0x20; pm8001_ha->inbnd_q_tbl[i].pi_pci_bar = get_pci_bar_index(pm8001_mr32(addressib, @@ -268,6 +269,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) 0 | (10 << 16) | (i << 24); pm8001_ha->outbnd_q_tbl[i].pi_virt = pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr; + pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0, 0); offsetob = i * 0x24; pm8001_ha->outbnd_q_tbl[i].ci_pci_bar = get_pci_bar_index(pm8001_mr32(addressob, diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 1aa3a499c85a..0f2c57e054ac 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -787,6 +787,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo; pm8001_ha->inbnd_q_tbl[i].ci_virt = pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr; + pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0, 0); offsetib = i * 0x20; pm8001_ha->inbnd_q_tbl[i].pi_pci_bar = get_pci_bar_index(pm8001_mr32(addressib, @@ -820,6 +821,7 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay = (i << 24); pm8001_ha->outbnd_q_tbl[i].pi_virt = pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr; + pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0, 0); offsetob = i * 0x24; pm8001_ha->outbnd_q_tbl[i].ci_pci_bar = get_pci_bar_index(pm8001_mr32(addressob, From patchwork Wed Feb 24 15:58:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 387047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95952C433E0 for ; Wed, 24 Feb 2021 16:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38E6764EF5 for ; Wed, 24 Feb 2021 16:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234030AbhBXQJa (ORCPT ); Wed, 24 Feb 2021 11:09:30 -0500 Received: from esa.microchip.iphmx.com ([68.232.153.233]:20345 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232806AbhBXPt5 (ORCPT ); Wed, 24 Feb 2021 10:49:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1614181791; x=1645717791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=l29CYZFnO8Xp+rAt0cwfaaHuF7JsDAwyBx7Zkfmr/E4=; b=j2HE+F+WQfev2luRYzgB0ovp6MyTfZUh+bWPw2cJ1S3xP3qwTjQ3XfOu 5C1SPnxBX+c3qTEzE80jFkGzHaLzMCPIjbmdgfNSdGM3wkF7yH8U0QDdS rpShoTvtDc7cVq3/riNq8Mxlty9JvcvD/YReMOChABdMc5ukJOaviybzF CWaNbphGAIZN/Rr69DRxUpgmjFSl6/x3wp/oMpWXV8lsSWGG5hY45W0Y3 jL1nYHYiteW4aUd3bxe6edAK2gNzG50nlH4PyUpqT8Gk/Cxwczoi0AuCw M4rEUt8DmjjtzHgndgcb4sDRiXS/WSyzAzINS1QEtt/N+nJ+rfgMTJQkL w==; IronPort-SDR: MpGcq7uz6wVLhBh7j/pA1m3yYMD9/lRfeKDmMOBeMBDLmWulWQQ1h3X293eHZd8zskCG73eR3A iSDez0Dy9l1vghBSjIpCZZGDC++t/hyVyWAkovTkPsUa+uADHqbg+nO+kEQeImhiw+aNiKo4Kt jxkI17AVBinmCPjTwUB0kZ4Fl8wGFgEqOYmN+Tz/TIz6MAzl+wxN1DfQWvw9Np767Zp+gsOzQc RGvQ2UZAASC0uFeDh82LzXGb7qO6UhHQ0JoXC7Zmd+RHBwzxFn3HIRFxA9sDhtHsAlC/40AzzK Jig= X-IronPort-AV: E=Sophos;i="5.81,203,1610434800"; d="scan'208";a="110952342" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 Feb 2021 08:48:29 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 24 Feb 2021 08:48:29 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 24 Feb 2021 08:48:29 -0700 From: Viswas G To: CC: , , , , , Subject: [PATCH 7/7] pm80xx: remove global lock from outbound queue processing Date: Wed, 24 Feb 2021 21:28:02 +0530 Message-ID: <20210224155802.13292-8-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210224155802.13292-1-Viswas.G@microchip.com> References: <20210224155802.13292-1-Viswas.G@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Introduced spin lock for outbound queue. With this, driver need not acquire hba global lock for outbound queue processing. Signed-off-by: Viswas G Signed-off-by: Ruksar Devadi Signed-off-by: Ashokkumar N Acked-by: Jack Wang --- drivers/scsi/pm8001/pm8001_init.c | 9 ++++++--- drivers/scsi/pm8001/pm8001_sas.h | 1 + drivers/scsi/pm8001/pm80xx_hwi.c | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index bd626ef876da..a3c8fb9a885f 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -267,7 +267,8 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, { int i, count = 0, rc = 0; u32 ci_offset, ib_offset, ob_offset, pi_offset; - struct inbound_queue_table *circularQ; + struct inbound_queue_table *ibq; + struct outbound_queue_table *obq; spin_lock_init(&pm8001_ha->lock); spin_lock_init(&pm8001_ha->bitmap_lock); @@ -315,8 +316,8 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, pm8001_ha->memoryMap.region[IOP].alignment = 32; for (i = 0; i < count; i++) { - circularQ = &pm8001_ha->inbnd_q_tbl[i]; - spin_lock_init(&circularQ->iq_lock); + ibq = &pm8001_ha->inbnd_q_tbl[i]; + spin_lock_init(&ibq->iq_lock); /* MPI Memory region 3 for consumer Index of inbound queues */ pm8001_ha->memoryMap.region[ci_offset+i].num_elements = 1; pm8001_ha->memoryMap.region[ci_offset+i].element_size = 4; @@ -345,6 +346,8 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, } for (i = 0; i < count; i++) { + obq = &pm8001_ha->outbnd_q_tbl[i]; + spin_lock_init(&obq->oq_lock); /* MPI Memory region 4 for producer Index of outbound queues */ pm8001_ha->memoryMap.region[pi_offset+i].num_elements = 1; pm8001_ha->memoryMap.region[pi_offset+i].element_size = 4; diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 36cd37c8c29a..f835557ee354 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -457,6 +457,7 @@ struct outbound_queue_table { u32 dinterrup_to_pci_offset; __le32 producer_index; u32 consumer_idx; + spinlock_t oq_lock; }; struct pm8001_hba_memspace { void __iomem *memvirtaddr; diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 0f2c57e054ac..f1276baebe1d 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4133,8 +4133,8 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec) return ret; } } - spin_lock_irqsave(&pm8001_ha->lock, flags); circularQ = &pm8001_ha->outbnd_q_tbl[vec]; + spin_lock_irqsave(&circularQ->oq_lock, flags); do { /* spurious interrupt during setup if kexec-ing and * driver doing a doorbell access w/ the pre-kexec oq @@ -4160,7 +4160,7 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec) break; } } while (1); - spin_unlock_irqrestore(&pm8001_ha->lock, flags); + spin_unlock_irqrestore(&circularQ->oq_lock, flags); return ret; }