From patchwork Thu Apr 15 10:33:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 422126 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.6 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 1ABCAC43460 for ; Thu, 15 Apr 2021 10:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE3F5613B1 for ; Thu, 15 Apr 2021 10:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232332AbhDOKYp (ORCPT ); Thu, 15 Apr 2021 06:24:45 -0400 Received: from esa.microchip.iphmx.com ([68.232.153.233]:23250 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232303AbhDOKYn (ORCPT ); Thu, 15 Apr 2021 06:24:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618482261; x=1650018261; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=1GJZzpKh7w6xcmwIOg6j3mF4rwt9tZpvPhZq7jvgvwo=; b=MCsuPpbDrWHDdnI5Xjt7ZvCdQ5vHnF3mFRQKUPKq9qpvE6oNOKMJKmsB 0ePcPbNIBhpV6kLZRXLJe8YLDghWOYUxh5KV+Z0+NTjsHHLTvCUdKitKw O3g4luIl8y5CLGWIVh8KmQviejLSr10J7w/Xg39S3rN2wgDusV7YVvYxq /9NXYeLyBfGHcjp4h1A//wGv4JM/LUepXwopo0KeHk5N7uiL+tFUDAqNn LZ5CCvPnAHpWrXz2j1UbXCHllXdWD6zFPXBJ9JHnf3YdbEG1wNOrj5n70 g9znjXe/eueTw9gCV1g8dGYQfI80bhwZizqAYvtR2GudE/+mPNwIo+Tdg Q==; IronPort-SDR: QHePRvJqqFzXpANxNFWnDpxPu9oHoMzE7tiI6oWrBIsqJ8RZTg1mj2llENMbrC9XwB5XmzVdB4 UYMgVq0folJG1tY933S3MTWrgiethf+ddbh1p7weeRz8C0biFtnZfw3OCE8EHNsb4oAb7HzXWK TqWvJKWYB0ZBQ7gkgaS5Arnm8KXBXndFUi0j62CepuP9pOX2zZcWwruMl5GA1+YzIAu0od50t/ 23G5KQMChmiAfcd+KIywGJ33/wM3TaK/Sku1mKLizMOBe6NvkazvHfzoJU0+KbKb6tLQ7K0ywA 0FM= X-IronPort-AV: E=Sophos;i="5.82,223,1613458800"; d="scan'208";a="116548099" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Apr 2021 03:24:21 -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.2176.2; Thu, 15 Apr 2021 03:24: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.2176.2 via Frontend Transport; Thu, 15 Apr 2021 03:24:20 -0700 From: Viswas G To: CC: , , , , , , Ashokkumar N , "John Garry" , Dan Carpenter , "Martin K . Petersen" , Bart Van Assche Subject: [PATCH v4 1/8] pm80xx: Add sysfs attribute to check mpi state Date: Thu, 15 Apr 2021 16:03:45 +0530 Message-ID: <20210415103352.3580-2-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210415103352.3580-1-Viswas.G@microchip.com> References: <20210415103352.3580-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 linux-2dq0:~# cat /sys/class/scsi_host/host*/ctl_mpi_state MPI is successfully initialized Reported-by: kernel test robot Reported-by: Dan Carpenter 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 Signed-off-by: kernel test robot --- drivers/scsi/pm8001/pm8001_ctl.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 12035baf0997..a93799bd3a32 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,37 @@ 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. + */ + +static const char *const mpiStateText[] = { + "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; + + mpidw0 = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 0); + return sysfs_emit(buf, "%s\n", mpiStateText[mpidw0 & 0x0003]); +} +static DEVICE_ATTR_RO(ctl_mpi_state); + struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, @@ -909,6 +938,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 Thu Apr 15 10:33:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 423063 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.6 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 11D50C43460 for ; Thu, 15 Apr 2021 10:24:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3519613B1 for ; Thu, 15 Apr 2021 10:24:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232362AbhDOKYr (ORCPT ); Thu, 15 Apr 2021 06:24:47 -0400 Received: from esa.microchip.iphmx.com ([68.232.153.233]:35455 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232315AbhDOKYq (ORCPT ); Thu, 15 Apr 2021 06:24:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618482263; x=1650018263; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=cOEw6hwvqZLDddzkN4vF8KBDSW5RRYekt8cbWZTJfeE=; b=BYD3oEDpLc2hzI/K4CbsMwZ+iy6vFYWNZ4XeK+vsdqY9m7tAAREXGD6l Wk9qsNPNgrX6OubBKBFBPBYiVki38+GkE2Pj482FeZCGTPXk/QWtO+The TmX9/ywZYCl+NZd8WjnH/NtaW9qR//7HYzmVL0K5KwwdXzD3DpKsTzI6L ABfcCIALWfto07PWumfdm6P03NkPAp6xdZO61JUI/jtj6A77lpbLhDdQj mq4eT/F3tM92RGZYOSgIjHNoRebd3G5sfZ/J3MBQjCMQpHu96+6h9Z6Kb 26lZDIRknlenhpi/nILGNuAfzKi+jVccMHrsT3bgri352d2/VICDBTEFh A==; IronPort-SDR: DxRviuQq17iDZ67lac8721TkD9lwAdPqQLO4wqQJ6J6JO7MtFQC0mT672BK5mze26y4pFzPx2w omQQZ60pX3M5D6e4yaPQ//P6PIQ8VQw3ewC30bvhdWEai02ntpulQDoicbTgUwozzB/kLfHjwQ 7kKVO58+0PzO9HHJbBFPB+qTvDdP9TOZk9f/09qdv3o7ZInycyU95LjDijoS4kabsSLeJ5/Bdl Fsif1ZCRFNJrA2VKkAniDOt7x4/qOvcsW7iH5fE6/unWM9pD2jhbQy4NUmq0WC8tXHwW47Rvrp iJE= X-IronPort-AV: E=Sophos;i="5.82,223,1613458800"; d="scan'208";a="123165425" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Apr 2021 03:24:22 -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.2176.2; Thu, 15 Apr 2021 03:24:22 -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.2176.2 via Frontend Transport; Thu, 15 Apr 2021 03:24:22 -0700 From: Viswas G To: CC: , , , , , , Ashokkumar N , "John Garry" , Dan Carpenter , "Martin K . Petersen" , Bart Van Assche Subject: [PATCH v4 2/8] pm80xx: Add sysfs attribute to check controller hmi error Date: Thu, 15 Apr 2021 16:03:46 +0530 Message-ID: <20210415103352.3580-3-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210415103352.3580-1-Viswas.G@microchip.com> References: <20210415103352.3580-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_hmi_error' is being introduced to give the error details if the MPI initialization fails Tested: Using 'ctl_hmi_error' sysfs variable we check the error details linux-2dq0:~# cat /sys/class/scsi_host/host*/ctl_hmi_error 0x00000000 0x00000000 0x00000000 Signed-off-by: Vishakha Channapattan Signed-off-by: Viswas G Signed-off-by: Ruksar Devadi --- drivers/scsi/pm8001/pm8001_ctl.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index a93799bd3a32..b1f105253a12 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -915,6 +915,27 @@ static ssize_t ctl_mpi_state_show(struct device *cdev, } static DEVICE_ATTR_RO(ctl_mpi_state); +/** + * ctl_hmi_error_show - controller MPI initialization fails + * @cdev: pointer to embedded class device + * @buf: the buffer returned + * + * A sysfs 'read-only' shost attribute. + */ + +static ssize_t ctl_hmi_error_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; + + mpidw0 = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 0); + return sysfs_emit(buf, "0x%08x\n", (mpidw0 >> 16)); +} +static DEVICE_ATTR_RO(ctl_hmi_error); + struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, @@ -939,6 +960,7 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_ila_version, &dev_attr_inc_fw_ver, &dev_attr_ctl_mpi_state, + &dev_attr_ctl_hmi_error, NULL, }; From patchwork Thu Apr 15 10:33:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 422125 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.6 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 DB648C433B4 for ; Thu, 15 Apr 2021 10:24:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC4F96124B for ; Thu, 15 Apr 2021 10:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232401AbhDOKYv (ORCPT ); Thu, 15 Apr 2021 06:24:51 -0400 Received: from esa.microchip.iphmx.com ([68.232.153.233]:35455 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232364AbhDOKYr (ORCPT ); Thu, 15 Apr 2021 06:24:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618482265; x=1650018265; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=h+n/osgDKFfKkZZXvUhRc2Cq6CfG6qdiDdNHe43XdcM=; b=oJRKYuaTI4DiItDD7K9VTDB1fNcmHbFyxhrEnpxlUffI8sRJsntbTcX8 zIKHyV+v2ayHjo0M8Y7CZxZhIh9gU5DL0JW4o7I1cLGvHyQPDOYkBBg24 6bT7Jt2toIOKviGFGbpRUFB8bl+AyOlI5sks6pP6e5WPkJfmPSD8UPBVy k560NM0Hdcwyek2JxSEtKsX41Wk8774Ip8+dM0bwuvSQ7Ik3HLauLZ58E 0xVYkLefNgBkwyaPJSJE0m+dQVoD3OdxLZwgPOKKUw+MqJ7DuPRu81ScP G0xkHIHKFuqChWUGzDHyhvpgrpFWRe2yCFu2LasvJ7KtmVJ60+H7Lq98C g==; IronPort-SDR: Hoi+gqE9gql5IBg9q46nHqqea+gibwVHyTTVCJ1BLgJaHK47A2J4Z6KJC1zC9Fs1OBeHBZiFJB 6mMKKlKWhOuH5LzjxBFTwajjyietYCo84/LeLq84VX2HR5BtLoahLR1jlQVBu0gT9qJppDXPXy evfh24STh5PC3ABtkoH2Lp4J/l0Mn+JZG9TcN+gDvnJxz4qrQ4KWzjefLoo9rs2lPkCmsnywAI R1R7aa+Tln7yS0EBUuldPGuQ3PuY8sZdFnVNcNl/YmBVYndpz+scM4PjETcnuVqFimmhhutft1 pJg= X-IronPort-AV: E=Sophos;i="5.82,223,1613458800"; d="scan'208";a="123165437" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Apr 2021 03:24:24 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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.2; Thu, 15 Apr 2021 03:24:24 -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.2176.2 via Frontend Transport; Thu, 15 Apr 2021 03:24:24 -0700 From: Viswas G To: CC: , , , , , , Ashokkumar N , "John Garry" , Dan Carpenter , "Martin K . Petersen" , Bart Van Assche Subject: [PATCH v4 3/8] pm80xx: Add sysfs attribute to track RAAE count Date: Thu, 15 Apr 2021 16:03:47 +0530 Message-ID: <20210415103352.3580-4-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210415103352.3580-1-Viswas.G@microchip.com> References: <20210415103352.3580-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 linux-9saw:~# cat /sys/class/scsi_host/host*/ctl_raae_count 0x00002245 0x00002253 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 Acked-by: Jack Wang --- drivers/scsi/pm8001/pm8001_ctl.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index b1f105253a12..a39cfd9d2a6b 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -936,6 +936,27 @@ static ssize_t ctl_hmi_error_show(struct device *cdev, } static DEVICE_ATTR_RO(ctl_hmi_error); +/** + * 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; + + raaecnt = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 12); + return sysfs_emit(buf, "0x%08x\n", raaecnt); +} +static DEVICE_ATTR_RO(ctl_raae_count); + struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, @@ -961,6 +982,7 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_inc_fw_ver, &dev_attr_ctl_mpi_state, &dev_attr_ctl_hmi_error, + &dev_attr_ctl_raae_count, NULL, }; From patchwork Thu Apr 15 10:33:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 423062 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.6 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 8B46CC433B4 for ; Thu, 15 Apr 2021 10:24:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C92A613B1 for ; Thu, 15 Apr 2021 10:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232315AbhDOKYy (ORCPT ); Thu, 15 Apr 2021 06:24:54 -0400 Received: from esa.microchip.iphmx.com ([68.232.154.123]:51425 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232367AbhDOKYu (ORCPT ); Thu, 15 Apr 2021 06:24:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618482268; x=1650018268; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=RHXlDWKuEQs6XxFxVWA2tELmta4o4j7fuyfenAu4v0k=; b=US9NQKdX1hm8vBhdptUSk87F8C38EHlLlvSHtu+cmKI+WxgGrW3baJz1 7rWEjgY7vUvoQ3OHmVx5Alwz9eTLrspEdH23Am8fyH25SGuE1nCEshWgx TQiP62P1RdsyqYtVgrjjvpPu+JduF+WW3shfrTXTjWWLGpvTGUHT/BNLQ jhsykp4xr7Xspy7PVtQvN6wa01zNvMHGytJmXeae+3DKKX5tT9wIYVbw9 DRGIsqik9+A5c4ifXThh5PeF2oHP0jjKYfbC+FltekNjYQpVPUmT3lZIZ rldi7eQlMSi5CJRctTeNzqA1MjmoUM9uExlX9BM6I7q4BF5XmDRGDKrpG A==; IronPort-SDR: BifSOS3SrGixlIOhPJFv72/6SIbCU2sKIaoKP9GB+40tw+76eeL4JLPYDrzz3SaNsPnEAHxpox cEPD1ZhzVN/YOy19tM+GFTOnI93xWNa9mJR4d5J+mvqDCKnXKK5EVdE6hSldz80NuBtdLwr3aT v6CsnioVqcM2Mu4zH/40Z5PeMUL5Q/jEcydeKWYfXb/VBiXMJ+1Np6f7CoXTWoR7caubBjtZLX hH4/GtQgewjGWIL5Qzff6f2KTJU0eKjmSJkFSWy7CdwO3kaZiY+q/q4/sASpRDDqVus6UGCCnK nE4= X-IronPort-AV: E=Sophos;i="5.82,223,1613458800"; d="scan'208";a="113684248" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Apr 2021 03:24:26 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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.2176.2; Thu, 15 Apr 2021 03:24:26 -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.2176.2 via Frontend Transport; Thu, 15 Apr 2021 03:24:26 -0700 From: Viswas G To: CC: , , , , , , Ashokkumar N , "John Garry" , Dan Carpenter , "Martin K . Petersen" , Bart Van Assche Subject: [PATCH v4 4/8] pm80xx: Add sysfs attribute to track iop0 count Date: Thu, 15 Apr 2021 16:03:48 +0530 Message-ID: <20210415103352.3580-5-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210415103352.3580-1-Viswas.G@microchip.com> References: <20210415103352.3580-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 linux-9saw:~# cat /sys/class/scsi_host/host*/ctl_iop0_count 0x000000a3 0x000001db 0x000001e4 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 Acked-by: Jack Wang --- drivers/scsi/pm8001/pm8001_ctl.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index a39cfd9d2a6b..b1c351dd2704 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -957,6 +957,27 @@ 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; + + iop0cnt = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 16); + return sysfs_emit(buf, "0x%08x\n", iop0cnt); +} +static DEVICE_ATTR_RO(ctl_iop0_count); + struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, @@ -983,6 +1004,7 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_ctl_mpi_state, &dev_attr_ctl_hmi_error, &dev_attr_ctl_raae_count, + &dev_attr_ctl_iop0_count, NULL, }; From patchwork Thu Apr 15 10:33:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 422124 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.6 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 3A190C43460 for ; Thu, 15 Apr 2021 10:24:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D2EB610CB for ; Thu, 15 Apr 2021 10:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232369AbhDOKYz (ORCPT ); Thu, 15 Apr 2021 06:24:55 -0400 Received: from esa.microchip.iphmx.com ([68.232.154.123]:63695 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232342AbhDOKYv (ORCPT ); Thu, 15 Apr 2021 06:24:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618482269; x=1650018269; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=AE5pehUJtze6tQ1cA3CjEf0CH4Iy/zeniEKuncO17Uo=; b=MK//BoBtKiSxmzImmJ5XtbDvNSBLkj+cUG7xlQF2Dvwx+ZlhVZSvhOnv eevVfTGWp8Ku0aPJvnkZVhanrAIDMt4zWvbypaGNO80zU4C0JPPvKzcmc Xq0k2UlrBEUWcg6J1zS+u4lFsh9nEql5VW6vgVxrJpAEEmnWKMpumR5MD yEs6bsHnKAja8XedNOLVPzJSaupNto6ayFIc+xNIn96QOcrrEshQyhOY4 bMOXQPmlCgfLUWDKCqQZCx62Fp8vuwVW8iVlvywaEKhDRpLqOQhL114VI vDfeW57ngu+j6xY6hk4TBNuvwCnn8cnANFhchF9EkB1t+jLpVZIrLjYVB g==; IronPort-SDR: egYreRsXk+pEDjt3voxUtbvQBQIqr9Svi2y9BR54cXPOonnNdcw/ndhPKw6Wi+0GCFv7d52kH/ TApG0Cp6U7Y5Yr1mTZdO1kKIchwTPG+tD3Yvt+Aq1aqoWjoYzn0ixQz8agxySlNyYRzQp7sZtU PwhjeJvqgdBCP73piuTRE0ibhNToqBJqBcUYVKUgA1uxvE9YysJlnNEEIRU7s3SwGC4En0ldhh Va5BRnFEUVbGdVqen5w6Wcbux0KqYfPfxQ2svBNqDxGGlOuXRlqIXy4ZCRuF6Obn7wvVhy5O/3 blM= X-IronPort-AV: E=Sophos;i="5.82,223,1613458800"; d="scan'208";a="110919200" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Apr 2021 03:24:28 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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.2176.2; Thu, 15 Apr 2021 03:24:28 -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.2176.2 via Frontend Transport; Thu, 15 Apr 2021 03:24:28 -0700 From: Viswas G To: CC: , , , , , , Ashokkumar N , "John Garry" , Dan Carpenter , "Martin K . Petersen" , Bart Van Assche Subject: [PATCH v4 5/8] pm80xx: Add sysfs attribute to track iop1 count Date: Thu, 15 Apr 2021 16:03:49 +0530 Message-ID: <20210415103352.3580-6-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210415103352.3580-1-Viswas.G@microchip.com> References: <20210415103352.3580-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 linux-9saw:~# cat /sys/class/scsi_host/host*/ctl_iop1_count 0x00000069 0x0000006b 0x0000006d 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 Acked-by: Jack Wang --- drivers/scsi/pm8001/pm8001_ctl.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index b1c351dd2704..f3c9fd067272 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -978,6 +978,28 @@ 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; + + iop1cnt = pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 20); + return sysfs_emit(buf, "0x%08x\n", iop1cnt); + +} +static DEVICE_ATTR_RO(ctl_iop1_count); + struct device_attribute *pm8001_host_attrs[] = { &dev_attr_interface_rev, &dev_attr_controller_fatal_error, @@ -1005,6 +1027,7 @@ struct device_attribute *pm8001_host_attrs[] = { &dev_attr_ctl_hmi_error, &dev_attr_ctl_raae_count, &dev_attr_ctl_iop0_count, + &dev_attr_ctl_iop1_count, NULL, }; From patchwork Thu Apr 15 10:33:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 423061 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.6 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 67C74C433ED for ; Thu, 15 Apr 2021 10:24:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49430613B0 for ; Thu, 15 Apr 2021 10:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232342AbhDOKYz (ORCPT ); Thu, 15 Apr 2021 06:24:55 -0400 Received: from esa.microchip.iphmx.com ([68.232.154.123]:51425 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232377AbhDOKYy (ORCPT ); Thu, 15 Apr 2021 06:24:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618482272; x=1650018272; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=fTnjCD7FiE02zqek8rsSIIp2WoF6+WStKn+5hmO0ork=; b=OvlatncISsM+PQolPeFSLJdJW4uKQnkGt1zl0rJO9BS6+rISSzqNzFPX tcrEj8213ABDlAo9q5GfS/wYiVsdixuOHUlE3JMIYfGzuT96jkwWnOqYW sTJEMFkzmfphoDPFOVgoy9g1aII5+2MXfmjgSMTTP5RrjaPp1/Ell4tZO DGM5kGrCxhCNu0FKz6lRRlucmn54ayy6kVNezft1QAPtYPYo5jf/QP+5L 3YfUEbmqHoqSkwg/xz9obO52GohDD7XO2v3tf4Q9Xf7wNk87ZtEeO8ZiA N/QfaRWjb0hVh19q34y4dywH2WU4HHCPEsE4hjR5DSc0P4RjvqxW5hNgs w==; IronPort-SDR: rKg7ipeDJm4uOdclbq2HjKhBjt3yZBVmTs6xZzOS1Bv8AqLY1CVEsrBaZCGk2aSKOTqA1MuWql XzFqbeaJ3KM50o+Bg46RCUH0g0hlDKDSd4u6Xton0wml/lKlv5vT7GJjSOnoODeRDyLbR2AUnY Md2Rvr3p736kaMEc0O9h0z8sANDSGoOq2jFKKo5YxLeCvCHyO+NC1oLjNPGSF6CMG4IXoEHCBh uvuVznnkANjWAvFw8vsoIsQG2Vn0b4a66dzZIvu+a/V5cvEGAB1KcgcLq02Vz8q/40xazbazcx ajs= X-IronPort-AV: E=Sophos;i="5.82,223,1613458800"; d="scan'208";a="113684266" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Apr 2021 03:24:31 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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.2176.2; Thu, 15 Apr 2021 03:24:30 -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.2176.2 via Frontend Transport; Thu, 15 Apr 2021 03:24:29 -0700 From: Viswas G To: CC: , , , , , , Ashokkumar N , "John Garry" , Dan Carpenter , "Martin K . Petersen" , Bart Van Assche Subject: [PATCH v4 6/8] pm80xx: Completing pending IO after fatal error Date: Thu, 15 Apr 2021 16:03:50 +0530 Message-ID: <20210415103352.3580-7-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210415103352.3580-1-Viswas.G@microchip.com> References: <20210415103352.3580-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 31e5455d280c..4e97075d2ad8 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 Thu Apr 15 10:33:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 423060 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.6 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 9EA39C433B4 for ; Thu, 15 Apr 2021 10:24:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8486D613B1 for ; Thu, 15 Apr 2021 10:24:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232389AbhDOKZD (ORCPT ); Thu, 15 Apr 2021 06:25:03 -0400 Received: from esa.microchip.iphmx.com ([68.232.153.233]:32596 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232367AbhDOKZC (ORCPT ); Thu, 15 Apr 2021 06:25:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618482280; x=1650018280; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=XUJD/hLB45soD0T1luoqpQsXxCfhnCkNgM49CXPWkCQ=; b=z4Cbu3bQRbpv/Be7KAd/3tkfHbxrDCFEmBhU456bz+u7h1Hsxla9F0GP m8+W1YUd5NqffBKv4983IMtnBYJNcyvOWnJT+beVEudeuucL8jaQTLpw5 RF+UhcJSy2nKRbHw+ACk5c6gsrKlPjP2Srapv3tWQsf7jj1Y6qvb2Ymuk F/f8y+JIZkaPB+LEBSpoQT8ud3DYfgnoazeSPxA9l7K63yVkeEQG086rQ Gn3SeXS5LmocPXsHqqW1RMJAb6y1s46aWiG/3fuposMexPNMsXXYrjEIb biW4LWV6KTh8aLDQ+2w/Bm4xYRGfLRzY2nqX5qCWb6yzS8k54ps3iozuc Q==; IronPort-SDR: v3XbvVpyvI8wNe8KTksIzAgglYE1yRKiriSq/+vkUlaFjblx0TJhOchcpiLpBjAKs5wQxXkeBS HUWZ/kFkcEwbZ9qXQvGkax1nuYFRomlHs3CsleibMNFz7b3iPQF8kkDTy0lltIRkv95z0g0gQK Sj7Z3i/81JNfPjQoUqab/FrgXmbDzd4g3ppKKEMxBAcB8f5corGOyNBd2wSLfin9QgI+ggYGNj h2yaT+A0aE7fp3VAoNsNaol7L8//0Fzy1lJ3tB1gVCj+KBytuQ1Vhaecv7VilMZkfj6wDXG3Sj LKk= X-IronPort-AV: E=Sophos;i="5.82,223,1613458800"; d="scan'208";a="117118815" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Apr 2021 03:24:34 -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.2176.2; Thu, 15 Apr 2021 03:24:31 -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.2176.2 via Frontend Transport; Thu, 15 Apr 2021 03:24:31 -0700 From: Viswas G To: CC: , , , , , , Ashokkumar N , "John Garry" , Dan Carpenter , "Martin K . Petersen" , Bart Van Assche Subject: [PATCH v4 7/8] pm80xx: Reset PI and CI memory during re-initialize Date: Thu, 15 Apr 2021 16:03:51 +0530 Message-ID: <20210415103352.3580-8-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210415103352.3580-1-Viswas.G@microchip.com> References: <20210415103352.3580-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. During resume(), the stale PI and CI Values will leads to unexpected behavior. 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 4e97075d2ad8..42e8a2e1e284 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 Thu Apr 15 10:33:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viswas G X-Patchwork-Id: 422123 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.6 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 8D0ADC433B4 for ; Thu, 15 Apr 2021 10:24:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7346F613B0 for ; Thu, 15 Apr 2021 10:24:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232380AbhDOKY5 (ORCPT ); Thu, 15 Apr 2021 06:24:57 -0400 Received: from esa.microchip.iphmx.com ([68.232.154.123]:46140 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232364AbhDOKY5 (ORCPT ); Thu, 15 Apr 2021 06:24:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618482274; x=1650018274; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=LNl35VTJtEBNoBz192iHt+t3NKyIkV3J4HMxtpymTpE=; b=oSZ9OlGSYkRhHMRrsIw79JhyXQiPWrNkDGJWGHMo/9Rar4cUq26ELv5n 18LbOVa/nMGMOJ93gpk/Pbi95ZC4TTx17ZoLJ2pLrSkTu1rxfSBTSVyFG 1sqqOyFud3Z0R8YFGLfOdJTVbB+CEnMwzXeQR4iAyM1dvRylYjozQ6R6o 6aZdNdbOU2TR0zz/SGAjH+pAZdzAUMdcKx4X3dmU8BVKDw5xrVxnPTP/N CQhGjnn/kpeM606Mko+ZVcSEB73tIk9XXI6q9pfO8HdqNY1W/SLnVadsg MED1PRVrGXHyAXBtf4Ls2RFXjLIjG2W0EjvvpjA10X6JV1zRX2EruBf0C Q==; IronPort-SDR: +Xdn+T7ViZiWWEg+BjqnpYTJd9NPPcEpqCul4Z7LXCRxiIPoq10m8KflyYNQpsDKyNWu181zH0 urdwXYV3yASXsLgLOmWWxQLGYrjL2Ey8ApLNZFCVclwFg6OMdKl0pVp161SaHQhX22i06gzDdX De+3FTFv/qXWZv2NjmGvyJA1mnTxqeOZLHkE0FM+Cefq+VhFvV3Z3HWDFO9DpI7gX3eLNOBZvE TRhvVMqYJX4Mi9wmaH06yjM1U7Z10mfPPrm5yweXEIZN1HwtYwBoIKK/glVbW6C+8nQUnRWmEc r50= X-IronPort-AV: E=Sophos;i="5.82,223,1613458800"; d="scan'208";a="51231528" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Apr 2021 03:24:34 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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.2176.2; Thu, 15 Apr 2021 03:24:33 -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.2176.2 via Frontend Transport; Thu, 15 Apr 2021 03:24:33 -0700 From: Viswas G To: CC: , , , , , , Ashokkumar N , "John Garry" , Dan Carpenter , "Martin K . Petersen" , Bart Van Assche Subject: [PATCH v4 8/8] pm80xx: remove global lock from outbound queue processing Date: Thu, 15 Apr 2021 16:03:52 +0530 Message-ID: <20210415103352.3580-9-Viswas.G@microchip.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20210415103352.3580-1-Viswas.G@microchip.com> References: <20210415103352.3580-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; }