From patchwork Fri Feb 18 03:14:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1EBCC433F5 for ; Fri, 18 Feb 2022 03:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231857AbiBRDPH (ORCPT ); Thu, 17 Feb 2022 22:15:07 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:55366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231851AbiBRDPG (ORCPT ); Thu, 17 Feb 2022 22:15:06 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 149ECC3C08 for ; Thu, 17 Feb 2022 19:14:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154092; x=1676690092; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u85LIoy2ZxhE8wzXAPZ3ypOuEIVonuWRNbAo6YJw+pM=; b=XmyXiGRUyG8g5Bsn9GJz5evpLtkZpN+KEHrE5m6OesRuxSsD0JtqaHoW 6WjrcEA7Ppbfu23bchEVoG32hj4MOYXwNQ/WHWFqPs4ev+Lon84asaO+R /66mFdsRPGl8W3ryrzJCOdrz+p4QCj2zVVJ0jbEmCtOBJ9gt/6uJIaAql 5T1eogLe4llR6Sk5CjtrjguBKxO5frxfRLd25p3pyYgEBJGiTOHpROMYV fu6yERVVUWOgVn+yVsGQ1+Vf84Qx0hwspu6vagkaTMlucNSKobEGbFhG5 dIOtdQgC5tZygWRNPr7nJnIoYmhNnHwJ0V3Mr6pxPN/rDK+ImQ9FGwe2o Q==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225697" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:14:51 +0800 IronPort-SDR: QnABjHRCn/SW94UDU/5Tc4UcSvDgwMaloqHdXqaia8Gx2MVxgC95ltXrraUpLRS6BWgj2I3ruO gXhxRb6d7qOJQFnttV2iu2pNbDpyL3bUI3SiCVGmxzjb2o4YgU9ojrqnTPt6H9cCQAdDAqZbfs JIioPi8cPc01eRlCrdyD0BJA2QXrZLmVNFy7zH8SaVtF7wv/id2Rw35IkrIJ8c5FR4gy0OkN76 GN+l0XocuD2+BJjFf2mQMaLko5WVoijPralbhEZLywJ9MeZWPHl1Br2fLvhgsSDjJsOHqqM/Bj oJW0ri3n7R9Un5uzpX8U4msK Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:28 -0800 IronPort-SDR: NAxF8SS/lsJoRUduhYcRTEMSIp1djNZbHvQ3xlF2otjW97d9/v2pWYrrXe6bpsrnm0hiltMPLw xBwbv9E5bsl1bWm0K3iBrjTnSVt+tmZcUXEDV2jirl9iCa5d8/oKO0sJ2sDCWcuQLQdiX5Ia1f pRMtKFQOpdJKlorjTRnraU/IhCCqUdyCLgS6Y7hzS1fh3M3UPaeARMDzZgmLeAnkrGCRJxryRV II7BOrVZp6dUFpHPSG/UufUSaIsZV9VBQVsyA1YjirrhqB4rt3JTcajDjsmHxEwm8jJAp+pZ9T 14E= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:14:51 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyf4G3wz1SVp2 for ; Thu, 17 Feb 2022 19:14:50 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154090; x=1647746091; bh=u85LIoy2ZxhE8wzXAP Z3ypOuEIVonuWRNbAo6YJw+pM=; b=g0s5WpPTksgQ+GiTqbkn+cBcJGjRQsx9bm 3nyX34VwPx7oidUhx1Tw8g1VQk6cgNHQBlt9/3CbTnfGRjf2beLYoqUUvyq53Xts j5fmHdo2wu4aXyF88yOY7RYzXLG3vMySCGYn6JS+YYhCtaw7YbnBpBlpVEmrvwX9 E7R1iqj7ZTdVRxFWw34edP7vM9aTNelCC6CHf7B4blxFPnLSyr68vFSmyaRObyg+ 3eKHxeqV8DIuyKe3FQ1WvQbzPjWBrboQLUnAYipDHZz4Jz8IMBcjeNczEI3G2Vhp UB/00btnxhQyLA2FdiOhrSPIgFvmQHS+G2CNv5MWzy3RihkLY7lQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id uDP4MPdYEAz3 for ; Thu, 17 Feb 2022 19:14:50 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyc5DzXz1SHwl; Thu, 17 Feb 2022 19:14:48 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 01/31] scsi: libsas: Fix sas_ata_qc_issue() handling of NCQ NON DATA commands Date: Fri, 18 Feb 2022 12:14:15 +0900 Message-Id: <20220218031445.548767-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect for the DMA_NONE (no data transfer) DMA direction, sas_ata_qc_issue() tests if the command protocol is ATA_PROT_NODATA. This test does not include the ATA_CMD_NCQ_NON_DATA command as this command protocol is defined as ATA_PROT_NCQ_NODATA (equal to ATA_PROT_FLAG_NCQ) and not as ATA_PROT_NODATA. To include both NCQ and non-NCQ commands when testing for the DMA_NONE DMA direction, use "!ata_is_data()". Fixes: 176ddd89171d ("scsi: libsas: Reset num_scatter if libata marks qc as NODATA") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/libsas/sas_ata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index e0030a093994..50f779088b6e 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -197,7 +197,7 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) task->total_xfer_len = qc->nbytes; task->num_scatter = qc->n_elem; task->data_dir = qc->dma_dir; - } else if (qc->tf.protocol == ATA_PROT_NODATA) { + } else if (!ata_is_data(qc->tf.protocol)) { task->data_dir = DMA_NONE; } else { for_each_sg(qc->sg, sg, qc->n_elem, si) From patchwork Fri Feb 18 03:14:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EC24C433F5 for ; Fri, 18 Feb 2022 03:14:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231861AbiBRDPM (ORCPT ); Thu, 17 Feb 2022 22:15:12 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:55460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231851AbiBRDPI (ORCPT ); Thu, 17 Feb 2022 22:15:08 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 885F3888D1 for ; Thu, 17 Feb 2022 19:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154093; x=1676690093; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8IJQAYYmg8RPwzlveiqyKuKOi4pmaoiH3Uli4OVOdwo=; b=b9OVl9JDzMOXGy9H7fX5h2ajqST6Pzc14m7M0gz2k5X6Az6wn7NQga92 OXrmmlJ75lyprRdIcHWNJnU378ku0qHwsDOnRzDokXdyEc2bEvJL6eOyP xJOaIy/tajwgBU3sV7QOUIqQwAbP7VMImyx29QqnePHIBA2hBvP/crJEt P8CpBMY1ncDH/U/JsXDjP9iii9mqXqFHN7kO2v7S6Zdahe/K+qeK7p6hW tq9+7HrjqiOJT9oGUuwEciUU1io9PmXOI2E20IjdXluJv6HBHPm1ygc0q C6i5YGtdhXruCroiuzr2ZuEuCnHdAGdACVVz0vMcEltLGASMZ5D9VbRjZ A==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225703" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:14:53 +0800 IronPort-SDR: uxSQWhNP4gvMmlFGHChoJm0E/I1aAp1X7uXUah9OHKtW97ztwbPW/xmtOtNvSYEl6wx2kP9SbK 52fJmZc97JscRctNToRvw/OLH6bl1YqNLeWeMhd+tunX5RFYSN5lmfLsTK4+VfNtjjQVw+xPLb SzddmNpFLfBXivZdK9dOoxnB0cUyAaciUOPOgFCvWFm/U3bA+PMFdC8UQI52fNOvwhA7ohwkvp Sisd3UrN7uBlr6PBihZDMqZCIsCSF/xYU8d04lU45CUXwF8DhGqti0wr5hG4wokYxEoshxF4ZW OXQQCq839cQLjuCAR21oN2NP Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:30 -0800 IronPort-SDR: c3fliS+H7gEyeyG/gPgWApM0oX22LKUD7Frv0RUTDal+z4DCawRzBxWqj6IPF5lGmwG7zGAtIh zwz01ekq3J4eBp7I0UHjNa93jeG3SgwLtrQ2aGKIT1xv5nsqQ+tHXB0pFv5RoZjisZO3/Xh0IZ LSX7Lg36Olkxv/+Ku1RPaDnsbrxkABUUmEPsY+CeESABDgBJ8yttbbStPWO6KRJfjG585+UHBV rBJIxg6AScK5ZtL1LRJ4M2z3PHEuxU6LqILk4S7GmEtjxW+ZJHR+WDGIwERcH47hpDM4Zb+Eca Esc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:14:52 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyg6T5Fz1SVp2 for ; Thu, 17 Feb 2022 19:14:51 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154091; x=1647746092; bh=8IJQAYYmg8RPwzlvei qyKuKOi4pmaoiH3Uli4OVOdwo=; b=lITQAkYSotqSaXMsepawRqyhOZLl7aixLf BibxfajQnyXymcj2LGotNzPj+AxGP+ssL+BM6Nar3nthnT0mdd8vl6OzSFecr9PW 4Ftdn+y25YkBgl/j8VBuO5vvBqnFo+xCWg5phTff8SnAcJO1+GBIbQKWpSKVJ6Za wUwROjACiYbV17YaWtBSp99mQqWQz/K4XYofFj2zhcljKOcC9weY5te5bTxJzA7c 00baGZH9gcGlCyaZccWhQ8Yx4S6WI3FfsDIEWlDeTfk7kZnaU+3xxtEdmHDDzHdm 5xtwD/sSEQVWDuS5ePY/GRBwBQX0cmxqE2PMfOCPrfOSaNRPChoA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KAzTsactANad for ; Thu, 17 Feb 2022 19:14:51 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyf26Lqz1Rwrw; Thu, 17 Feb 2022 19:14:50 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 02/31] scsi: pm8001: Fix __iomem pointer use in pm8001_phy_control() Date: Fri, 18 Feb 2022 12:14:16 +0900 Message-Id: <20220218031445.548767-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Avoid the sparse warning "warning: cast removes address space '__iomem' of expression" by declaring the qp pointer as "u32 __iomem *". Accordingly, change the accesses to the qp array to use readl(). Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_sas.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 8c12fbb9c476..4ab0ea9483f2 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -234,14 +234,13 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, } { struct sas_phy *phy = sas_phy->phy; - uint32_t *qp = (uint32_t *)(((char *) - pm8001_ha->io_mem[2].memvirtaddr) - + 0x1034 + (0x4000 * (phy_id & 3))); - - phy->invalid_dword_count = qp[0]; - phy->running_disparity_error_count = qp[1]; - phy->loss_of_dword_sync_count = qp[3]; - phy->phy_reset_problem_count = qp[4]; + u32 __iomem *qp = pm8001_ha->io_mem[2].memvirtaddr + + 0x1034 + (0x4000 * (phy_id & 3)); + + phy->invalid_dword_count = readl(qp); + phy->running_disparity_error_count = readl(&qp[1]); + phy->loss_of_dword_sync_count = readl(&qp[3]); + phy->phy_reset_problem_count = readl(&qp[4]); } if (pm8001_ha->chip_id == chip_8001) pm8001_bar4_shift(pm8001_ha, 0); From patchwork Fri Feb 18 03:14:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C303C433EF for ; Fri, 18 Feb 2022 03:15:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231867AbiBRDPN (ORCPT ); Thu, 17 Feb 2022 22:15:13 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:55538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231859AbiBRDPJ (ORCPT ); Thu, 17 Feb 2022 22:15:09 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85654CA0E5 for ; Thu, 17 Feb 2022 19:14:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154094; x=1676690094; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qwEC/HAHMVugj2YgjUkTAgDhC0DdmBvV/+2YVPjh/G0=; b=EooV5h6aGbqmhBkFTx6H3oxFlVC0h6RHGw0Fukx1hf/pm++H0xQPJiqN yL5PdnllULTGtzIcq+xmBcA5jwMOTgsGxHdkjOJFdPT0daeF6kGqQGvxd J0iKaQLqX93i+MnvUmLYjklOAwosX2BdzvaHvxusyLbYqN7sBR3kKzPTg xVVIhpAWExINzemzBoMLRRC7wiihQbDk/BZqHh28t9ihYip0hU+V4eee2 wZnVw3idwTDcU+M6j1MLH4vcVvRBIkc1NJJpcsbe2Evm6hAxnV61h7BhF pZrMKQTbiiNwCISLbxtJrCZKKI2F11Je7ccmffXbn4rtl7l77sFxNcRuX g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225708" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:14:54 +0800 IronPort-SDR: 7GACDYuXP3oeTskFUikOWQh8YMkmmDq9WrNibi5UYnzFpXhOzL0y8WuJa/Y9xcoPLcJySAFyMi 9GmVo1r/5mIWQfOM2KGutD4J9P/4u+TWsJMA3I3EA5CXtQs2JSEdTlTzeggfYDKHKhHXqDUTC4 CmxdXPMAgxlfrxwwVF2i0/zwS+asgYrcPzxCCtJ2hIer7HPpIffdRUwTDBSni3RDmVYykcUdQq 9gbp+GV/E4/HjF38Gep+DYVNF7VjmM0cWMZ5VtoLOXCYtTqiLk6Oc/x19eFGKB0if1JRrZjAco BY9rSEspR61riLM1MGKzTZrh Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:31 -0800 IronPort-SDR: W9o9SEdq/uudVCM7eYLFXI+/aOXup5YbFu2VF8tN+EjB7axviY7Lj4zfeb5UYkNPQkRXg+lLNS 2uK5Wpb/B+eI87xxX6JkrufX+BQcia9239y1scauN2/ONVhCYCDJ2CHjbmeWuZLktCJDX/Jnac TUHN5NuqboF4e7ijpvinRZltsdeyVx3AxRyAYc0ct21j+Qmh82w0E/BZWatq41SMWei7RhGYI7 g/+qz5waNjBQnkmPfliwKBqzkfKHXH4zdx2l/aPigIGbQaXhD/qSGnPXEPhB4m+yjovsE06/Gb BC8= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:14:53 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyj0qKMz1SVp5 for ; Thu, 17 Feb 2022 19:14:53 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154092; x=1647746093; bh=qwEC/HAHMVugj2YgjU kTAgDhC0DdmBvV/+2YVPjh/G0=; b=YF5u5Z3Q3kPwHuowQO45ZH3YYe5mpBG2Mp UmfjQuP42QOnBe9yMavYsscO/DxekGGmMpPJ+7pc6FkX22LQXKyU2F9flz/U5TsY nLyrTMQaj4FBA8E9EIb+KsHFpNNf6JvjosMCJxTmu1wntiedP/ySupORgvndF6LV oIhWniUuewIPoWxe7yIDIZE03QtTvurg05lZOrK9ewfJhmmbyy4mDoqjZJMFPFeO RqKt3QGofbV2htLcybuXZMR+aZtoYr2444t1C6+JgmEFGAJKP9diHW8F9lMEv7Wo qsc2SKYUjfcjagq8Yr2SSZKoFxw/sPrVHi+bKcvCcBks7f8hS8zQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id O5GGzwnMDQwv for ; Thu, 17 Feb 2022 19:14:52 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyg47zKz1SHwl; Thu, 17 Feb 2022 19:14:51 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 03/31] scsi: pm8001: Fix pm8001_update_flash() local variable type Date: Fri, 18 Feb 2022 12:14:17 +0900 Message-Id: <20220218031445.548767-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Change the type of partitionSizeTmp from u32 to __be32 to suppress the sparse warning: warning: cast to restricted __be32 Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_ctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 66307783c73c..73f036bed128 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -721,7 +721,8 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) DECLARE_COMPLETION_ONSTACK(completion); u8 *ioctlbuffer; struct fw_control_info *fwControl; - u32 partitionSize, partitionSizeTmp; + __be32 partitionSizeTmp; + u32 partitionSize; u32 loopNumber, loopcount; struct pm8001_fw_image_header *image_hdr; u32 sizeRead = 0; @@ -742,7 +743,7 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data; while (sizeRead < pm8001_ha->fw_image->size) { partitionSizeTmp = - *(u32 *)((u8 *)&image_hdr->image_length + sizeRead); + *(__be32 *)((u8 *)&image_hdr->image_length + sizeRead); partitionSize = be32_to_cpu(partitionSizeTmp); loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN, IOCTL_BUF_SIZE); From patchwork Fri Feb 18 03:14:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0382CC433F5 for ; Fri, 18 Feb 2022 03:15:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231874AbiBRDPP (ORCPT ); Thu, 17 Feb 2022 22:15:15 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:55642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbiBRDPK (ORCPT ); Thu, 17 Feb 2022 22:15:10 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD1CEE6DB8 for ; Thu, 17 Feb 2022 19:14:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154095; x=1676690095; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hIyOX+6jIqSb2Fpc+Y+ejgZhw2rZ7ZNLwrTdrjMSzOw=; b=O3yZegk642P6FT2KsdtEN3AmubYAM8tItjzFOrtvPSJgZyNQa0BLJEjo xPKsDS6EAGo8jrNWXL9gDaUixhsEy7MmG9WGPs9glq76czZhNBcP/ZApc ElcScsXOBgSi+umhvl1wyY/Un8dC5Vfe34moLZqO576/xHvkDSWbYqSkC 9D+i0ec5AuBNMP+zU8VrOb2bsdgPFQvRU50IhpRC5rLYYyi6xPipkprcR Fqybc/oYzCR1v7hI4Y8fIQrHRE8bHgwhISGr+TlXQzruOSbac802ceSjG UDd5oQGVpN6YzsC5Sc8XK+XWeKuOAiOXlq6wkK61HemPv+1FTx2/fGL+Z Q==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225712" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:14:55 +0800 IronPort-SDR: AKzBVorCRPjINbfvkptrirpWgq1vNXb5yrTTp+lJJ6K5Tc7Cuapc3vNYZd9tUaMRULk+1h/ouZ ZZHBq7S71QXYb7xApD0HUoHSy/Iepa9yNu1+CdeljxdwkppnwegY2IDp3dAMk4z/DL/0wGPYiy RaiLeuLVZj2HWQ8fRuBp4IuQO39ln+UyAtJmW0Zt2sgXhppXrQUQURA4DFSKYWhhOlMBuJe/Sr JdJ6+64VRJyHE2bcYlSe6/iDO2sB6T4AcG3RyztWHO+KUMRDckcdwSprhG4cXn2HI2VasJhJNS bTr46Uf1vm1gCWN3+mniLAp9 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:32 -0800 IronPort-SDR: UL11W49RZqPZvQBg8MlcLaFBzww+LZiQ13SsLVcgxy4UjUQH/usdl9l8jDyMHdq7U/uIN7Tng3 z/VFKhlaz2mF//CjDVjuCOz5SpIyWZmYrXQoDlt2pDEleXwqZFWA7yXCiIJJyswCZT+WXDBJLp 0X1AnDTh37JO7ZZLaQgUDHnhWH+l+vgs057LwbsJ4Py75agNQvuLFxLQkHHa+3CnCdLfq+Egiu x5WfApmFI5DjsSgnI5Ib+CMSAtNSGWd8MNF3dSqnK11+8dpiofrUWhffEwvgr0g0eSXT+SU9U/ h5k= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:14:54 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyk37LTz1SVp0 for ; Thu, 17 Feb 2022 19:14:54 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154093; x=1647746094; bh=hIyOX+6jIqSb2Fpc+Y +ejgZhw2rZ7ZNLwrTdrjMSzOw=; b=Evshxea/vlBhQBHNxtfECc+mxBf3owLID3 euHa6DHJlW5UwNxkx5cYnrOFLz+lOEg/aUvEagiXF4bR/ZNW23btWtuWKbtd3w7A uwkudw8PYiLOY9EOUR36B+G2/EzTlbvKsfIMj9CZyDgTcRwlFLcEU8DgcqqnHmYc VsvYYHzbTP/N2FLPSjc9M4e7yeTu96q0Mycf8FekqPT9w9VvBk2GEfmH/kcEIsAj mkGh7K6WnI9Jb+ReD+wwzYedXaKy6cneI36UMQKgnbQ0bSn+gXIBUiFOLfXjdV8T JxKjisPH69V9I5UaOoJMJxRa2dTx6eemPdhxvqNAr37YWLuOac6g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JrzMiupjKodJ for ; Thu, 17 Feb 2022 19:14:53 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyh6RbPz1Rwrw; Thu, 17 Feb 2022 19:14:52 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 04/31] scsi: pm8001: Fix command initialization in pm80XX_send_read_log() Date: Fri, 18 Feb 2022 12:14:18 +0900 Message-Id: <20220218031445.548767-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Since the sata_cmd struct is zeroed out before its fields are initialized, there is no need for using "|=" to initialize the ncqtag_atap_dir_m field. Using a standard assignment removes the sparse warning: warning: invalid assignment: |= Also, since the ncqtag_atap_dir_m field has type __le32, use cpu_to_le32() to generate the assigned value. Fixes: c6b9ef5779c3 ("[SCSI] pm80xx: NCQ error handling changes") Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 2 +- drivers/scsi/pm8001/pm80xx_hwi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 4683fee87b84..817bba65feb3 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1864,7 +1864,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, sata_cmd.tag = cpu_to_le32(ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); - sata_cmd.ncqtag_atap_dir_m |= ((0x1 << 7) | (0x5 << 9)); + sata_cmd.ncqtag_atap_dir_m = cpu_to_le32((0x1 << 7) | (0x5 << 9)); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index b83500ef3d86..f1663a10693a 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1882,7 +1882,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, sata_cmd.tag = cpu_to_le32(ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); - sata_cmd.ncqtag_atap_dir_m_dad |= ((0x1 << 7) | (0x5 << 9)); + sata_cmd.ncqtag_atap_dir_m_dad = cpu_to_le32(((0x1 << 7) | (0x5 << 9))); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, From patchwork Fri Feb 18 03:14:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5062C433FE for ; Fri, 18 Feb 2022 03:14:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231866AbiBRDPN (ORCPT ); Thu, 17 Feb 2022 22:15:13 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:55778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbiBRDPL (ORCPT ); Thu, 17 Feb 2022 22:15:11 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42CE9120F7A for ; Thu, 17 Feb 2022 19:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154096; x=1676690096; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tMu46lOD+saf9CD6nTTB39TE+9yuObAVdHXvuV2n3JQ=; b=ispgWspZ//Zbk97JFY9vwUtvWEd345aH3b5rb+cUQlENx2Bij9/SvuPO W66a3Ykh/SiVJn5t1V6aa66ye3OFL703KKwtZfDTmVnQws/pSgV/h6AV8 d/gd0ghdtQ6GbBS9nOWfELg6E376EP6Twk6IkjsFEERFyc1p6MbTmF+TP fXLAN05EKnVdBzL3SgOBUxixn8P3b3MIdhMCSQcCGKqwf6xfqOvrK3ZVJ ppikJkvzzhJgYjRsTWX8W2ad2bUZ8Magwc5fkxXW4bs/LY2ciH7kPq6qD p31TO4WEsFjqC9gq87w5k1l6TeKAnjuqPYRoVzqGNNrEfTnh0hQAmfnMt g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225721" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:14:56 +0800 IronPort-SDR: +evSo4T/iUbWYEqisD9keRhIxupV+bmLaQ9lvU7l8v7Ap9hq/6PB5/dmMpVRevvG0ldGkQicLW iLzb1B6A5t4YPSTsKFyeabXWnkXvONoR7qN1SxDJ7RZ/oplaOaAf/fi81+/efdCHwmxgxhsB4l nPHQ1dFl26ho5lcElLO3l30hKWzVPqPXbdOSFhVK43FW9pq6cNUsIehD6TDuzt78ASnrpNnD/z wk1tPPfe4EhD9s3Ayde5PUcOQ1kjUNc4XF2o+4lZDzac/D6IjgJLwDvUJS1qEtQaowFj/6Ml1D txG7lCBHpxsBm9l1jbqpkFPa Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:34 -0800 IronPort-SDR: aVcmwAPyWMmmWPJxnWoSF4uvketdAmvOJxzInNsq78fnvBeyh4Z7VKprV9bH4HciYY5umRS+8f Q3UVxBcWJnmN1uZ5lii9YtALKkm8b3rSbyibwhonqWz/TZj09sYSVvl/9g1mhDS/e7URoMTFtu Un24eqnBWdhoLl/rPPyVBH/TmFv0hjQX9Wr+bQN52kJAvFIjDNNhWLt5sdYYBBiVEqO3Iz/N/H sw9oyBZUnB288FKOTU5Fk7EqLPnZ2v54HTYmtbyqn7jIYAfQGn3nNMUFyK3gc38qRpT5XIGR0k kXg= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:14:56 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyl6VM8z1SVp0 for ; Thu, 17 Feb 2022 19:14:55 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154095; x=1647746096; bh=tMu46lOD+saf9CD6nT TB39TE+9yuObAVdHXvuV2n3JQ=; b=t0b4oxhiy0vnOQ5uqSNWre+bkCOSOxH21i qJrt6njRXAQH/N1NwgyGZGrTjiafq7V9HizpgEqgBkc8EoUN4BytvjMoeFz4fv6B p450MKEM1ZpG84UtCAxjk7sW0IMmZZosPxQeAEEZjJt9dMp6vT6QY7ewxyNG6NL3 2e26PoIS/e3Obi+MKezYAXUw/xDrDnPslcnvmygyUWuq0cQz5Zhz/j16alUuY6PD XMz/ePbRQcljKycAheV7q6zmYMaX5oo44sgAu3Hs8jiBtg4tfgbEQt0yShSNIJFG 0Cz++nN0yPI4XsxMgKNG8dvtCZT5Dm7l97LRLwJwl3y+7WTQSkiQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id RF7rx7VEBwZN for ; Thu, 17 Feb 2022 19:14:55 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyk2LrWz1SHwl; Thu, 17 Feb 2022 19:14:54 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 05/31] scsi: pm8001: Fix pm80xx_pci_mem_copy() interface Date: Fri, 18 Feb 2022 12:14:19 +0900 Message-Id: <20220218031445.548767-6-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The declaration of the local variable destination1 in pm80xx_pci_mem_copy() as a pointer to a u32 results in the sparse warning: warning: incorrect type in assignment (different base types) expected unsigned int [usertype] got restricted __le32 [usertype] Furthermore, the destination" argument of pm80xx_pci_mem_copy() is wrongly declared with the const attribute. Fix both problems by changing the type of the "destination" argument to "__le32 *" and use this argument directly inside the pm80xx_pci_mem_copy() function, thus removing the need for the destination1 local variable. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index f1663a10693a..0b3386a3c508 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -67,18 +67,16 @@ int pm80xx_bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shift_value) } static void pm80xx_pci_mem_copy(struct pm8001_hba_info *pm8001_ha, u32 soffset, - const void *destination, + __le32 *destination, u32 dw_count, u32 bus_base_number) { u32 index, value, offset; - u32 *destination1; - destination1 = (u32 *)destination; - for (index = 0; index < dw_count; index += 4, destination1++) { + for (index = 0; index < dw_count; index += 4, destination++) { offset = (soffset + index); if (offset < (64 * 1024)) { value = pm8001_cr32(pm8001_ha, bus_base_number, offset); - *destination1 = cpu_to_le32(value); + *destination = cpu_to_le32(value); } } return; From patchwork Fri Feb 18 03:14:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1D39C433F5 for ; Fri, 18 Feb 2022 03:15:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231893AbiBRDPU (ORCPT ); Thu, 17 Feb 2022 22:15:20 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:55878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231864AbiBRDPN (ORCPT ); Thu, 17 Feb 2022 22:15:13 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F8C4CA0E5 for ; Thu, 17 Feb 2022 19:14:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154098; x=1676690098; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fXOF40/S8zEtelNS6z7k47nZ1ECRVRdZ58w3E2pA9QI=; b=dcfnO1/QWgK+QJ9QD5e133biJ2ehmggNfpjdcEgI7Fxb4KmXV/deaLUC k9S3cS8trZwSxiSE5IgkgsZJVoAR22nnmisQolqBv4DJBEIa8z3UFwbpC RepssthUr3LtOR180+9LJtMYMUqkMeJyzfO2egWhyGqR8HttH0ZkCIDJf Vr/Y6Mh17OFE9tyAC0YGNPSpVbajpXvYlgLLXi3IaAiI/HDfgbbxneWU9 bcOQG/KV+4+E+Aw+Mcw+9ilNIYoySpAc23PIL/8GTMaLpCUs4jOWDfkNU XQZMkf+w2Xi7T09bikocnSs8/ON7RLDD7SbZmOIFkut2HHuWzqipfirEH w==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225727" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:14:58 +0800 IronPort-SDR: rsHF2bcfFDZK9i5jZ8AtaNpCqcxRq76Ym+3j/T/jCR3pmQIu+LV0UhJdyajFcnSGuooRuO64Zv 7bG3MZ6+3eMco3gYmBniMIV0xHSv/Qd1KQdUMHGtq+agtTz/dycw7YQL0HsM7KdbhzgkfI/5g/ QyMvjovHCGgPXa1cq/xAk1k85qbcj5AfICmhaVmy9V176YR7Ydc8R1AxBzC1OeEZgjSeUdVYpd qWmzLfnZNg8o91Mt4LiQPr4I9nOgmvO9pcLSGg0QchsxoMNWcxEqEOiEaqMjvhN3FndQNqrcMp YTpsIABRs/3uTP1gnWMKvA8Z Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:35 -0800 IronPort-SDR: 0IEMrdPdYKcSsQ0dcwYvFlSpyvjRGnB5ilB8HaJVi3Pemuha5Q8nHrixDvUw5w8dAy0Zy7n+Sq hh/r3qQO9kPkIBbGx8eD6q8nBTDDCLreGT3ZpSW7L7LQsRIbnYMnX2gA+2bCA/AtXbyNXVIflM mCh22kmQsDgYQXA5HS9wNUqN16p+kQF7yznIo0ulfZ0agNseBbvtNV1csnu2rTRv/aVTuq2jv3 nk5qcwdWGJJslZLxP/iwKy91WajD2JjtL7Jxij184QYxnebqHN3+VD7V3DC5rvoX9RS2B33tvI Xgs= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:14:57 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyn0txLz1SVnx for ; Thu, 17 Feb 2022 19:14:57 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154096; x=1647746097; bh=fXOF40/S8zEtelNS6z 7k47nZ1ECRVRdZ58w3E2pA9QI=; b=JnfEed6jbUmZVBXxIBM6/LKFTaWqaF4jWw PQpAy5nC5TOaUVb9Bn5qykIjSzKpN/YIAYTk6Lz991xM3Sxkf+PAeJ/dtOsYio4i 31QsHM9f6cLy5E/JIvvmZF64yiK3cDWh9BaSGdiY34UDuZhFaRbAwws3cmvPZUW1 9LWWN/HEF97lPZG6IVArwTdJgdDKkbJjuvpDPOzuKBIO++UZaxxAP6T9Oke6vvQx 6zYxU27ZTvoYkJxM6BLIfRiiLz7qDOKGb3pVIV9w1I1SxYghnNArCU7f8b8xpLuE rSibEL5GpWcygVMLpdkPZhN4uBPWgko8ULUsB+xBaUGu7eT0UYcQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qqCYizVkXRP1 for ; Thu, 17 Feb 2022 19:14:56 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyl4tD2z1Rwrw; Thu, 17 Feb 2022 19:14:55 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 06/31] scsi: pm8001: Fix command initialization in pm8001_chip_ssp_tm_req() Date: Fri, 18 Feb 2022 12:14:20 +0900 Message-Id: <20220218031445.548767-7-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The ds_ads_m field of struct ssp_ini_tm_start_req has the type __le32. Assigning a value to it should thus use cpu_to_le32(). This fixes the sparse warning: warning: incorrect type in assignment (different base types) expected restricted __le32 [addressable] [assigned] [usertype] ds_ads_m got int Fixes: dbf9bfe61571 ("[SCSI] pm8001: add SAS/SATA HBA driver") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 817bba65feb3..e20a1d4db026 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4619,7 +4619,7 @@ int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha, memcpy(sspTMCmd.lun, task->ssp_task.LUN, 8); sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag); if (pm8001_ha->chip_id != chip_8001) - sspTMCmd.ds_ads_m = 0x08; + sspTMCmd.ds_ads_m = cpu_to_le32(0x08); circularQ = &pm8001_ha->inbnd_q_tbl[0]; ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd, sizeof(sspTMCmd), 0); From patchwork Fri Feb 18 03:14:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68730C433EF for ; Fri, 18 Feb 2022 03:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231882AbiBRDPV (ORCPT ); Thu, 17 Feb 2022 22:15:21 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:55976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbiBRDPO (ORCPT ); Thu, 17 Feb 2022 22:15:14 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7C1112A757 for ; Thu, 17 Feb 2022 19:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154099; x=1676690099; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QveB5a+85eplIPaj4PtIIZ6/INt1r9nE8RbC6a9EBNw=; b=Wp4+TIFyASAvpaFCriKR5LGaV2Y4Rq/ZxFSPE8POnCp8GJ0E69oNHhRK iUgQiEaH/gZD7mBV1c+tESqswNgnLaA+HAzUT27v7qv/1lCx8g1DbGDw9 ZnFVVW66cwcRmV7rMZrFe3CBF4hya1Fx8Q3mlROX/l+AgDvJuB8U0Zcqj m9L0o0ysRtqsxsiCQ/6jI7ZOjZNP/rigRHhIF7Ub9nLgq6DQP4cCGgm/F ZxwL608GyR2HqLHgL8Xtq/7J4V3/V+dWAWZR4FI8eXemL62Tqa9IVl5u1 rhlu1jvdfEFAuZoozEsQ/pGyKPm/QuxAW9eEVCAHrTG0UTr3gdRu7VRo+ g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225739" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:14:59 +0800 IronPort-SDR: BibEM7Ah4e0IsacXQjoQnEtT0od0HAurkfC99BPqf6OVv5zGbjVH2UcEuBot20EM3UX1/IZmAB Xb0mnIhPCuIPz+wzF5W+i24RwinA/V6WAJF3NbBlKMDnFkUFrm/+xNhlFrELNCEpi+Dd3I6/GW QMocKmGeDOPxOzqd00Q2pyel84hDu/Vq1jK7cf5Dasdk4GWmWO3L9jdSxAcw7C7b28C0ibrEZz zYgWe16tqp8VJ1OOgNnuUvFyzofqvousk73ruOmcTk+IX7Bn8jX4VV/33ANz7NRE8JHhjxjfuR aj9Mi2ANfbEB+NR2tjnWUHfe Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:36 -0800 IronPort-SDR: R016TXp5/tqhfVfRpepRMldI2x+qVcDhd+Ja5GZ/kjQKK5e8uS67NDpUhHACKxVbDctjEZHukC egCvNUb3xxDKO617recJtyBgRkmAxoyjRLin/Kr1Mkz5vopDMhGzMOAyzPiC4wrDrRTb0IzpNu PGSUeRTfJlSP9xGVJpN1XdjM34tBygWktkUhdRUw0sXpU459Mo2VTE/QeGW49AoPYstUy89Y3t 3HTGQgsjbt3Dc6GPV8BPkq6IAwrMCazA8ZB92NTpEEMPtSTNAIP6ZbVBe0VFXNnVQGVjn72ttJ CpM= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:14:59 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyp3qFGz1SVp2 for ; Thu, 17 Feb 2022 19:14:58 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154098; x=1647746099; bh=QveB5a+85eplIPaj4P tIIZ6/INt1r9nE8RbC6a9EBNw=; b=O3CM1o9wWrYqTwW0i4S0wfAhOuUDRw7Z8S SlIOMj/0FdY0ERaYd2/ov8ee7V2LKTbEfvJsrczn8CLS3j4hV4GRmV5TEesUCOKN nqfsVIULxmEKmoDZIpxiFf13WNeaVmga4ZMpLVuhymEnoetA/OCP9/zcBEmLWo19 M6kPIThOMXgeolDIaGu/vFSfYF44oJFFSuRSI1pa+x68cZoOpxJch3qKoQaNAjvx GOQopLCkVKfXdua+jTfkrLwDi/5lN6UP8Z3NY5UfxEpK6pbyK3J77qlLOkWGIu/y 0nooRKzAIr7m59/4BuF/x/0F4IyPLt5gtrnBxUs9nALeov0HjyIw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id j5531HukGC6s for ; Thu, 17 Feb 2022 19:14:58 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyn0Gs5z1SHwl; Thu, 17 Feb 2022 19:14:56 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 07/31] scsi: pm8001: Fix payload initialization in pm80xx_set_thermal_config() Date: Fri, 18 Feb 2022 12:14:21 +0900 Message-Id: <20220218031445.548767-8-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The fields of the set_ctrl_cfg_req structure have the __le32 type, so use cpu_to_le32() to assign them. This removes the sparse warnings: warning: incorrect type in assignment (different base types) expected restricted __le32 got unsigned int Fixes: 842784e0d15b ("pm80xx: Update For Thermal Page Code") Fixes: f5860992db55 ("[SCSI] pm80xx: Added SPCv/ve specific hardware functionalities and relevant changes in common files") Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 0b3386a3c508..b303bc347f3d 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1201,9 +1201,11 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) else page_code = THERMAL_PAGE_CODE_8H; - payload.cfg_pg[0] = (THERMAL_LOG_ENABLE << 9) | - (THERMAL_ENABLE << 8) | page_code; - payload.cfg_pg[1] = (LTEMPHIL << 24) | (RTEMPHIL << 8); + payload.cfg_pg[0] = + cpu_to_le32((THERMAL_LOG_ENABLE << 9) | + (THERMAL_ENABLE << 8) | page_code); + payload.cfg_pg[1] = + cpu_to_le32((LTEMPHIL << 24) | (RTEMPHIL << 8)); pm8001_dbg(pm8001_ha, DEV, "Setting up thermal config. cfg_pg 0 0x%x cfg_pg 1 0x%x\n", From patchwork Fri Feb 18 03:14:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA659C4332F for ; Fri, 18 Feb 2022 03:15:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231868AbiBRDPW (ORCPT ); Thu, 17 Feb 2022 22:15:22 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:56144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbiBRDPP (ORCPT ); Thu, 17 Feb 2022 22:15:15 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B05142361 for ; Thu, 17 Feb 2022 19:15:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154100; x=1676690100; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tEJfk/UE9FOASU+9JhmgRQlEK/ajrA/oKGoTSJqp5mA=; b=fi2YExuiKF3/OORXPnFgt5y4kYhvUSUmDGeT0t64ecNhD9OSr7If0cTy QoIloR8Cflc0O//qoA/zST/GmwiLxwu4+EQfzDH/IkCLznZjBvXzOIFBZ c6gZ8DL/CymQ/HaX1iUZYe7RBfG2QSnsXja/JgNHaINhQy5/olmBtDI1Q MYb9H48bQkE9ptOdTXZ8GFBqYF5nvVXEnWRFsKhiLys9bS2Z3AOMV2Pvk huG1zioDDaClUGCC3BjRbs7Nyijm5ALOjSzP/NHaeYx10SfD2VWlfVuXr ZyUm2F5NYe3w6gJq5Smom7E1PiQiVYAw7w2BJzCXoyqwfBK77JkbLXy47 g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225746" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:00 +0800 IronPort-SDR: X8JBYCTSk1FDbdJzhPCrm0QHpvd8VnpQA49wc3RKxuM67NG7yFKkpfPdr6UQIwV5TTS9VldCvO PlD89w4zlJXQI+tDLeY1qoIU0P5gs4m20+/a+DoRddZL+bcY8LE9pZeGWk9NAlZjFMClU8tmeE tckFKvywzjcJz78IOVWOOT3LeSH5pehGupmrY4HLNQwhoJ5Zv4J/RqXSfLk9W0Ptg1k56mP1cQ 0xJSRVMXoMldai7EX8PvOL9JxM8pQsIknTZ5D2/Z7SKqj3p5uHLDjvN2LI/8avu8VM3+Bqs4+N FIZQWTcqpMyvb2BDlRbyClBA Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:38 -0800 IronPort-SDR: J37z8VpWZPhWsteigs4paHKTeUFUHxS6sDXDpmSV4zM0rpwgo39lRGsVSbK6wWy5pA0bG87DPk hA98r5LN3FdZyH1sItHyMV/g2cL3obd3IxVE1Z7CLhARGuHqmho3HSkdcy3hLrgxTiJ9KDKLr0 fcyb5rfsMDD12V+0cGZ9R+Csa12XzX5FdhPMD4NHICaMICc3WZCjxp0JniGEwaVd9EDWdYm1bL n7khKCafhGkajpb+SRSAid4qpGEMDjTvG87uFuFurAnEsSMtt4U5fn3X1DWEjg0tgWBDQZBq+C /oU= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:00 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyr1DQZz1SVp4 for ; Thu, 17 Feb 2022 19:15:00 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154099; x=1647746100; bh=tEJfk/UE9FOASU+9Jh mgRQlEK/ajrA/oKGoTSJqp5mA=; b=pQIcucPTpR8vq2xatQjLrqot45zdFlsbW6 a9rUBxmHB+XfrJ5xVyt0eIX6qMLREKw7Auzf1RGmaFKj6W5AUKMFvUnk6+R82Tr1 fXBOPhUrerJRg9JIPcq4DqGQvGDB8sMJmj+XI72zyp33Ckpk9o82qaOfTP8WWZRZ uB3nL16o7eVPdYekW+sMTK7z5anC7xEp2pkzdtqz6H2FiNGICqwlvP58JHSH29lL KtuUh/ATGlSWXnJpOT7p0ORBybi//IrtwsE77GQw1TDHnngjB357mnWKgV88dQWR d0QRppEyD3FnMLf2PR7nuGQr7fHp7jCZ9tAEKvN50HJgTiHuyOVw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id oEwY-UP1fVhb for ; Thu, 17 Feb 2022 19:14:59 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyp35tyz1Rwrw; Thu, 17 Feb 2022 19:14:58 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 08/31] scsi: pm8001: Fix le32 values handling in pm80xx_set_sas_protocol_timer_config() Date: Fri, 18 Feb 2022 12:14:22 +0900 Message-Id: <20220218031445.548767-9-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org All fields of the SASProtocolTimerConfig structure have the __le32 type. As such, use cpu_to_le32() to initialize them. This change suppresses many sparse warnings: warning: incorrect type in assignment (different base types) expected restricted __le32 [addressable] [usertype] pageCode got int Note that the check to limit the value of the STP_IDLE_TMO field is removed as this field is initialized using the fixed (and small) value defined by the STP_IDLE_TIME macro. The pm8001_dbg() calls printing the values of the SASProtocolTimerConfig structure fileds are changed to use le32_to_cpu() to present the values in human readable form. Fixes: a6cb3d012b98 ("[SCSI] pm80xx: thermal, sas controller config and error handling update") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 52 +++++++++++++++----------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index b303bc347f3d..e6fb89138030 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1245,43 +1245,41 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); - SASConfigPage.pageCode = SAS_PROTOCOL_TIMER_CONFIG_PAGE; - SASConfigPage.MST_MSI = 3 << 15; - SASConfigPage.STP_SSP_MCT_TMO = (STP_MCT_TMO << 16) | SSP_MCT_TMO; - SASConfigPage.STP_FRM_TMO = (SAS_MAX_OPEN_TIME << 24) | - (SMP_MAX_CONN_TIMER << 16) | STP_FRM_TIMER; - SASConfigPage.STP_IDLE_TMO = STP_IDLE_TIME; - - if (SASConfigPage.STP_IDLE_TMO > 0x3FFFFFF) - SASConfigPage.STP_IDLE_TMO = 0x3FFFFFF; - - - SASConfigPage.OPNRJT_RTRY_INTVL = (SAS_MFD << 16) | - SAS_OPNRJT_RTRY_INTVL; - SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = (SAS_DOPNRJT_RTRY_TMO << 16) - | SAS_COPNRJT_RTRY_TMO; - SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = (SAS_DOPNRJT_RTRY_THR << 16) - | SAS_COPNRJT_RTRY_THR; - SASConfigPage.MAX_AIP = SAS_MAX_AIP; + SASConfigPage.pageCode = cpu_to_le32(SAS_PROTOCOL_TIMER_CONFIG_PAGE); + SASConfigPage.MST_MSI = cpu_to_le32(3 << 15); + SASConfigPage.STP_SSP_MCT_TMO = + cpu_to_le32((STP_MCT_TMO << 16) | SSP_MCT_TMO); + SASConfigPage.STP_FRM_TMO = + cpu_to_le32((SAS_MAX_OPEN_TIME << 24) | + (SMP_MAX_CONN_TIMER << 16) | STP_FRM_TIMER); + SASConfigPage.STP_IDLE_TMO = cpu_to_le32(STP_IDLE_TIME); + + SASConfigPage.OPNRJT_RTRY_INTVL = + cpu_to_le32((SAS_MFD << 16) | SAS_OPNRJT_RTRY_INTVL); + SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = + cpu_to_le32((SAS_DOPNRJT_RTRY_TMO << 16) | SAS_COPNRJT_RTRY_TMO); + SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = + cpu_to_le32((SAS_DOPNRJT_RTRY_THR << 16) | SAS_COPNRJT_RTRY_THR); + SASConfigPage.MAX_AIP = cpu_to_le32(SAS_MAX_AIP); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.pageCode 0x%08x\n", - SASConfigPage.pageCode); + le32_to_cpu(SASConfigPage.pageCode)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.MST_MSI 0x%08x\n", - SASConfigPage.MST_MSI); + le32_to_cpu(SASConfigPage.MST_MSI)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_SSP_MCT_TMO 0x%08x\n", - SASConfigPage.STP_SSP_MCT_TMO); + le32_to_cpu(SASConfigPage.STP_SSP_MCT_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_FRM_TMO 0x%08x\n", - SASConfigPage.STP_FRM_TMO); + le32_to_cpu(SASConfigPage.STP_FRM_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_IDLE_TMO 0x%08x\n", - SASConfigPage.STP_IDLE_TMO); + le32_to_cpu(SASConfigPage.STP_IDLE_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.OPNRJT_RTRY_INTVL 0x%08x\n", - SASConfigPage.OPNRJT_RTRY_INTVL); + le32_to_cpu(SASConfigPage.OPNRJT_RTRY_INTVL)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO 0x%08x\n", - SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO); + le32_to_cpu(SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR 0x%08x\n", - SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR); + le32_to_cpu(SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.MAX_AIP 0x%08x\n", - SASConfigPage.MAX_AIP); + le32_to_cpu(SASConfigPage.MAX_AIP)); memcpy(&payload.cfg_pg, &SASConfigPage, sizeof(SASProtocolTimerConfig_t)); From patchwork Fri Feb 18 03:14:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D9F0C433F5 for ; Fri, 18 Feb 2022 03:15:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231886AbiBRDPX (ORCPT ); Thu, 17 Feb 2022 22:15:23 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:56392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbiBRDPT (ORCPT ); Thu, 17 Feb 2022 22:15:19 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E6CA120F7A for ; Thu, 17 Feb 2022 19:15:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154101; x=1676690101; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PplX+kDNXdsQ5HZh8arIKafLu+DD+Al5/ujtqhFFtf0=; b=ihq3jYrY/AOWAAP52BvSZvF5W1Ed40gmqI0Ie14tgQ5YdbDk7ZMvh0bI RZxNbZ065JQAS5F4j+Gk6CKjapCO5icwoen0rnqNswONKRqEwdsSOrDIL MLOHMvtMtgOVrSb+uli+OmAVwp0X4xzfq5dn9amgDhwOh2NUUIvT0KAs1 xyJoWwHVo8gM5+Wbi8y/PLXQ8SCwDf5VHMw6urlywRcPFDVy+UAZ9UNTr 5qWc6z5LGNK2ho8WdL9xtc3wBiEsc6OUEnd4zme15IolkMLcPXFZhMmPj uPuHZn9syPfhe74Q7fNMTmbHCtSr/Qfgld+QjmDrIHGB8d2r7PealhqE/ Q==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225754" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:01 +0800 IronPort-SDR: /y2mT2jbQVGq6PPEMXREL/CzdFXecCxuPySTecrvKhth5QwMhV6kH8utChbF6Iu6+Lq2tD/3kB G0PZ6mYIWlnSOyqCa7Rk6vxxY+JsnG8aNvs/+H+PD0tYbeT3aBlwge6x493+hrwOn/BLIE5B3l HLn4D9KidYjaFN04WUR8iQvr1Kv9pGZmbZtht6Q2LQKPWACGPdYUJcm7FckeHZPMUqZniw435f CapvL37oEooM5ApOhTig6eCQcrTF62fi6gyHpvM69SHjnUKjfUmxAY84udW22bGcBGCA5YtcIh 4EIOfq1OWv4aNp9zugilMpZo Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:39 -0800 IronPort-SDR: yR+D3La8fum/V0O1mCOU0Aem0kdDpASUMFllyHmNfU/+DOEGjxEpfWoUP9mA6ZOCVHUw8DhXIW /3POTAy7JC9SWxZhT5jOFx83meywuBgovuKMSmYQurwVmd9W0xkWeyEMrmB66eMSYHRIYM8I7I 7Xs7hBHxly+3JWc7/UcRxT9tqvv0bK6H5Z+Y91xc+HLn19RuKtOfZ/hzz2N/2V/r4AVPL/mN7D ILa4VYS/H2Kt/0U2HtTxJHh8d30bPVbB4GFTE0xlDeuuQh1Vqdgst9DU9C8m5mUfYEqxG4o/CT mXg= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:01 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gys1jZhz1SVp0 for ; Thu, 17 Feb 2022 19:15:01 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154100; x=1647746101; bh=PplX+kDNXdsQ5HZh8a rIKafLu+DD+Al5/ujtqhFFtf0=; b=mmEz+2fj+4MA3pe99yPeOzCNRviSRFbSxt KuY6n1RIW/L0qFe1HB0h1sp6D2U6pELijzoOzXnAN2MTjgjLS1tiot8npFKjaBDk jpZMLtCBVkcFa2OmgGiQzTJMMQkDx7qlTc+2Myvj8m2Ipl+DXYJJG1Hj9iGL7TDK fmIHOZrpeCgwZS8a3qPq2H0G0jWm3iGvypcj0DaKNJ0fci2FOg9tHVQmUgIKWD3k bhTVekZcgZeRIQTsNaFavDQ3JcBaWEAX1E0WvGZB2PD5Imh4qu2atrj4cvkqkk71 iOsv5MNUPQpL8jC8eVC79iOBW/Atd7uVN53HnCbuMstbzVYVpyFw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id L8MkZV8DzjiP for ; Thu, 17 Feb 2022 19:15:00 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyq5Pxcz1SHwl; Thu, 17 Feb 2022 19:14:59 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 09/31] scsi: pm8001: Fix payload initialization in pm80xx_encrypt_update() Date: Fri, 18 Feb 2022 12:14:23 +0900 Message-Id: <20220218031445.548767-10-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org All fields of the kek_mgmt_req structure have the type __le32. So make sure to use cpu_to_le32() to initialize them. This suppresses the sparse warning: warning: incorrect type in assignment (different base types) expected restricted __le32 [addressable] [assigned] [usertype] new_curidx_ksop got int Fixes: 5860992db55c ("[SCSI] pm80xx: Added SPCv/ve specific hardware functionalities and relevant changes in common files") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index e6fb89138030..b06d5ded45ca 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1405,12 +1405,13 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) /* Currently only one key is used. New KEK index is 1. * Current KEK index is 1. Store KEK to NVRAM is 1. */ - payload.new_curidx_ksop = ((1 << 24) | (1 << 16) | (1 << 8) | - KEK_MGMT_SUBOP_KEYCARDUPDATE); + payload.new_curidx_ksop = + cpu_to_le32(((1 << 24) | (1 << 16) | (1 << 8) | + KEK_MGMT_SUBOP_KEYCARDUPDATE)); pm8001_dbg(pm8001_ha, DEV, "Saving Encryption info to flash. payload 0x%x\n", - payload.new_curidx_ksop); + le32_to_cpu(payload.new_curidx_ksop)); rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); From patchwork Fri Feb 18 03:14:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DE7FC433FE for ; Fri, 18 Feb 2022 03:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231890AbiBRDPY (ORCPT ); Thu, 17 Feb 2022 22:15:24 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:56422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231887AbiBRDPT (ORCPT ); Thu, 17 Feb 2022 22:15:19 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 568FC1662CA for ; Thu, 17 Feb 2022 19:15:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154103; x=1676690103; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NznwQIrXtOr3EbXJhwYPD9nDQOPGAk8nVW66eSLouuE=; b=PoaDIv79w9EqRO25AEs7NJfcCz4F4vUFe3vC3zsEfcThgAfbTIv4RO9q rA4kQoOhI6e28DfLjy+Qhq6MjrxHmjJWrMVRX298KMsHdCW7pRKO4B9/V +lHC0SLsF9F4fPNwC9lNXEz1unW2CVBQQiIvLj3BbV9+UqoCyVL/BwbsQ iNo3h2HpwCnO8GEFZyr00N3Go2G/FajE8X6lBPH4Y5aYILXGYV/mxAbH6 qILsZIeNiwlJoHkBvaaBku8Mdgk0YNuCGL2zmn9jR7tAAd1sNVXkQ2tAH veU7Djj7ww9wxPeCHk1rNHNJSUopB2qDFt65mYg5CSBJhteOGnPFSH1v7 A==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225763" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:03 +0800 IronPort-SDR: n5PACeQtDU1lLGPc0Gz4jjcpmk5C0HghjJ5HaCtGD5zbnfXzHTTxNspNvCmNlC15vBFUErV65U xGdfIUsni3sg53ggl7sWZr8imjQPGeYE8oiatt70egSuNUOFf03UMDUNFt0vqQmkumXcg0BPC0 +RvABoVibVrc2NfJWLCsdBGAf5RmZhzUcQSgaIBaV3A242mYYxd6jn6j5n3i8h9+7eftg+NHK2 Lov0mEhQ3x6ezF7yNzBXrWADDDzX0oXS8cpbm+yXkrmBzMPSXiXMN9fhRNAhunQAJ1aX38wdjx KKX+UQDtiY677liMb09BRBvC Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:41 -0800 IronPort-SDR: ka5WLgYvpoq7EOqEGKq2sLtnMF8HR69farN7HrE4D2/XmPPHj5HOxfPWaPvw9rHha4+QrV+7oC tR68FYZEZZrOK3zKdJ1FoZHJsDYNS9woGS0jxKKqxTgOicJrORXBASO/MDNih9b2Xa2exKynHi kT0NlpdgP+NyDY2/rd4DJ5eJr6f19YgY9DlUl50+diqCd97THquRoyNu/yMjBq6kTyL3U2xqXf TqP6mDoHqW2dJVHP2qSA1tGrbbWWOEpm60wbK2A+qUd1KaZSj4xTEGz4kc51fjgwAU9S0sI8TW vJM= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:03 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyv01ztz1SVp2 for ; Thu, 17 Feb 2022 19:15:02 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154102; x=1647746103; bh=NznwQIrXtOr3EbXJhw YPD9nDQOPGAk8nVW66eSLouuE=; b=Nj2PZNaBc6ao1YnEAao75tuccVKcSPwlvz Qyx5W2mz0NkCzGhD05KVfIX1plkf1fpwJ+FP9+01G0XbhvLwIWdKkHmaGOmwzoIg NrS84doOFz+LE7k+PI/ewKPHsFgJOEI8qAg+e7WCRB/ndUERE/mgmA+iXOyZuWTT uTiQvW4U3eo5dgDpqw2yp2rBp0RKLVAHFNNCHZZOZ2CPS10aQbWTwQuwB4HdYxQA 8ig1CQidjlszuATn/XdoNrpnA4cpMvGeiEQ5KDZinoMlu5U75QeMHhhtJQAc5/6g +M4lriV560Mi6nH4kftnAY0ofCNQvbDD51Kr9dgO3kvFdqMqgBBg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id eUsv3cmkbdFh for ; Thu, 17 Feb 2022 19:15:02 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gys1T7Vz1SVnx; Thu, 17 Feb 2022 19:15:00 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 10/31] scsi: pm8001: Fix le32 values handling in pm80xx_chip_ssp_io_req() Date: Fri, 18 Feb 2022 12:14:24 +0900 Message-Id: <20220218031445.548767-11-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make sure that the __le32 fields of struct ssp_ini_io_start_req are manipulated after applying the correct endian conversion. That is, use cpu_to_le32() for assigning values and le32_to_cpu() for consulting a field value. In particular, make sure that the calculations for the 4G boundary check are done using CPU endianness and *not* little endian values. With these fixes, many sparse warnings are removed. While at it, add blank lines after variable declarations and in some other places to make this code more readable. Fixes: 0ecdf00ba6e5 ("[SCSI] pm80xx: 4G boundary fix.") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 41 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index b06d5ded45ca..130747b5a70a 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4374,13 +4374,15 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, struct ssp_ini_io_start_req ssp_cmd; u32 tag = ccb->ccb_tag; int ret; - u64 phys_addr, start_addr, end_addr; + u64 phys_addr, end_addr; u32 end_addr_high, end_addr_low; struct inbound_queue_table *circularQ; u32 q_index, cpu_id; u32 opc = OPC_INB_SSPINIIOSTART; + memset(&ssp_cmd, 0, sizeof(ssp_cmd)); memcpy(ssp_cmd.ssp_iu.lun, task->ssp_task.LUN, 8); + /* data address domain added for spcv; set to 0 by host, * used internally by controller * 0 for SAS 1.1 and SAS 2.0 compatible TLR @@ -4391,7 +4393,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.device_id = cpu_to_le32(pm8001_dev->device_id); ssp_cmd.tag = cpu_to_le32(tag); if (task->ssp_task.enable_first_burst) - ssp_cmd.ssp_iu.efb_prio_attr |= 0x80; + ssp_cmd.ssp_iu.efb_prio_attr = 0x80; ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_prio << 3); ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7); memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cmd->cmnd, @@ -4423,21 +4425,24 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.enc_esgl = cpu_to_le32(1<<31); } else if (task->num_scatter == 1) { u64 dma_addr = sg_dma_address(task->scatter); + ssp_cmd.enc_addr_low = cpu_to_le32(lower_32_bits(dma_addr)); ssp_cmd.enc_addr_high = cpu_to_le32(upper_32_bits(dma_addr)); ssp_cmd.enc_len = cpu_to_le32(task->total_xfer_len); ssp_cmd.enc_esgl = 0; + /* Check 4G Boundary */ - start_addr = cpu_to_le64(dma_addr); - end_addr = (start_addr + ssp_cmd.enc_len) - 1; - end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); - end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); - if (end_addr_high != ssp_cmd.enc_addr_high) { + end_addr = dma_addr + le32_to_cpu(ssp_cmd.enc_len) - 1; + end_addr_low = lower_32_bits(end_addr); + end_addr_high = upper_32_bits(end_addr); + + if (end_addr_high != le32_to_cpu(ssp_cmd.enc_addr_high)) { pm8001_dbg(pm8001_ha, FAIL, "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", - start_addr, ssp_cmd.enc_len, + dma_addr, + le32_to_cpu(ssp_cmd.enc_len), end_addr_high, end_addr_low); pm8001_chip_make_sg(task->scatter, 1, ccb->buf_prd); @@ -4446,7 +4451,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, cpu_to_le32(lower_32_bits(phys_addr)); ssp_cmd.enc_addr_high = cpu_to_le32(upper_32_bits(phys_addr)); - ssp_cmd.enc_esgl = cpu_to_le32(1<<31); + ssp_cmd.enc_esgl = cpu_to_le32(1U<<31); } } else if (task->num_scatter == 0) { ssp_cmd.enc_addr_low = 0; @@ -4454,8 +4459,10 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.enc_len = cpu_to_le32(task->total_xfer_len); ssp_cmd.enc_esgl = 0; } + /* XTS mode. All other fields are 0 */ - ssp_cmd.key_cmode = 0x6 << 4; + ssp_cmd.key_cmode = cpu_to_le32(0x6 << 4); + /* set tweak values. Should be the start lba */ ssp_cmd.twk_val0 = cpu_to_le32((task->ssp_task.cmd->cmnd[2] << 24) | (task->ssp_task.cmd->cmnd[3] << 16) | @@ -4477,20 +4484,22 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.esgl = cpu_to_le32(1<<31); } else if (task->num_scatter == 1) { u64 dma_addr = sg_dma_address(task->scatter); + ssp_cmd.addr_low = cpu_to_le32(lower_32_bits(dma_addr)); ssp_cmd.addr_high = cpu_to_le32(upper_32_bits(dma_addr)); ssp_cmd.len = cpu_to_le32(task->total_xfer_len); ssp_cmd.esgl = 0; + /* Check 4G Boundary */ - start_addr = cpu_to_le64(dma_addr); - end_addr = (start_addr + ssp_cmd.len) - 1; - end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); - end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); - if (end_addr_high != ssp_cmd.addr_high) { + end_addr = dma_addr + le32_to_cpu(ssp_cmd.len) - 1; + end_addr_low = lower_32_bits(end_addr); + end_addr_high = upper_32_bits(end_addr); + if (end_addr_high != le32_to_cpu(ssp_cmd.addr_high)) { pm8001_dbg(pm8001_ha, FAIL, "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", - start_addr, ssp_cmd.len, + dma_addr, + le32_to_cpu(ssp_cmd.len), end_addr_high, end_addr_low); pm8001_chip_make_sg(task->scatter, 1, ccb->buf_prd); From patchwork Fri Feb 18 03:14:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A8DDC433EF for ; Fri, 18 Feb 2022 03:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231896AbiBRDP0 (ORCPT ); Thu, 17 Feb 2022 22:15:26 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:56520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231880AbiBRDPU (ORCPT ); Thu, 17 Feb 2022 22:15:20 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B8EEF1EB1 for ; Thu, 17 Feb 2022 19:15:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154105; x=1676690105; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RWs2sw36i5zBmGZYuC/mk8fWJ3x6aeqwKl3ALeic7R0=; b=m/W5sUlS/6qostkuNxLXoTyhTXOPhOyXBXgoKED1lxszBERPHVGO2L08 STbegJUmjNts/9d4zyxmcjqIB1hNutXt/oTRcM94rkMJF2MUcISl4CXt8 b7JrCad+F2pGdXAFePH/nTR6lzMDsFIaOHtxwCICdpBT97n1vimxnjRpn CzfOuUx2WMpzh5oXUQwSudWLj6l0a5ZmJZvjETQupwDOHZCPsvyauP5Tz X1MEbJlocho8nryU7oaqGmHnjj18tuR/QKLQXYKIwBG+zkpxFnPrtGMJD Lnoz2Qy/czk3vpGVbp9tjfIc4HVUlUJw4niJTYDqqtc/pf2UaZqF6aMUz g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225768" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:05 +0800 IronPort-SDR: 5oIuASUttvkwEMpQP2qXG4x2QITJpKHjvZAVRYUtcymEqhq/WB6567BcdCdzGLj+0VGsUYNE3D 2MUiRgEGv+s9WrGASUoRTB8gpVXacgandSYi1T8vuKkOk3JruYc2TUsNxaRhuzBffcTNQ2X6xN bscneYyimzwqAAnAPmEvqf4uyPTN9JYP7b0nU0mp7uLlswbxi7zjJU2h3jQcIpeP3YcwxVyxbO gCCh456NvQEYkvKi93P2G6FPHqSMJzdCsao6mNejOeB6kj0LRl+2R+VpIQspumuIE6fUSbhgnO Y/us25Ahuyp3nQqoKouxmdna Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:42 -0800 IronPort-SDR: QtHf2jGwqtDCL/ai8ncMO55dGIHnsC4HHyjrcLzhQs0gQOoqIHggJu5j0ZI43jitQrWbmZpQB5 BBs62YUgLXCjjFoKxTbeAU/my8HIQmAtXUiATIhKwXanvUiMZ5jOZV2HiirAoyJSECuPOI2ke+ W8SLvVsfLmzO05qHy1VhKdy3NvAltolHdMunXWu7Pg2lVtpiMfS1e6Sh8grqnNQMQvEUU7vrPw eNjR4ukC1tvS+ngzLMrvvz17vGfpvVCcxoeYQI5PF+iIw0ZIa3Oi64XCJEBpWTkzgTOGFPlOm8 TlM= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:05 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyw4n3qz1SVp5 for ; Thu, 17 Feb 2022 19:15:04 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154103; x=1647746104; bh=RWs2sw36i5zBmGZYuC /mk8fWJ3x6aeqwKl3ALeic7R0=; b=M4J/r8ByyMBkI1eKx4FRQKoRUYUUZFjlIX VLNKgk4a4n+8Qp73MH/cINGq6NqVSUIK5hbg1tgY651HtIfvBUygQjqs9Yx+v3C+ WaZwmog3zwPkDEbjgEY0GZJ36p2VWaKaZN3VWlGVns1ZZVhPSc1bk5JWhlL+1vMQ LEYXU+BVZTJNN4kbJ2+yirUrurVeO/NbNcaAu+0fkjI+9A2sEaP2UMmLgwBrm3/2 Wlj7GXhnel2juLwBwxEgOHTVdanpMj7p4ESBnKIti7adEXZPaYPF4udmJi/XYjO8 NJPmU+MP4GTIzR3AaBlkBHqAVwGFqS9uI5sU2IJIz8gpO3tjOtxg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id koeEFeRNA9Zv for ; Thu, 17 Feb 2022 19:15:03 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyt4SCPz1Rwrw; Thu, 17 Feb 2022 19:15:02 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 11/31] scsi: pm8001: Fix le32 values handling in pm80xx_chip_sata_req() Date: Fri, 18 Feb 2022 12:14:25 +0900 Message-Id: <20220218031445.548767-12-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make sure that the __le32 fields of struct sata_cmd are manipulated after applying the correct endian conversion. That is, use cpu_to_le32() for assigning values and le32_to_cpu() for consulting a field value. In particular, make sure that the calculations for the 4G boundary check are done using CPU endianness and *not* little endian values. With these fixes, many sparse warnings are removed. While at it, fix some code identation and add blank lines after variable declarations and in some other places to make this code more readable. Fixes: 0ecdf00ba6e5 ("[SCSI] pm80xx: 4G boundary fix.") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 82 ++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 130747b5a70a..1f3b01c70f24 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4534,7 +4534,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, u32 q_index, cpu_id; struct sata_start_req sata_cmd; u32 hdr_tag, ncg_tag = 0; - u64 phys_addr, start_addr, end_addr; + u64 phys_addr, end_addr; u32 end_addr_high, end_addr_low; u32 ATAP = 0x0; u32 dir; @@ -4595,32 +4595,38 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, pm8001_chip_make_sg(task->scatter, ccb->n_elem, ccb->buf_prd); phys_addr = ccb->ccb_dma_handle; - sata_cmd.enc_addr_low = lower_32_bits(phys_addr); - sata_cmd.enc_addr_high = upper_32_bits(phys_addr); + sata_cmd.enc_addr_low = + cpu_to_le32(lower_32_bits(phys_addr)); + sata_cmd.enc_addr_high = + cpu_to_le32(upper_32_bits(phys_addr)); sata_cmd.enc_esgl = cpu_to_le32(1 << 31); } else if (task->num_scatter == 1) { u64 dma_addr = sg_dma_address(task->scatter); - sata_cmd.enc_addr_low = lower_32_bits(dma_addr); - sata_cmd.enc_addr_high = upper_32_bits(dma_addr); + + sata_cmd.enc_addr_low = + cpu_to_le32(lower_32_bits(dma_addr)); + sata_cmd.enc_addr_high = + cpu_to_le32(upper_32_bits(dma_addr)); sata_cmd.enc_len = cpu_to_le32(task->total_xfer_len); sata_cmd.enc_esgl = 0; + /* Check 4G Boundary */ - start_addr = cpu_to_le64(dma_addr); - end_addr = (start_addr + sata_cmd.enc_len) - 1; - end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); - end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); - if (end_addr_high != sata_cmd.enc_addr_high) { + end_addr = dma_addr + le32_to_cpu(sata_cmd.enc_len) - 1; + end_addr_low = lower_32_bits(end_addr); + end_addr_high = upper_32_bits(end_addr); + if (end_addr_high != le32_to_cpu(sata_cmd.enc_addr_high)) { pm8001_dbg(pm8001_ha, FAIL, "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", - start_addr, sata_cmd.enc_len, + dma_addr, + le32_to_cpu(sata_cmd.enc_len), end_addr_high, end_addr_low); pm8001_chip_make_sg(task->scatter, 1, ccb->buf_prd); phys_addr = ccb->ccb_dma_handle; sata_cmd.enc_addr_low = - lower_32_bits(phys_addr); + cpu_to_le32(lower_32_bits(phys_addr)); sata_cmd.enc_addr_high = - upper_32_bits(phys_addr); + cpu_to_le32(upper_32_bits(phys_addr)); sata_cmd.enc_esgl = cpu_to_le32(1 << 31); } @@ -4631,7 +4637,8 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, sata_cmd.enc_esgl = 0; } /* XTS mode. All other fields are 0 */ - sata_cmd.key_index_mode = 0x6 << 4; + sata_cmd.key_index_mode = cpu_to_le32(0x6 << 4); + /* set tweak values. Should be the start lba */ sata_cmd.twk_val0 = cpu_to_le32((sata_cmd.sata_fis.lbal_exp << 24) | @@ -4657,31 +4664,31 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, phys_addr = ccb->ccb_dma_handle; sata_cmd.addr_low = lower_32_bits(phys_addr); sata_cmd.addr_high = upper_32_bits(phys_addr); - sata_cmd.esgl = cpu_to_le32(1 << 31); + sata_cmd.esgl = cpu_to_le32(1U << 31); } else if (task->num_scatter == 1) { u64 dma_addr = sg_dma_address(task->scatter); + sata_cmd.addr_low = lower_32_bits(dma_addr); sata_cmd.addr_high = upper_32_bits(dma_addr); sata_cmd.len = cpu_to_le32(task->total_xfer_len); sata_cmd.esgl = 0; + /* Check 4G Boundary */ - start_addr = cpu_to_le64(dma_addr); - end_addr = (start_addr + sata_cmd.len) - 1; - end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); - end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); + end_addr = dma_addr + le32_to_cpu(sata_cmd.len) - 1; + end_addr_low = lower_32_bits(end_addr); + end_addr_high = upper_32_bits(end_addr); if (end_addr_high != sata_cmd.addr_high) { pm8001_dbg(pm8001_ha, FAIL, "The sg list address start_addr=0x%016llx data_len=0x%xend_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", - start_addr, sata_cmd.len, + dma_addr, + le32_to_cpu(sata_cmd.len), end_addr_high, end_addr_low); pm8001_chip_make_sg(task->scatter, 1, ccb->buf_prd); phys_addr = ccb->ccb_dma_handle; - sata_cmd.addr_low = - lower_32_bits(phys_addr); - sata_cmd.addr_high = - upper_32_bits(phys_addr); - sata_cmd.esgl = cpu_to_le32(1 << 31); + sata_cmd.addr_low = lower_32_bits(phys_addr); + sata_cmd.addr_high = upper_32_bits(phys_addr); + sata_cmd.esgl = cpu_to_le32(1U << 31); } } else if (task->num_scatter == 0) { sata_cmd.addr_low = 0; @@ -4689,27 +4696,28 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, sata_cmd.len = cpu_to_le32(task->total_xfer_len); sata_cmd.esgl = 0; } + /* scsi cdb */ sata_cmd.atapi_scsi_cdb[0] = cpu_to_le32(((task->ata_task.atapi_packet[0]) | - (task->ata_task.atapi_packet[1] << 8) | - (task->ata_task.atapi_packet[2] << 16) | - (task->ata_task.atapi_packet[3] << 24))); + (task->ata_task.atapi_packet[1] << 8) | + (task->ata_task.atapi_packet[2] << 16) | + (task->ata_task.atapi_packet[3] << 24))); sata_cmd.atapi_scsi_cdb[1] = cpu_to_le32(((task->ata_task.atapi_packet[4]) | - (task->ata_task.atapi_packet[5] << 8) | - (task->ata_task.atapi_packet[6] << 16) | - (task->ata_task.atapi_packet[7] << 24))); + (task->ata_task.atapi_packet[5] << 8) | + (task->ata_task.atapi_packet[6] << 16) | + (task->ata_task.atapi_packet[7] << 24))); sata_cmd.atapi_scsi_cdb[2] = cpu_to_le32(((task->ata_task.atapi_packet[8]) | - (task->ata_task.atapi_packet[9] << 8) | - (task->ata_task.atapi_packet[10] << 16) | - (task->ata_task.atapi_packet[11] << 24))); + (task->ata_task.atapi_packet[9] << 8) | + (task->ata_task.atapi_packet[10] << 16) | + (task->ata_task.atapi_packet[11] << 24))); sata_cmd.atapi_scsi_cdb[3] = cpu_to_le32(((task->ata_task.atapi_packet[12]) | - (task->ata_task.atapi_packet[13] << 8) | - (task->ata_task.atapi_packet[14] << 16) | - (task->ata_task.atapi_packet[15] << 24))); + (task->ata_task.atapi_packet[13] << 8) | + (task->ata_task.atapi_packet[14] << 16) | + (task->ata_task.atapi_packet[15] << 24))); } /* Check for read log for failed drive and return */ From patchwork Fri Feb 18 03:14:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 006B9C433FE for ; Fri, 18 Feb 2022 03:15:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231901AbiBRDP1 (ORCPT ); Thu, 17 Feb 2022 22:15:27 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:56588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231875AbiBRDPV (ORCPT ); Thu, 17 Feb 2022 22:15:21 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E3B2120F7A for ; Thu, 17 Feb 2022 19:15:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154106; x=1676690106; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lVB2sM0qCfqo8mvvo1uohffxKjaC+Yh2JveklQXFsqs=; b=A1JBYECSNkKQeNiHniw2KGkcYGe3XWSaW5EIFwVLUz/kACoDVVqAqG9U tObm2FjyrImSQd8YErOpbGIcMiGs75/0uz3c5MC+PjhTnnpFFAWjTg8R0 jQv+u1I6FQsj7JQd5vxvlMEmDBvaf7Q6RA18FvGyoA3XzskL7xrpFMKux Bum4YG+GjjOdTqx1xdsxKbKQ0ZFnibEgpQRXDXuql379ZCaXJM2IRwHaQ 1gZW/MAoPRQOVFjaX68+ug0z4u79IexIQ1Kty/Os+e5nRADQfKnZlrJBG InuLRD9cMqaNwsPYt5AGI6fG8uOrFxG8BUKMhoNggM478hzBRYBl3VyAJ A==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225770" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:06 +0800 IronPort-SDR: 4oV6jlsRploWj+12OSHrOGa0zw8g7NSlO//FGohkYeJpd0G79e4egHRybyqMW4iw3MLd7vrjV+ ix6cYDQIUHEqMpnAlV3whp+qw7bRaltRAdCikW0CJbnNjPpbicLvGNkhSsLmQrdwE+QsfIEpYy e5wKiGn40K9gMl2u5JZn57DqpU9uoHXRH8ubc4EhU6YxwHgpI2dT2tOEgebbZ7cXqh+e9bYvgV 2NcrTKL2bfbwv0osok/p3VHzxSseNwm9SsvahXbGW5AuZPa1wqHaRG0P4bN1nnCSj3I71Yb96E 5vKjH6pknici7Ehnid1NnovC Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:44 -0800 IronPort-SDR: z4QY46s2eisiK97TwRG4934x1gOG90Uo78m6xrXsxplVK0yCfYEZLQoSAHqpHHUd06CBO3c6dN kGM5sa6xszBh2T3BlooNBa4jY/9IaqB5bbOUf707giotowy7vXJwJfqohl8WKIbgO5/gAE4JF4 RdVQnmY4mXxD6IYthfyTeqrO+KQUK9jjgWzed0HLiL8nfyKOYNLncRWXi7Rh8DQEC/KxtC4VD/ EoS1Bw8GMg1kmkbA8lQRk6vxwNuyKclE6ImoMFHuF1iBptYNkjS3kdZ6JmYEJNnjEWI3Wq7AbF 07I= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:06 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyx5ZZfz1SVp2 for ; Thu, 17 Feb 2022 19:15:05 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154105; x=1647746106; bh=lVB2sM0qCfqo8mvvo1 uohffxKjaC+Yh2JveklQXFsqs=; b=B3FkjmdTJS58RvMWLD73fXUSyaw7AXl618 V0zEMNsSVv+zKaffUkByC3zmEdVo7mZDFLS3vx4/FGvSQ05zyQ2FfBupO1dZAu1w nl/+Dk1asOvJtDWkGtL65ii0WBiXrQx1S3Rmduw28RhkQ5H8B6nqzFgeintTyjK+ yNnQ8QHNPyvJeY8LLF5hXoHe7RSWThVGNF3x5Ya8CKeGG7ird39sBzoELnRWdt2V +ZqbsI7Jiu/aK533cg9dOi5b5dtfAeek6rgBh9yeyOJr1E00hPR+TJUhxNGWCwSM xgnKCF3IJAAyX02+rCICAj/WI8UYo1TdKvIseaOs/PsX2MILre2g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wa7UjYzhOVSt for ; Thu, 17 Feb 2022 19:15:05 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyw0jBDz1SHwl; Thu, 17 Feb 2022 19:15:03 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 12/31] scsi: pm8001: Fix use of struct set_phy_profile_req fields Date: Fri, 18 Feb 2022 12:14:26 +0900 Message-Id: <20220218031445.548767-13-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In mpi_set_phy_profile_req() and pm8001_set_phy_profile_single(), use cpu_to_le32() to initialize the ppc_phyid field of struct set_phy_profile_req. Furthermore, fix the definition of the reserved field of this structure to be an array of __le32, to match the use of cpu_to_le32() when assigning values. These changes remove several sparse type warnings. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 12 +++++++----- drivers/scsi/pm8001/pm80xx_hwi.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 1f3b01c70f24..60c305f987b5 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4970,12 +4970,13 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, pm8001_dbg(pm8001_ha, FAIL, "Invalid tag\n"); circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); - payload.ppc_phyid = (((operation & 0xF) << 8) | (phyid & 0xFF)); + payload.ppc_phyid = + cpu_to_le32(((operation & 0xF) << 8) | (phyid & 0xFF)); pm8001_dbg(pm8001_ha, INIT, " phy profile command for phy %x ,length is %d\n", - payload.ppc_phyid, length); + le32_to_cpu(payload.ppc_phyid), length); for (i = length; i < (length + PHY_DWORD_LENGTH - 1); i++) { - payload.reserved[j] = cpu_to_le32(*((u32 *)buf + i)); + payload.reserved[j] = cpu_to_le32(*((u32 *)buf + i)); j++; } rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, @@ -5015,8 +5016,9 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, opc = OPC_INB_SET_PHY_PROFILE; payload.tag = cpu_to_le32(tag); - payload.ppc_phyid = (((SAS_PHY_ANALOG_SETTINGS_PAGE & 0xF) << 8) - | (phy & 0xFF)); + payload.ppc_phyid = + cpu_to_le32(((SAS_PHY_ANALOG_SETTINGS_PAGE & 0xF) << 8) + | (phy & 0xFF)); for (i = 0; i < length; i++) payload.reserved[i] = cpu_to_le32(*(buf + i)); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h index c41ed039c92a..d66b49323d49 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.h +++ b/drivers/scsi/pm8001/pm80xx_hwi.h @@ -972,7 +972,7 @@ struct dek_mgmt_req { struct set_phy_profile_req { __le32 tag; __le32 ppc_phyid; - u32 reserved[29]; + __le32 reserved[29]; } __attribute__((packed, aligned(4))); /** From patchwork Fri Feb 18 03:14:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38403C4332F for ; Fri, 18 Feb 2022 03:15:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbiBRDPu (ORCPT ); Thu, 17 Feb 2022 22:15:50 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:56684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231883AbiBRDPX (ORCPT ); Thu, 17 Feb 2022 22:15:23 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6616120F7A for ; Thu, 17 Feb 2022 19:15:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154108; x=1676690108; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g9DqTo9CfqOPxmAnqtDwRWIZjNs6xzEf/L8jfuXNUaI=; b=WRu+a8CvvChIUWDlFWqrHgA+6ybz0o+Ro8Hx7gYm8ax8S2m7bh3iXaWE m57vSOKRHd5sUC3h6Ye0zsJ/JCWLU9dzfC6hb/5SuWZQl/pA3bnj/2fia xMXOcdTnjiqyFeJMWzLM9WhRi5vcKEtSdL2c7JH2sIgvsXzzVvOCivW2N Y8P5L7eA7BRQ3his/8MlVifKrWIT1jthPgzvmu1Xwf+Hg0Bk5Obfm2JZt n33/TDi/osYMZ1X333BUTPEp4C9eY0jcMW2IaGPAmrFxXTFVtpQ48UP5r ba13w5MGwzxqoexeTMFaxGg19qiZ8bd8IqLv1iOvqQW9EoCq1DOm7ciDY w==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225774" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:07 +0800 IronPort-SDR: kV9D2AzlVHGvEYovzqMRyrumo71si0EJ+OvP0itlGgnTujlh5ylOoZtHu23Qb/i2Dg5uYDz3HY pMNp/5/drSGAEyPhAJQmFnvbN0zxr4xIP8P+Yxknlsk3DHZkJsRPfLFaJiVdScVsIS0qq2+XzQ ELTc8ICJV9r12iI85ZhLzjmT1oLXx9OMUzNDP2P+GHink6pnhKrw4U8/+ioWt+i7CTEoANJpI6 owYEkUffHHcab5sXW+SkszJBNtBexcannd0KU6al2PHfwyPPU7iYoSW964tITfit7ZR24R0kZ4 wH6XijzP29HRvdh32FtTEFm6 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:45 -0800 IronPort-SDR: MV79fSEVgBlSUUo6BCXuzeUfcRf02oY9KoncmpF5NhRiPYvT6LQWth3tyJ5S5pcKVSy6buuFOf hTSqJduBB/tnIqObxn51W3BW5zBhTBhCPjQmSfuIaj63Qd5AAvjktcSUoSl2UDGygW6gQKvO7J +Pt7ogcfKeCJSr9yvcFtcEGZSgKWgBZ5aXI2IDnrbh8919oatEBdO48/Ry6RfuQj61aJqrIghA l3Cpwgwl0dUavCJgCq0Dh8kO95n0FTD9ExIR0Ejy+23ydt2jqKdPXzbuOcA+f3qmNURB2WNi1l BbY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:07 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gyz0jBPz1SVp1 for ; Thu, 17 Feb 2022 19:15:07 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154106; x=1647746107; bh=g9DqTo9CfqOPxmAnqt DwRWIZjNs6xzEf/L8jfuXNUaI=; b=dj6Gecc8R/3UpPo1FtadUPPvFLkRJUXOSD YN7EIYdnbWblVpqfdW72E383TWgiX5u0EMipB1PUoe9v8lafx0h9aVDFmd6mm1E9 5IAvhZMmc25cPFeHsssxVLBRC9nMdyrT9l9a/n3H4yo+n7jmRoWc8LQ9ZrALM+yb PTbRxpFvP4za006fp8zaZ4rFiQNfZzo69njtEe1FJjI4gCdZf2/Ntwa7J8YbHr3G f1VNpk2cljEKRKQgSR+PzKehNTxJbe150MPhmesXEFdlP/913jr/5mlBYev0Q3lQ 48XTqvripf467tR9IL2fE3dBb5EDTK+cIZnN5T4vLtCJBhAVA0TA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Ck2_9fVXbWTr for ; Thu, 17 Feb 2022 19:15:06 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyx4J0Wz1Rwrw; Thu, 17 Feb 2022 19:15:05 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 13/31] scsi: pm8001: Remove local variable in pm8001_pci_resume() Date: Fri, 18 Feb 2022 12:14:27 +0900 Message-Id: <20220218031445.548767-14-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm8001_pci_resume(), the use of the u32 type for the local variable device_state causes a sparse warning: warning: incorrect type in assignment (different base types) expected unsigned int [usertype] device_state got restricted pci_power_t [usertype] current_state Since this variable is used only once in the function, remove it and use pdev->current_state directly. While at it, also add a blank line after the last local variable declaration. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index d8a2121cb8d9..4b9a26f008a9 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1335,13 +1335,13 @@ static int __maybe_unused pm8001_pci_resume(struct device *dev) struct pm8001_hba_info *pm8001_ha; int rc; u8 i = 0, j; - u32 device_state; DECLARE_COMPLETION_ONSTACK(completion); + pm8001_ha = sha->lldd_ha; - device_state = pdev->current_state; - pm8001_info(pm8001_ha, "pdev=0x%p, slot=%s, resuming from previous operating state [D%d]\n", - pdev, pm8001_ha->name, device_state); + pm8001_info(pm8001_ha, + "pdev=0x%p, slot=%s, resuming from previous operating state [D%d]\n", + pdev, pm8001_ha->name, pdev->current_state); rc = pci_go_44(pdev); if (rc) From patchwork Fri Feb 18 03:14:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69337C433F5 for ; Fri, 18 Feb 2022 03:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231967AbiBRDPs (ORCPT ); Thu, 17 Feb 2022 22:15:48 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:56880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbiBRDPZ (ORCPT ); Thu, 17 Feb 2022 22:15:25 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B0F312A757 for ; Thu, 17 Feb 2022 19:15:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154109; x=1676690109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cm4NHH8QFWFhsmZPJF6NC1uwQRhBpzoxbcq11J3AtIA=; b=YA+FllRDPXKlatBUdBJDR5ANiMju+rr44L5qO8pFS3JfNcVp1mXaPZdP HKU06gUTrP1RCFrd19ET6jWFJAyOsCsGMvjPqal5zWD52lkLozRtV7j26 MqHiuq1iE2kjwmdnt48Uxgi+qpcAcodUW2G1ixtuhcMtMjlUnHWqNSsSE IFvZGlNW8cIYKRCI7H7JJxEiyNzyiLRxXMyPH/ZKacUlwQ/O/ExUz7liV ZNLSkgR5lkCsIGr1gU59yUGrl5fpnJ/JSEZ4Iy7NCVYKNQio2qoLsMupD O2S/RDORbgiSFSZ52qDDRk1fbNz5YE3NFeXGjPZzeu30B4Bi4xTWlvvhF w==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225786" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:09 +0800 IronPort-SDR: a5vrXCqxYDrZkxRFaFGn+i0m1Q7C1n5V69PvKJJblVM3JEqAbEWzN9CGDhZI6ti9pQsBLeKdq3 U7/sChK9iSMXzgc/fyjWlgJ0AKPu9fwO4sajWJltZawfpAsHydsYuGDE5aVSl9iZXMI6Z9M4dl d80oDREjyGuYcApwCs+imlMmr8RYgoRlxKnc5vUAd8tndb30tL3opIZd8YNb7itKH5cD0cN6Ij /6tJK771Hz+uOduBhD060JCAJZhB4V1xDKtAbYbInEWCNYsoRS8ReFGDkAtFQpLKdblk4erZ7C TjWVLZc7Da8KUJG6Ake1uS7K Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:47 -0800 IronPort-SDR: 52XnIsdQKcrZjPUvMu9wmVcAuiloGk899sHjuH9tWI6fkWzre30MBge8RpucZihTbum6mae1Ia sOYZOs/QNayqaPjj8f1EyM/aBmDBlMtV+9qOMjlsdBM37tD0yMx9jjA23RDLQL7kTIe0+4I88c sUgGZOcced9S3OS5pvmNUK9jQx31n9mb3FxOZ3823zKhKtBZ4GdxNQDYt45TI+f4Ues3S1/3T+ TGKprAGTzfWl4thJCJFXeWRCMyWn0peF3niVND2+j6j7hyxDma/by5T99OCNsIyU041qxs1jWo vx8= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:09 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gz0531mz1SVp5 for ; Thu, 17 Feb 2022 19:15:08 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154108; x=1647746109; bh=Cm4NHH8QFWFhsmZPJF 6NC1uwQRhBpzoxbcq11J3AtIA=; b=DpGuEt2EvCNIpkShjp/yT7gdZUaXPTfVax 5zdphz5JXyJwGduxlU92Lrnu47tJotO/aeyktos4xPswOOiM7k9LdWAIwENXSv1u ELib4PeoQFWUynZLRyiTtyywozC2N/wHsO/q6Q90LmKEkwi8n/WK+gXJU9poQaRy hk2qrcVePWdubvkyIB6R3iP9MZxyRF/8zoooHo16CoGgjB1usGkY+lvlUFBMZxbf 2TQmOm0cfNL0ITuiSAwbLJNkpVXW+OI+oJQI6CHCv8spmhUJyH3ZKTXLO5lithST rBVRgIs9Hj1scEqXgnMl4Ach6LYdEH5e/mZSQplQcJEcUA0vjYsg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pGkhVEjWiueP for ; Thu, 17 Feb 2022 19:15:08 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gyy6ky3z1SHwl; Thu, 17 Feb 2022 19:15:06 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 14/31] scsi: pm8001: Fix NCQ NON DATA command task initialization Date: Fri, 18 Feb 2022 12:14:28 +0900 Message-Id: <20220218031445.548767-15-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In the pm8001_chip_sata_req() and pm80xx_chip_sata_req() functions, all tasks with a DMA direction of DMA_NONE (no data transfer) are initialized using the ATAP value 0x04. However, NCQ NON DATA commands, while being DMA_NONE commands are NCQ commands and need to be initialized using the value 0x07 for ATAP, similarly to other NCQ commands. Make sure that NCQ NON DATA command tasks are initialized similarly to other NCQ commands by also testing the task "use_ncq" field in addition to the DMA direction. While at it, reorganize the code into a chain of if - else if - else to avoid useless affectations and debug messages. Fixes: dbf9bfe61571 ("[SCSI] pm8001: add SAS/SATA HBA driver") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 14 +++++++------- drivers/scsi/pm8001/pm80xx_hwi.c | 13 ++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index e20a1d4db026..c0215a35a7b5 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4265,22 +4265,22 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, u32 opc = OPC_INB_SATA_HOST_OPSTART; memset(&sata_cmd, 0, sizeof(sata_cmd)); circularQ = &pm8001_ha->inbnd_q_tbl[0]; - if (task->data_dir == DMA_NONE) { + + if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { ATAP = 0x04; /* no data*/ pm8001_dbg(pm8001_ha, IO, "no data\n"); } else if (likely(!task->ata_task.device_control_reg_update)) { - if (task->ata_task.dma_xfer) { + if (task->ata_task.use_ncq && + dev->sata_dev.class != ATA_DEV_ATAPI) { + ATAP = 0x07; /* FPDMA */ + pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); + } else if (task->ata_task.dma_xfer) { ATAP = 0x06; /* DMA */ pm8001_dbg(pm8001_ha, IO, "DMA\n"); } else { ATAP = 0x05; /* PIO*/ pm8001_dbg(pm8001_ha, IO, "PIO\n"); } - if (task->ata_task.use_ncq && - dev->sata_dev.class != ATA_DEV_ATAPI) { - ATAP = 0x07; /* FPDMA */ - pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); - } } if (task->ata_task.use_ncq && pm8001_get_ncq_tag(task, &hdr_tag)) { task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 60c305f987b5..3deb89b11d2f 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4546,22 +4546,21 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num); circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; - if (task->data_dir == DMA_NONE) { + if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { ATAP = 0x04; /* no data*/ pm8001_dbg(pm8001_ha, IO, "no data\n"); } else if (likely(!task->ata_task.device_control_reg_update)) { - if (task->ata_task.dma_xfer) { + if (task->ata_task.use_ncq && + dev->sata_dev.class != ATA_DEV_ATAPI) { + ATAP = 0x07; /* FPDMA */ + pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); + } else if (task->ata_task.dma_xfer) { ATAP = 0x06; /* DMA */ pm8001_dbg(pm8001_ha, IO, "DMA\n"); } else { ATAP = 0x05; /* PIO*/ pm8001_dbg(pm8001_ha, IO, "PIO\n"); } - if (task->ata_task.use_ncq && - dev->sata_dev.class != ATA_DEV_ATAPI) { - ATAP = 0x07; /* FPDMA */ - pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); - } } if (task->ata_task.use_ncq && pm8001_get_ncq_tag(task, &hdr_tag)) { task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); From patchwork Fri Feb 18 03:14:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544220 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56002C433F5 for ; Fri, 18 Feb 2022 03:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbiBRDPq (ORCPT ); Thu, 17 Feb 2022 22:15:46 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:56996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231898AbiBRDP0 (ORCPT ); Thu, 17 Feb 2022 22:15:26 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA93A1AD284 for ; Thu, 17 Feb 2022 19:15:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154111; x=1676690111; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AtXsP68DA8SivwT19RlpE3NM6EAI2vFseddiKDScx9A=; b=ca3c7+/piZBcuiC4rqAcLjXk/Pte14UfiCOZixHiuUY6C4KXw9QSw578 LdF+LWdrzbc/fe2Q5wzGDYzLLU4az15SC5fOZ+xerEw/1hxfnrX6EIjSx Y8DZCx0Pkk2ZjLhELDDED6C4WV/KYS1RJPh4JltytFXEUcUsSR/vB4tfg Ne8mBmyoCXxl+wOScdKBTABmgXLXp7aqMYpwN+pakjqU4y+qZYNsywU88 1+HKeaE1uHSAv4c73gwRkidgDJZwj5n+Q3LaNt/bz5W9eW530hpyDAWrn fglDr4vcd78A2IbghyiLlmt/aA23z26kH/2nBfiezsIOEmnzqUrbV8sU6 g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225795" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:11 +0800 IronPort-SDR: f6hnrWsrWAYKC+Bg9E8wKKYFKZ6QxRVUDnedSgtXX+iAKr1Y2aYuCOapTOE3wOb/+lbTfTYbdu IwNUk96nskedVvVZnDH9R4gGxhXryxrC1qxKOl/axIx1wzm5JbIlGQkE5R7zahoip9WRDJrsBQ kcgmUAC3zvOGLus5h/VY3vqaXbeqdCeAu3K8c2IYFrmJ60AK127mjp/Dk1ZNpuiYJS9XqXsbyT iY9/maFhaEejx3y9rWZMb7keQCz2mMqSpUzg2gP+I5i0Ve4x/9NQYCJfWr1kRrRVoOgrGDMoV2 5b90GRV7NY4Xbr0QFrm6oKvo Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:48 -0800 IronPort-SDR: 1hiGmmSpsF+PIFcZP754yWwkc/VaiOHpEHaDsG+d4Sula4YFrhCwJSI5B7OUMizSXb1RcNZo1r 2M6HLDeSjTr1zUXJqaEG32T2DLAKgRmwt4xQWEXzQF4iv3kpNtv06xShneU6S+Ws4madGNZ9gu y2kmwkKsK2F/F9UPSaprwaLekdY/AmNsL54mTn97ZFOdt7jElAzwi8buN97id3jwMVAvCfUrUY tMinYnuq9LgSWt+nC7SxRKAYMQisyH01kBQB0gIU3qI5k7hLurHprME6uNLnSFCZIu0rYEQyn+ wUY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:10 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gz170crz1SVp5 for ; Thu, 17 Feb 2022 19:15:09 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154109; x=1647746110; bh=AtXsP68DA8SivwT19R lpE3NM6EAI2vFseddiKDScx9A=; b=GFL9GDSB7dB03/BLX+8rQnogbsQ5EbZgHz ceMbbXs4MQ3ewQ9/JU/L3Lkjny1G8n1HXWYKg1bOep2ZbUxx7R6tEtTNAvELTrxU Z3eB3ehLnOJTFUmwljeDZOwLZ0ZmHaFR5wnI/SmsZU1vzw8Ct4xnR8r6rYwE6Mcl yU/895jwTRRagx6Ze9BSQVifhZxAMaaImvGqjCwIGJbz93egurQTzt+fOkydmKMs MJa5fnk1O4tcFf3SWW/zJzQsz+I8UcK9khK7cucmuzYpqQ+iPeWofBy0jo7obSQE g4oUIC8bqOoze2XNoDdxfy6dotBru0vVBjRXIH9r/T/fZJD77DAA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TsxxIKf0zYBt for ; Thu, 17 Feb 2022 19:15:09 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gz02mr2z1Rwrw; Thu, 17 Feb 2022 19:15:08 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 15/31] scsi: pm8001: Fix NCQ NON DATA command completion handling Date: Fri, 18 Feb 2022 12:14:29 +0900 Message-Id: <20220218031445.548767-16-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org NCQ NON DATA is an NCQ command with the DMA_NONE DMA direction and so a register-device-to-host-FIS response is expected for it. However, for an IO_SUCCESS case, mpi_sata_completion() expects a set-device-bits-FIS for any ata task with an use_ncq field true, which includes NCQ NON DATA commands. Fix this to correctly treat NCQ NON DATA commands as non-data by also testing for the DMA_NONE DMA direction. Fixes: dbf9bfe61571 ("[SCSI] pm8001: add SAS/SATA HBA driver") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 3 ++- drivers/scsi/pm8001/pm80xx_hwi.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index c0215a35a7b5..8149cc0d1ecd 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -2415,7 +2415,8 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) len = sizeof(struct pio_setup_fis); pm8001_dbg(pm8001_ha, IO, "PIO read len = %d\n", len); - } else if (t->ata_task.use_ncq) { + } else if (t->ata_task.use_ncq && + t->data_dir != DMA_NONE) { len = sizeof(struct set_dev_bits_fis); pm8001_dbg(pm8001_ha, IO, "FPDMA len = %d\n", len); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 3deb89b11d2f..ac2178a13e4c 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -2507,7 +2507,8 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, len = sizeof(struct pio_setup_fis); pm8001_dbg(pm8001_ha, IO, "PIO read len = %d\n", len); - } else if (t->ata_task.use_ncq) { + } else if (t->ata_task.use_ncq && + t->data_dir != DMA_NONE) { len = sizeof(struct set_dev_bits_fis); pm8001_dbg(pm8001_ha, IO, "FPDMA len = %d\n", len); From patchwork Fri Feb 18 03:14:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 335B0C433EF for ; Fri, 18 Feb 2022 03:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231934AbiBRDPr (ORCPT ); Thu, 17 Feb 2022 22:15:47 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231927AbiBRDPn (ORCPT ); Thu, 17 Feb 2022 22:15:43 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 084FA1BAC68 for ; Thu, 17 Feb 2022 19:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154112; x=1676690112; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZdAZjOz0DdWfc2ddhVgvZaPj7g27emWw7eDrDZx7wkg=; b=CPK4c+IoCmsIfIJvPFSfr8yWSiiUotEp40+fT4F9JHB5VhtCe77Kt38x YcicgUP9gxN6KMHnNno1qJHAUfnUCh0mUo6mWBVbR8LJHwA8Cx8e9K6L3 yGP3Kb+7WvyZQuVwzNmr6DC2/v+Z7AezdyW3HDrcABa6FjhwxySK8P4iY 4fXuQc1yXNZABhlIZSqn4qY7BSmhplKukdLm7StVk/p9KNsUjCTNXMvad fmsMgv81ebvqAPXyehaBaJAjOKRDAcKUFAuu4ex6jchcRZZ5oumblW7Yh xVEi5pA7vmG4syDzrjXahJqQCh/8GyySDQhwhRGw36qjSHU5vO0kj7rWG Q==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225800" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:12 +0800 IronPort-SDR: dlF2m+Tez8fiWH+PK2GgaRyFCcOjR29xmslEm6f9iDhMFCIttWUJ7g0CGjB/IKpgxzINJyv0i0 NMdR6vVaeP47sK5tk1nWsr5uA+isALb6y/fJSG9KFRxwC8Vf58zneXad9C5oI3FQ8QjHfIX0WO WelJkBy+sGPEAKLGfAXmdqwVq1cOFJdP4V20MHlSz27gvzFNEGt6hAs/tCUjSTZyEMK+gUuMQ+ DQ0sAs+AVWQYsqpwVrJ9oGY2D6O1eqleTNyqtP9SuMD8z7tWACuYGenQJ0nSiORxuJvyAqRpd4 +6KhdZLF17QA4pV7e/iOt0Xe Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:49 -0800 IronPort-SDR: MLqjkDlDilUGqhNsuzEw1XNYVsHnVJOE3pCaF2r93qGT+WbC27Ykb0EKnOQfg/7BMUzTH1c0DL mEDQ2R+i+JX9NgG8EVncaohjmL7j7HBq0ZL12BqAuRzx4cOX1dpVzZGpd4iPns7WAWzGgVmhoS SoMwiU64vQVyAtLIi0EGYWb7dvl6mUWTIL9Aa3rYfkGxJxq8EeAoKjtMSeC1s1cDWWLhk1DpdK glbOGUWj2AcmjbbbqBUD+0gyUqochCuC5RRr1Dbqr3XdPdfSe+FUzBD0BsuHf62tJddOUG2Oza anw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:12 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gz32pxwz1SVp4 for ; Thu, 17 Feb 2022 19:15:11 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154110; x=1647746111; bh=ZdAZjOz0DdWfc2ddhV gvZaPj7g27emWw7eDrDZx7wkg=; b=N7Wcsw5rtuV6OuKJ2g3GkCfqfVD6srZ0py Y9PEy4/VT9n9I5EsBdjfyaXxuVXgcja99iZKj4YrjHRgJa2AYokYZlImmHJSwdmS 4LH+XoZV6Xlcpxqb61jhAtw2P1Z3UhvgMUCLfijD/TNZiDkkuNBrT+AXzqpZGijV khUI28LXqC22BwyWRi65g4u5XuTS5Ww8uOreV7Aohc7SxwveL3q/+3QkymvrM8c3 6KRu5+dfLZ6aE+kQTKVILIJLyVCR3z836QAb2FVCX3J2yHFOIRllUtcwQ6oqpj+Q GG9AMJjdhIXgzY8HgiUg0BipefLQAV6AoIetna3+0uwIGCfUBaog== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id q3CPvhddtbsQ for ; Thu, 17 Feb 2022 19:15:10 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gz14zhcz1SHwl; Thu, 17 Feb 2022 19:15:09 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 16/31] scsi: pm8001: Fix abort all task initialization Date: Fri, 18 Feb 2022 12:14:30 +0900 Message-Id: <20220218031445.548767-17-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm80xx_send_abort_all(), the n_elem field of the ccb used is not initialized to 0. This missing initialization sometimes lead to the task completion path seeing the ccb with a non-zero n_elem resulting in the execution of invalid dma_unmap_sg() calls in pm8001_ccb_task_free(), causing a crash such as: [ 197.676341] RIP: 0010:iommu_dma_unmap_sg+0x6d/0x280 [ 197.700204] RSP: 0018:ffff889bbcf89c88 EFLAGS: 00010012 [ 197.705485] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff83d0bda0 [ 197.712687] RDX: 0000000000000002 RSI: 0000000000000000 RDI: ffff88810dffc0d0 [ 197.719887] RBP: 0000000000000000 R08: 0000000000000000 R09: ffff8881c790098b [ 197.727089] R10: ffffed1038f20131 R11: 0000000000000001 R12: 0000000000000000 [ 197.734296] R13: ffff88810dffc0d0 R14: 0000000000000010 R15: 0000000000000000 [ 197.741493] FS: 0000000000000000(0000) GS:ffff889bbcf80000(0000) knlGS:0000000000000000 [ 197.749659] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 197.755459] CR2: 00007f16c1b42734 CR3: 0000000004814000 CR4: 0000000000350ee0 [ 197.762656] Call Trace: [ 197.765127] [ 197.767162] pm8001_ccb_task_free+0x5f1/0x820 [pm80xx] [ 197.772364] ? do_raw_spin_unlock+0x54/0x220 [ 197.776680] pm8001_mpi_task_abort_resp+0x2ce/0x4f0 [pm80xx] [ 197.782406] process_oq+0xe85/0x7890 [pm80xx] [ 197.786817] ? lock_acquire+0x194/0x490 [ 197.790697] ? handle_irq_event+0x10e/0x1b0 [ 197.794920] ? mpi_sata_completion+0x2d70/0x2d70 [pm80xx] [ 197.800378] ? __wake_up_bit+0x100/0x100 [ 197.804340] ? lock_is_held_type+0x98/0x110 [ 197.808565] pm80xx_chip_isr+0x94/0x130 [pm80xx] [ 197.813243] tasklet_action_common.constprop.0+0x24b/0x2f0 [ 197.818785] __do_softirq+0x1b5/0x82d [ 197.822485] ? do_raw_spin_unlock+0x54/0x220 [ 197.826799] __irq_exit_rcu+0x17e/0x1e0 [ 197.830678] irq_exit_rcu+0xa/0x20 [ 197.834114] common_interrupt+0x78/0x90 [ 197.840051] [ 197.844236] [ 197.848397] asm_common_interrupt+0x1e/0x40 Avoid this issue by always initializing the ccb n_elem field to 0 in pm8001_send_abort_all(), pm8001_send_read_log() and pm80xx_send_abort_all(). Fixes: c6b9ef5779c3 ("[SCSI] pm80xx: NCQ error handling changes") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 2 ++ drivers/scsi/pm8001/pm80xx_hwi.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 8149cc0d1ecd..35d62e5c9200 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1787,6 +1787,7 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; + ccb->n_elem = 0; circularQ = &pm8001_ha->inbnd_q_tbl[0]; @@ -1848,6 +1849,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; + ccb->n_elem = 0; pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index ac2178a13e4c..8fd38e54f07c 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1800,6 +1800,7 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; + ccb->n_elem = 0; circularQ = &pm8001_ha->inbnd_q_tbl[0]; From patchwork Fri Feb 18 03:14:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 476ECC433FE for ; Fri, 18 Feb 2022 03:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231912AbiBRDRj (ORCPT ); Thu, 17 Feb 2022 22:17:39 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231928AbiBRDPn (ORCPT ); Thu, 17 Feb 2022 22:15:43 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 288711BB725 for ; Thu, 17 Feb 2022 19:15:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154113; x=1676690113; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aFrF4rJ6wByeGWngQJkFybPJUoSWqcmYvM759TiDF+A=; b=pwlAduCHMdXht/9GEeLdBIQq0yLiHi6Xug+UUvfm2Qv3izWAwEgnGtAC VToKsAG5oW7fLnPK6PNkJjGARwIt0GOU0nalF2CgGrC+jFtWhqBe1xml7 R87qiarnlhMaEADKYErrCNJ8GKGMFwSow9hoyR07zuoEpQRa5f9H5JP4z E6od8J/xKGKi+uQYeOWTMrox3bGlsehnsUq4Iwa+k2UTsyGgM8GN8PCHK 3kVXviMl1xTq98Z2pVJ7qP98SeIQAgdWdffXzi1m/6dDyppbpiSaFUu6K akYMXQc0FDlIDbUccnYh6JE9qbTH/80p6sBRWx69zGlIQ6fm+5ijJH2jf g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225804" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:13 +0800 IronPort-SDR: Mdljyg12KKdwGAbStibixYroh9zCwGnGrhMZaKfD7Yyy+KGMs25+1vCY1y5rS70M7hNLZtRWqg KcQ89zTNJhUMvczWINLr8s7lnOx1i4W2RUkm3kluarix/aHhE9HguORxr43wVRV9sBiQwEQFY5 RbplKm/5ipDjpibJdV3Z2C1b/XHUVDDj5SUYeifndZvdg41CfH2/dqtBrBfvL13FhIA27TR65n jtNtT5LW2CmveXXRXQtwxiHeLMlT3kIzmllHMhhZbl/MtlWDbZvcdM8KfFjD+b5kdk+gIpp8HQ 0sHc/K5p7HRGTxLebSd+SSmR Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:51 -0800 IronPort-SDR: P1AkybG3e61Kk/+Qa+WSppxIyWYhmCmiy95ebG+jxkl5V45ddeQtF376WPLiJM/wgT9cVUbOCl jtjFziBqHerdezwSm9KApOTO47puiURfy8Reh6M3OZIGoGaeWkHNASwhbOSU2mn1ItT9msUvud RY+7t/W6qgbd7S4Ks/XkBBOlRGBIrDxgswAoaIDbckzPhKlnxLuPbHygoX8jadQ6uK3Ki5ecsb Z1V4LD7XlDy7cU2SaNzE8JML/73A+Ob0WOg2Bw7gqNc7EAwwD0eZhXtG5f/Uh4tOZHjVAqQJ/e Zt8= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:13 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gz45yJvz1SVp3 for ; Thu, 17 Feb 2022 19:15:12 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154112; x=1647746113; bh=aFrF4rJ6wByeGWngQJ kFybPJUoSWqcmYvM759TiDF+A=; b=Irb6sSipA2G0d/3qXnduOnlumgjOmjm0OW kZo1fQczD6G0PVTFeMo1Zlqwk3uoAFdbugDIvhbn8rGBJ9XhdzXIqZPdmodd7hj0 aAxBvjfv8kSHtAUPr7vV2TH3x3sLcldNuJDsnbDzJvlcjRCXz/iJZUCr9ptJKud8 tph75me+3zvzRinsMyxy9BYPbJnzFLQJblzLJ0hkjU2s2uGykYhB+G34x0xlBOf2 IibbzuzDN7A+OqSbAoYWQ65aQKB/zT+d674VOE5XxSf4QwFQ5sZ9XrTXp81puWU0 jNC3nSfvAAJv+mbq/3Si3M48a6xOuMU0748FVpBo7eLOEpNqsopg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id AHliiNMqBwhH for ; Thu, 17 Feb 2022 19:15:12 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gz31Jwzz1Rwrw; Thu, 17 Feb 2022 19:15:10 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 17/31] scsi: pm8001: Fix pm8001_tag_alloc() failures handling Date: Fri, 18 Feb 2022 12:14:31 +0900 Message-Id: <20220218031445.548767-18-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In mpi_set_phy_profile_req() and in pm8001_set_phy_profile_single(), if pm8001_tag_alloc() fails to allocate a new tag, a warning message is issued but the uninitialized tag variable is still used to build a command. Avoid this by returning early in case of tag allocation failure. Also make sure to always return the error code returned by pm8001_tag_alloc() when this function fails instead of an arbitrary value. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 8fd38e54f07c..76260d06b6be 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1191,7 +1191,7 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) memset(&payload, 0, sizeof(struct set_ctrl_cfg_req)); rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) - return -1; + return rc; circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); @@ -1240,7 +1240,7 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) - return -1; + return rc; circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); @@ -1398,7 +1398,7 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) memset(&payload, 0, sizeof(struct kek_mgmt_req)); rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) - return -1; + return rc; circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); @@ -4967,8 +4967,11 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, memset(&payload, 0, sizeof(payload)); rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) + if (rc) { pm8001_dbg(pm8001_ha, FAIL, "Invalid tag\n"); + return; + } + circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); payload.ppc_phyid = @@ -5010,8 +5013,10 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, memset(&payload, 0, sizeof(payload)); rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) + if (rc) { pm8001_dbg(pm8001_ha, INIT, "Invalid tag\n"); + return; + } circularQ = &pm8001_ha->inbnd_q_tbl[0]; opc = OPC_INB_SET_PHY_PROFILE; From patchwork Fri Feb 18 03:14:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58537C433FE for ; Fri, 18 Feb 2022 03:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231985AbiBRDP6 (ORCPT ); Thu, 17 Feb 2022 22:15:58 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231932AbiBRDPn (ORCPT ); Thu, 17 Feb 2022 22:15:43 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67FA61BBF40 for ; Thu, 17 Feb 2022 19:15:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154115; x=1676690115; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iR4rqyNUe2jk5VIFUb8waldi+JGvDb0b3u7gvNVRma4=; b=GxxtjOlADT0VZ6yqfaE9eM4Q6KTYhwRSSAd8vjkNh7M8o3YtIG40ll5U 5H80aZixV5T2316O5NhvgQ7OS9R5LR5n56LCQkF7tvJLWkJNQD1OnnqoN pTB7mXUAXAgl3klrhsoPq/o3bLJDt9UdPGZ2TTA0Oj8V6mUDkBN84oy3O XkPkNJulfcJgcN7iPsatMtkkF8yF0pDRA2j5SKR6v4IjOfnfVxMjQct2Z kM/Z8pK++yfx8YXAzH5G/IZzwNcnCNGLCaR2SSs8n5GxM857IrMNiMXxp Q8se8YbIWqg7va4c4HucrjEHvkYszcI9Cle8ipEwxzAIVCrNJMR8qOHvu g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225808" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:14 +0800 IronPort-SDR: WT5cUmZ1tSjIs20xhMRdgIgmO19F9gRhidk8Aem+7ZNkqsZ8pY23ycW7rPWzA6Z9Audc2fjmp/ L9uMGshu7KNmKp6Ny79LS+lLBfZK+jfj6TovI7UoY5u2g08ebPz19QcuYMouO4uGcqqI9M9ImE cVqBIsQ2KUTZW2wd/D4GK7b0eHxxF2fRhwJturmnzyHx8rp+ilo+xDXOaFV3aWKCTvpz6npRMj 0tzISl/RMcaO2v0m1Q1AUBLS3i2aouYgLqyvbMHZxaqTfTqX/E+ybQuXzkyb34axnBT/qXk2Py gznQAN+gDQuIcEZAmH9v/qLX Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:52 -0800 IronPort-SDR: ZE4N5f79ECm5mh9o3FcAiP0CuF3MJ7Zp3rD7XMOopweKJZEZwh1jlatfklbzvaTVtIHU9Yzk0/ 0SaySQJWuNhTM2p5nM9s42J4GwJV92sHcb80fOOtZI9pzM+di9IfziuVEV+xebxyb8UKm2NLZE OLTgldJ+aBTBEJt/VkZBiY17mUTsjsgr4LPJcxNoBtZT8O/48FOqQWaOMP9TzyiWasrno1VcXf ZzupNza9PE/VBmHNcnwlQRS7FC0gVxM6zVsNmuE9Vk8nWCpI7ljtN/niPqN374vpXB9mUOXiLf UF8= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:14 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gz60bssz1SVp1 for ; Thu, 17 Feb 2022 19:15:14 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154113; x=1647746114; bh=iR4rqyNUe2jk5VIFUb 8waldi+JGvDb0b3u7gvNVRma4=; b=aS92PXMDfJqvIH5j8QW+o2M17FjpAt4apB kKlzDMBXqKbR76cjONkBCMI8UcURbH7N/5dHW+Queb90xO5xUMLa8AGyO2ABD4La ka3wheuwggJ6cAqCy2MEwnvgCUEkBEmjaZkeCfn+uQJu0iZqZEPJP9KcYNFi2at7 iO9BD/a0mPNW6rV5K6SGrG7MWGKkz3cP0G/DD2Mp0h6eK6IaHadDYJzXlS+OCqD0 1XDM0hSgzd+izkAlbdWXEP2tDt5Ww4/LQXq4m5Ar7BsSR0dQs3Nv77GU4tx4joiw bQTyzfBID9saGD8uQLOCMsnZVCCJKJOOVxx3e4cbA5XTvaXONSUg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XJn0DN1gA7NT for ; Thu, 17 Feb 2022 19:15:13 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gz44WzWz1SHwl; Thu, 17 Feb 2022 19:15:12 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 18/31] scsi: pm8001: Fix pm8001_mpi_task_abort_resp() Date: Fri, 18 Feb 2022 12:14:32 +0900 Message-Id: <20220218031445.548767-19-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The call to pm8001_ccb_task_free() at the end of pm8001_mpi_task_abort_resp() already frees the ccb tag. So when the device NCQ_ABORT_ALL_FLAG is set, the tag should not be freed again. Also change the hardcoded 0xBFFFFFFF value to ~NCQ_ABORT_ALL_FLAG as it ought to be. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 35d62e5c9200..5cad5504301e 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -3700,12 +3700,11 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) mb(); if (pm8001_dev->id & NCQ_ABORT_ALL_FLAG) { - pm8001_tag_free(pm8001_ha, tag); sas_free_task(t); - /* clear the flag */ - pm8001_dev->id &= 0xBFFFFFFF; - } else + pm8001_dev->id &= ~NCQ_ABORT_ALL_FLAG; + } else { t->task_done(t); + } return 0; } From patchwork Fri Feb 18 03:14:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544218 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 162FDC433EF for ; Fri, 18 Feb 2022 03:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231979AbiBRDPx (ORCPT ); Thu, 17 Feb 2022 22:15:53 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231941AbiBRDPn (ORCPT ); Thu, 17 Feb 2022 22:15:43 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 183631BBF5D for ; Thu, 17 Feb 2022 19:15:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154120; x=1676690120; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nFinQwtMY9NA+m4aufz3pH2lyHwmyuiXD24SymgYwfg=; b=KgocyAX6uhg2jhjsGgxvJDegO4M8C72jYIOvuf5WoLVbp5V+AnpL25hq eCRpzXE+lTUmhhdDNQNihxTaRHH6Zqp0W0fphZO6jh25kx+Uv+zZmpjR1 g71VOSVRjS6/hyxN1M5puIOSVbnSmx6x6WbdSMTMTWEqoed6ONLkv/A1/ CvzsItoiJsxVnQy6q5e04Fa/qTUzFsTgTDa7W6EFFRf6ZOFwNs7jzUD86 6RxbPRJLpWNYdFWw7WOCrsaUQbv8AO9hUSm1jXhbcG/7uuM0GfcivV50N rLyW2Pbt3+5wmVg6nLk3IS7mv/+i8toO2xQBY0YnaZqbFC/jeoOEsZngG g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="194225811" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:18 +0800 IronPort-SDR: 0Zoaf6f9S8GSGPbaSlr7nmgOm/uwuYi/pCHx5zu4MWD5F9PViLGuZXP06UQLXOhhkDq6cOxguu U4wydVczlLACWDL+C65/3rSKaL+cFNxfU52tmHmqj6UvIfT2qyb6ZWjzGivi+OYsa558cLuYEE KGENZy/8gL2N2APLpj284biGv7E16ffgnLdxPg5IJsq+4jfLNkZa1Rk+MEgljmr1rq/554BgJm +lVUqRdB9yksgOC6JuTkQj9G+ouyqoh7EOkweT8Rm1yUneBjDhvL6TrKAHv5IIwUnjkNyY+3VD 1r9m4uiCo+K1GQYBuF/zgiaD Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:54 -0800 IronPort-SDR: 7JQsc1E3R4gTnbFJgIOlq78tR+Etj/bzyhwAnM2CgzkJqhbTJKkc9m343SrepP9l5bv4EDqsbM S1pPqy0CdjvptNP9VY8bLYNvjvGz4GL4GmDzhlxKTJRPhoN0l3wmhFKHPMMY9RvlRlkumL58WG SuSZaHyOnmgeRP3GW3GhVEh9xEro0GyhGuCx6D8PApqyWfWj9aMLi8pnoq0n/c8i8YwX5YNkUp NDOvySh468/WI9/I07r+b27uPGGT3cxxK58RKxbip2nQ0+wMNavy3OScQY4Z02P1qTWaQz+9fP iSQ= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:16 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gz80yPZz1SVp3 for ; Thu, 17 Feb 2022 19:15:16 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154115; x=1647746116; bh=nFinQwtMY9NA+m4auf z3pH2lyHwmyuiXD24SymgYwfg=; b=aKYECfbYBnroUS+YTME2X79p1bq3FeXKIn i7UubXpnb3GbTlTNcVBLdphhPfpb1m9TsARduppjhuRvgjcaUT6FY5DQ/Opq0cM4 vCV2Z6yPrU9OpexOX2qke0JBhXn7gcAciYVTB9ZqKV/Qv6Wvgq2a9ubzWii42hGp RFfiwsGznKEI2JP3whTZ7Hz+ds+VY3rJBppS+Mg7FyPcEYpAqSLzXCqoCcqdb6V8 8Q/i7sc1h8XQWMqMvVsShzDDz7I0rkMDjKbN/Uw6jS6ABRqQX+oTFNOYODfPJNe/ LNUHYVHn+4Jxy5LXxsWdeSRzcGQ71S2qZsIB/g5jkxYUKJXlKCzg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Ep2ZHbbHf0Hy for ; Thu, 17 Feb 2022 19:15:15 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gz56mF1z1Rwrw; Thu, 17 Feb 2022 19:15:13 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 19/31] scsi: pm8001: Fix tag values handling Date: Fri, 18 Feb 2022 12:14:33 +0900 Message-Id: <20220218031445.548767-20-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The function pm8001_tag_alloc() determines free tags using the function find_first_zero_bit() which can return 0 when the first bit of the bitmap being inspected is 0. As such, tag 0 is a valid tag value that should not be dismissed as invalid. Fix the functions pm8001_work_fn(), mpi_sata_completion(), pm8001_mpi_task_abort_resp() and pm8001_open_reject_retry() to not dismiss 0 tags as invalid. The value 0xffffffff is used for invalid tags for unused ccb information structures. Add the macro definition PM8001_INVALID_TAG to define this value. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 52 +++++++++++-------------------- drivers/scsi/pm8001/pm8001_init.c | 3 +- drivers/scsi/pm8001/pm8001_sas.c | 13 ++++---- drivers/scsi/pm8001/pm8001_sas.h | 2 ++ drivers/scsi/pm8001/pm80xx_hwi.c | 5 --- 5 files changed, 28 insertions(+), 47 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 5cad5504301e..3dc628b0384d 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1522,7 +1522,6 @@ void pm8001_work_fn(struct work_struct *work) case IO_XFER_ERROR_BREAK: { /* This one stashes the sas_task instead */ struct sas_task *t = (struct sas_task *)pm8001_dev; - u32 tag; struct pm8001_ccb_info *ccb; struct pm8001_hba_info *pm8001_ha = pw->pm8001_ha; unsigned long flags, flags1; @@ -1544,8 +1543,8 @@ void pm8001_work_fn(struct work_struct *work) /* Search for a possible ccb that matches the task */ for (i = 0; ccb = NULL, i < PM8001_MAX_CCB; i++) { ccb = &pm8001_ha->ccb_info[i]; - tag = ccb->ccb_tag; - if ((tag != 0xFFFFFFFF) && (ccb->task == t)) + if ((ccb->ccb_tag != PM8001_INVALID_TAG) && + (ccb->task == t)) break; } if (!ccb) { @@ -1566,11 +1565,11 @@ void pm8001_work_fn(struct work_struct *work) spin_unlock_irqrestore(&t->task_state_lock, flags1); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with event 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, pw->handler, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); spin_unlock_irqrestore(&pm8001_ha->lock, flags); } else { spin_unlock_irqrestore(&t->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); mb();/* in order to force CPU ordering */ spin_unlock_irqrestore(&pm8001_ha->lock, flags); t->task_done(t); @@ -1579,7 +1578,6 @@ void pm8001_work_fn(struct work_struct *work) case IO_XFER_OPEN_RETRY_TIMEOUT: { /* This one stashes the sas_task instead */ struct sas_task *t = (struct sas_task *)pm8001_dev; - u32 tag; struct pm8001_ccb_info *ccb; struct pm8001_hba_info *pm8001_ha = pw->pm8001_ha; unsigned long flags, flags1; @@ -1613,8 +1611,8 @@ void pm8001_work_fn(struct work_struct *work) /* Search for a possible ccb that matches the task */ for (i = 0; ccb = NULL, i < PM8001_MAX_CCB; i++) { ccb = &pm8001_ha->ccb_info[i]; - tag = ccb->ccb_tag; - if ((tag != 0xFFFFFFFF) && (ccb->task == t)) + if ((ccb->ccb_tag != PM8001_INVALID_TAG) && + (ccb->task == t)) break; } if (!ccb) { @@ -1685,19 +1683,13 @@ void pm8001_work_fn(struct work_struct *work) struct task_status_struct *ts; struct sas_task *task; int i; - u32 tag, device_id; + u32 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) { @@ -1706,10 +1698,11 @@ void pm8001_work_fn(struct work_struct *work) continue; } /*complete sas task and update to top layer */ - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, task, ccb, + ccb->ccb_tag); ts->resp = SAS_TASK_COMPLETE; task->task_done(task); - } else if (tag != 0xFFFFFFFF) { + } else if (ccb->ccb_tag != PM8001_INVALID_TAG) { /* complete the internal commands/non-sas task */ pm8001_dev = ccb->device; if (pm8001_dev->dcompletion) { @@ -1717,7 +1710,7 @@ void pm8001_work_fn(struct work_struct *work) pm8001_dev->dcompletion = NULL; } complete(pm8001_ha->nvmd_completion); - pm8001_tag_free(pm8001_ha, tag); + pm8001_tag_free(pm8001_ha, ccb->ccb_tag); } } /* Deregister all the device ids */ @@ -2313,11 +2306,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) param = le32_to_cpu(psataPayload->param); tag = le32_to_cpu(psataPayload->tag); - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, "tag null\n"); - return; - } - ccb = &pm8001_ha->ccb_info[tag]; t = ccb->task; pm8001_dev = ccb->device; @@ -3051,7 +3039,7 @@ void pm8001_mpi_set_dev_state_resp(struct pm8001_hba_info *pm8001_ha, device_id, pds, nds, status); complete(pm8001_dev->setds_completion); ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); } @@ -3069,7 +3057,7 @@ void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) dlen_status); } ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); } @@ -3096,7 +3084,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) * freed by requesting path anywhere. */ ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); return; } @@ -3142,7 +3130,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) complete(pm8001_ha->nvmd_completion); pm8001_dbg(pm8001_ha, MSG, "Get nvmd data complete!\n"); ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); } @@ -3555,7 +3543,7 @@ int pm8001_mpi_reg_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) } complete(pm8001_dev->dcompletion); ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, htag); return 0; } @@ -3627,7 +3615,7 @@ int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info *pm8001_ha, } kfree(ccb->fw_control_context); ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); complete(pm8001_ha->nvmd_completion); return 0; @@ -3663,10 +3651,6 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) status = le32_to_cpu(pPayload->status); tag = le32_to_cpu(pPayload->tag); - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, " TAG NULL. RETURNING !!!\n"); - return -1; - } scp = le32_to_cpu(pPayload->scp); ccb = &pm8001_ha->ccb_info[tag]; diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 4b9a26f008a9..8f44be8364dc 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1216,10 +1216,11 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost, goto err_out; } pm8001_ha->ccb_info[i].task = NULL; - pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff; + pm8001_ha->ccb_info[i].ccb_tag = PM8001_INVALID_TAG; pm8001_ha->ccb_info[i].device = NULL; ++pm8001_ha->tags_num; } + return 0; err_out_noccb: diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 4ab0ea9483f2..d0f5feb4f2d3 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -563,7 +563,7 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, task->lldd_task = NULL; ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; ccb->open_retry = 0; pm8001_tag_free(pm8001_ha, ccb_idx); } @@ -948,9 +948,11 @@ void pm8001_open_reject_retry( struct task_status_struct *ts; struct pm8001_device *pm8001_dev; unsigned long flags1; - u32 tag; struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[i]; + if (ccb->ccb_tag == PM8001_INVALID_TAG) + continue; + pm8001_dev = ccb->device; if (!pm8001_dev || (pm8001_dev->dev_type == SAS_PHY_UNUSED)) continue; @@ -962,9 +964,6 @@ void pm8001_open_reject_retry( continue; } else if (pm8001_dev != device_to_close) continue; - tag = ccb->ccb_tag; - if (!tag || (tag == 0xFFFFFFFF)) - continue; task = ccb->task; if (!task || !task->task_done) continue; @@ -984,11 +983,11 @@ void pm8001_open_reject_retry( & SAS_TASK_STATE_ABORTED))) { spin_unlock_irqrestore(&task->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, task, ccb, ccb->ccb_tag); } else { spin_unlock_irqrestore(&task->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, task, ccb, ccb->ccb_tag); mb();/* in order to force CPU ordering */ spin_unlock_irqrestore(&pm8001_ha->lock, flags); task->task_done(task); diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index a17da1cebce1..1791cdf30276 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -738,6 +738,8 @@ void pm8001_free_dev(struct pm8001_device *pm8001_dev); /* ctl shared API */ extern const struct attribute_group *pm8001_host_groups[]; +#define PM8001_INVALID_TAG ((u32)-1) + static inline void pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, struct sas_task *task, struct pm8001_ccb_info *ccb, diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 76260d06b6be..cc46e2013eeb 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -2402,11 +2402,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, param = le32_to_cpu(psataPayload->param); tag = le32_to_cpu(psataPayload->tag); - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, "tag null\n"); - return; - } - ccb = &pm8001_ha->ccb_info[tag]; t = ccb->task; pm8001_dev = ccb->device; From patchwork Fri Feb 18 03:14:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96029C433F5 for ; Fri, 18 Feb 2022 03:15:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231984AbiBRDP5 (ORCPT ); Thu, 17 Feb 2022 22:15:57 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231935AbiBRDPn (ORCPT ); Thu, 17 Feb 2022 22:15:43 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 626131BBF52 for ; Thu, 17 Feb 2022 19:15:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154118; x=1676690118; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ig1uYjC9rTuwTN1Ykh0XxJsNqojO83JkUIq8tDwJTbo=; b=dJpGHJBHqhF3BXuQZODEzf4tXfpxr7sYBHfDO/OtRsuWg+a9MQ8cvgLW H13sbudGf+FZjGLa6mjhHKbP9QllwvC9xUtfTKsyB9ixL6UCXOtxKpNpg OdUxfJM569mAxGr3CSOKbexr3mCiKWe7M0mMAIN9yYRodVWInOG8sLCw+ T4n9A0YSjG+aFGsKGfH1P0e/vkP66QFoJ1gtvmTX42inaBFJ1mVbIyFSF oNgQvFTAlD2AgevYyZkT/N5F+IZlI/FbqqqyGYIxOWFpglV5gsM9PhVvq xcn2lK9ic2TCTBwhzALXqTy2AyfOGFsDcL2FQ/RE48HxzxfqEcATNt3+7 Q==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="297362825" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:17 +0800 IronPort-SDR: zZdUel99JoZeE5lKW+wZOOByMMoPQkGEaBo/d54uSSo12mOIPXcBTWkl0tNj6MOxGrKqbcCE08 MyqDBE/v+6SsDQAXVeQVmNDxCKFjB0XDjBEdn9tssNGMINW4NHzbdfWHWG6MlfgQoKGqv0IyyK sIDl0+35W7bN3G2NxnAMYTHBNJJz/pf/qqNbWeS98rH22CCdHjvedFNWD4tVYr0pXYnDZam75l a5ZP9/kYDDjPKTplqrwNHUyG+Nh3GZgX2je7t3dOMn8Zy83G6iL8afuBzp8epcchPQvYU+7v5i RXI2vphb/xp5TEATzoyw/o8R Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:55 -0800 IronPort-SDR: LGdT5Zo8S5UwoPOvD99IMwjRTzzwSO/D+ZRXP9o75W8quZKy+aCw3MueIH9cZkdo0NFeYzwKNK nV8oSf4cHRcLwJ3jzqn2ZI8bX+oLVPXPYIFhvT8kCRRPMMtEwvQyafgCMVkic/YqRRUlI4Xnbs 5LE8i1SGOUvmu+8gO1FqCYH9eU/gTcJLKEg6MtgMdiPR7+DS5i9RCBdhDQpKlZQH39B/nZcXqw oY3Cb3rvpox+xW7WLp5WlHpTFy8Z0vFYWYviO9cv9d2CvjG5lDMR/Of71pqy98ICYprnBt8OyJ snQ= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:17 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0Gz92ZDGz1SVp2 for ; Thu, 17 Feb 2022 19:15:17 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154116; x=1647746117; bh=ig1uYjC9rTuwTN1Ykh 0XxJsNqojO83JkUIq8tDwJTbo=; b=UkSYW1XeRDNSva1kKniW9GYgBPAwUXjzeN 2j4/Olqs8dE8YNpRZFp9swpEg1wLDR8v3gKWrUA/UmPor9RbgZsk2tgt3IM6z28x kuK0h94tHsrOR/MSQsrIE72vy1zzkboTB26+v180DXBmfYBZp4fXzrYmOh8DUdu0 k/aS7ma3b1l/x+H0IGbEG1qUGi8c30xCddvq0fLLM2tJwldxAWFhbhHWIm0AVdzF kwuHp2CTPemyeKmZKC7mC9H0zi4JQRqIWkj+2A5wfdfP9XePkmx5B5a+Cl+HcRT2 5L3riUzdJ/BiDc/RmSEHzvCrA8BmvwFSWPqqJPxonobcvtDGMlVQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1X9VwA_XukBo for ; Thu, 17 Feb 2022 19:15:16 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gz74FsSz1SHwl; Thu, 17 Feb 2022 19:15:15 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 20/31] scsi: pm8001: Fix task leak in pm8001_send_abort_all() Date: Fri, 18 Feb 2022 12:14:34 +0900 Message-Id: <20220218031445.548767-21-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm8001_send_abort_all(), make sure to free the allocated sas task if pm8001_tag_alloc() or pm8001_mpi_build_cmd() fail. Signed-off-by: Damien Le Moal Reviewed-by: John Garry --- drivers/scsi/pm8001/pm8001_hwi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 3dc628b0384d..cc96e58454c8 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1764,7 +1764,6 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, } task = sas_alloc_slow_task(GFP_ATOMIC); - if (!task) { pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task\n"); return; @@ -1773,8 +1772,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, task->task_done = pm8001_task_done; res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) + if (res) { + sas_free_task(task); return; + } ccb = &pm8001_ha->ccb_info[ccb_tag]; ccb->device = pm8001_ha_dev; @@ -1791,8 +1792,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, sizeof(task_abort), 0); - if (ret) + if (ret) { + sas_free_task(task); pm8001_tag_free(pm8001_ha, ccb_tag); + } } From patchwork Fri Feb 18 03:14:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0433DC433F5 for ; Fri, 18 Feb 2022 03:15:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231990AbiBRDP7 (ORCPT ); Thu, 17 Feb 2022 22:15:59 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231938AbiBRDPn (ORCPT ); Thu, 17 Feb 2022 22:15:43 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CD281BBF58 for ; Thu, 17 Feb 2022 19:15:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154118; x=1676690118; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g7EBBD7qLhE1YqM6ddgx33476kZlCQryWeE4NMPtD5c=; b=P3WVjMQl7ZCZOvoiwr9H3e2Nz5Bi7hs0LalTzgulp+qmVzxIRALcWpZU enK+tD5/wIV2HO7KKavoZPtnZpBg5YLIOXSE6JmdOkHGCaMPagTDfZV9c Pwv8sqWuPCWA0klJf5QYRvgvSQ7xXpLpCoLvzgvXGWXf0iCzISORLQPPF 380CKbKP7BilJVXxJPcJoqzYgHtdBicyzt8CPVHOTB1d/WBoLpqysdLte kFT7rHc0AgCgmySjB1VMnl6QXnEpL6kWE8Pk43XG3U+IhpFGY6jyFaogV 6QhdvYm3ZIUn0CUnKmW99FrIyFhuIq7ZzLTahqHhvKtyQ7jZDdd9es6JO g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="198074189" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:18 +0800 IronPort-SDR: Kkhkm+0vuDdw6WWDAjJrYGAMUrfrofg+k+Jue8OtTALwUhspjrLXfLRdiZ7B7xoBF7BHa3ne22 tkFAYzOtLfUG4QTUg+GnbqFk4fBLoWBDL1oGXoeW7Ia2nyE/rJAb24hrUSmGUjmuT8Y9Y6jd4b 0nDjWHIms51ydN6iEdIC8CribboS2frULd5QMj9K7mGdzuNyLyEOmg2vDlJ0+o+h4Ka5KhpXYc JqhOIqxb9xNgCqCTYNtuiVHl0f5zINfPINJyc1jEVNcCJp2aSG4G4n2OZ6VD3BTtnN2Vm5CJ8G mpcbY+OPOHC+2gi8sNcF6Mmy Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:57 -0800 IronPort-SDR: RuP6VkkNxGYXYc0DTZVFbiZwhNFSSsK0dNJNM1o5ef9ECIoUoPWYtKaEnOnG3sguOIaDWbqwLy 3IhKGHzw1FUA/vkTiHSrHpL/c2smnbfPKTFd1ZVRfLTnQfB0g4G9G0RBc6GxT8BKZGLhf3PGni FQTWGW93iV3yr/yyCxnwtkenyTKIksTh8QXl5CThpzJ99HbeZI5+cYgPzHZ3SAEIpqBufodEQr NxoPN8TqsOKaeyaIwbpXxNhKzhudJsBCaRmyu24Xh/ZhIRuV8cfVkfGy1/O0BMhg/GO1IxjAiN EgY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:19 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzB5ysPz1SVp1 for ; Thu, 17 Feb 2022 19:15:18 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154118; x=1647746119; bh=g7EBBD7qLhE1YqM6dd gx33476kZlCQryWeE4NMPtD5c=; b=XsPdkwrqnMV3t1CeBppH5T00WGB650EuV8 Jd2qNJTvfWR88jpSBrNwvVE/sw6sfIIGa1ta14OE4WeM5GdMALtJr+oLMgvl85F7 xAQqxEt2c6fZcB2bd/KhlSOv8bPkeYOUQVs9TOwOmLltYSCyblKOYfWdChD11Yyj Blzr9Z7+e/knw8M4WkJMQtwmQKdr85hGQzcV0Abm5SuXG9JgalHAnGxeGoXVMcOh lu/JvXx4vj2DDCoiizdUjoqBRoTWjeFjCDQcqNZ2WoPRFuCi63STTBzCZoqP3JZ1 AncJXl+pcHSM3U+SHBQiSPtMeEjQN26kaqKe5LXVClePW0xuTckw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 268xDrJ4qa-F for ; Thu, 17 Feb 2022 19:15:18 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0Gz91hYzz1SVnx; Thu, 17 Feb 2022 19:15:16 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 21/31] scsi: pm8001: Fix tag leaks on error Date: Fri, 18 Feb 2022 12:14:35 +0900 Message-Id: <20220218031445.548767-22-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm8001_chip_set_dev_state_req(), pm8001_chip_fw_flash_update_req(), pm80xx_chip_phy_ctl_req() and pm8001_chip_reg_dev_req() add missing calls to pm8001_tag_free() to free the allocated tag when pm8001_mpi_build_cmd() fails. Similarly, in pm8001_exec_internal_task_abort(), if the chip ->task_abort method fails, the tag allocated for the abort request task must be freed. Add the missing call to pm8001_tag_free(). Signed-off-by: Damien Le Moal Reviewed-by: John Garry --- drivers/scsi/pm8001/pm8001_hwi.c | 9 +++++++++ drivers/scsi/pm8001/pm8001_sas.c | 2 +- drivers/scsi/pm8001/pm80xx_hwi.c | 9 +++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index cc96e58454c8..431fc9160637 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4458,6 +4458,9 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, SAS_ADDR_SIZE); rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } @@ -4870,6 +4873,9 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, ccb->ccb_tag = tag; rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, tag); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } @@ -4974,6 +4980,9 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, payload.nds = cpu_to_le32(state); rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index d0f5feb4f2d3..3e186cd6792d 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -843,10 +843,10 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, res = PM8001_CHIP_DISP->task_abort(pm8001_ha, pm8001_dev, flag, task_tag, ccb_tag); - if (res) { del_timer(&task->slow_task->timer); pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n"); + pm8001_tag_free(pm8001_ha, ccb_tag); goto ex_err; } wait_for_completion(&task->slow_task->completion); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index cc46e2013eeb..4419fdb0db78 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4915,8 +4915,13 @@ static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, payload.tag = cpu_to_le32(tag); payload.phyop_phyid = cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF)); - return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + + return rc; } static u32 pm80xx_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha) From patchwork Fri Feb 18 03:14:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63ACAC433EF for ; Fri, 18 Feb 2022 03:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231981AbiBRDP4 (ORCPT ); Thu, 17 Feb 2022 22:15:56 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231942AbiBRDPn (ORCPT ); Thu, 17 Feb 2022 22:15:43 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 954E666F8B for ; Thu, 17 Feb 2022 19:15:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154119; x=1676690119; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=goRnkkeqxKTUbei8qtQZ6iOM0R/J7gkprYGYQUTWsug=; b=ZQjvWR5tRCNMyFrukWnCsIPO6+dwVewrX/y9/kl0xXgB9Yv0pBr+U1ml wYFG/Z2eH7fQTQULYLlfYzvimcJbmC4dWDxcTU6v2zlKwbd7BIFLkwtHF K8a1pGfw/7a+cecXWtDNy/WJXpFyjDKn5PiabG6P7pFqLnI+gc6ExEHEW hBP2fCO6l678XrOAI0Lf6o0k3YGdtZ+Nc1+6dKnoQ6QIhhCsEMxmtEXg3 DGo3M3z691n1H+IBvALXC0km+d3yASivaUrt9VznABwA5qp7n/GH4HBS2 7+7hsWLrCzuZXdYs9WBgAOjdC0vrSj6yXyNhsl242GaIpMRz17av6lXjg Q==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="198074193" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:19 +0800 IronPort-SDR: UMZD1WRXamDQU/s/4clc8hz/n1rH4ZgFDAq7pCmURiDfFOxJynyS/SGLdiQyBXYSe8WB76uc+X 9LPHUFTb2p8zhBf36+ASToKtSM9bvS38RXlt2lqcwhsowC7J3HmrHgM5OssVIfFzkohZiICz+9 Vpw/H+HyK3vkyFiWIrVwqUzqB2ewlb0gRzFd0sPCX4/P8j5RerKEIAby4KowWI+3SQf0EF2oGv SksQrM5xZ+YRWVXVwsFy0LDKIODNKdjJSZmMFWJeW0BQEgkSpIwCacLqvhHlrMk6YGv9OgpzKc LsqsfmgE+QRcWJf2Hev/aiwV Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:58 -0800 IronPort-SDR: /P9BknsobdSmZH0tD/o7+VPmtoXKgBGpv/l4XM5gFHr3okW3GJ3pY9uj0xoZb9zSKJNn78xcVK p21cIXCOQ9KiCF7i9POGq/QoM0ywcPyHiW8gdafFEicZdBzxRBMNhweOmEXcbnjspffqxoDmtZ u3jjrxDwdN02li1TWF3inFlXNz+TADXU2QHIMLuMb0mNU6QiOTgPWmpJd3uxwWB5BCKQuwFr3f Ae8Rae0+TofiOLcHXWNWkw588geK977UhI3tvs9sGQicI3kWBBNlCw9J8xP/odd7b4turiaJrD 3TA= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:20 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzD1GlRz1SVp3 for ; Thu, 17 Feb 2022 19:15:20 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154119; x=1647746120; bh=goRnkkeqxKTUbei8qt QZ6iOM0R/J7gkprYGYQUTWsug=; b=hriRh8hi/YK5tQhS8yLfLU/iso9VaSPpp4 J7DT5OmlN3xgLnkHn56LeUPSuus4Xtg2GtAgEIhnQw3n8gczVUgTvfjTogLSIA8j Xk0rF/rHZ1YBC2cK0WOWA4XW1Ma5FhqNJMpWjjlD4/ttuNj+1zTBwqwc2p38TSN9 f2rd4Yw1X8m8IkqtkVrkaKw+ApeGmGPjBKLLnCyrLGWo8qmewuSLf/X4HM4oSRMz Q8J1B3GpBp23Dk2qr09zuhuytKMhtsmJETTmy7JesHBlFH3SZ4ySCLsu5N3XpgF9 NOIFumq5a8Q3ZsylwVi7ZtdNiZkpXyBnUXmzfqjHKqUr0aMVS8iQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6aFrIxK6SVeQ for ; Thu, 17 Feb 2022 19:15:19 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzB4qkjz1Rwrw; Thu, 17 Feb 2022 19:15:18 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 22/31] scsi: pm8001: fix memory leak in pm8001_chip_fw_flash_update_req() Date: Fri, 18 Feb 2022 12:14:36 +0900 Message-Id: <20220218031445.548767-23-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm8001_chip_fw_flash_update_build(), if pm8001_chip_fw_flash_update_build() fails, the struct fw_control_ex allocated must be freed. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 431fc9160637..41077c84eec9 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4873,8 +4873,10 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, ccb->ccb_tag = tag; rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, tag); - if (rc) + if (rc) { + kfree(fw_control_context); pm8001_tag_free(pm8001_ha, tag); + } return rc; } From patchwork Fri Feb 18 03:14:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC5B1C433F5 for ; Fri, 18 Feb 2022 03:15:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231980AbiBRDPy (ORCPT ); Thu, 17 Feb 2022 22:15:54 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231947AbiBRDPn (ORCPT ); Thu, 17 Feb 2022 22:15:43 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1234770841 for ; Thu, 17 Feb 2022 19:15:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154121; x=1676690121; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G72px9zteVEyav9xzEEG21fzNpn0jSxqg6FF7e4Vh/0=; b=rU+wzXRIvPDQU02/q68DTLVJ2ZJ43T8uYB3sS82N6UhLIEQk5Mk8gbIg 1VT9qsHWMEbXNv+rJPVYlVl2AF78Dh5Oj8BenDhcFSfPhyC8qzDEX4JNG 1tOHNWnIP2VgrNB2gSLf8vfiQOLVYXHwxLIOU8TGhAI0x404/ff2JF6C5 8s+mZZ7y3jKXmmJwTk6pukX/++6Tn8amzgbbSdzyfjaKB/SmZFUEi9pn5 yT5bJcTW0yQ0wWsULWmIuZwNpOTWcPNmsnrbDQguUTVSpEgwwdjAiTh6h b6AQeDv9mMQzFp1nYuzhwkQDbGHCLIGk15GyTdx+R2XQDgmrCTnejzXWJ A==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="198074196" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:20 +0800 IronPort-SDR: aI7Mz7KhwDSmGfcCrwKyJcEnhOTiPwdfBfqI/R+n3kG0GyRTSHixewiuaL4cmhIMgY69ryrNQk GdlHaP+fggtR/FAzU4SxTkIDXVtwb1hzdx2FGeL1MoZahHAIsQTj30yz+iEzmF3ZbSI9cEQipt BrbFm1gd6AwNEsOY9eprO5S4RL+QVAR6NiLme4/HbIFLMZMCQjyq0FIe5V6Q5HllAI6e7Fe5GR qd3WwgTQpPuFVcHrt/uxPEphsNk/Utr02ZrTlVz/uyPkYiMftp99yR3ecj3VYvp1e4MpilhIoy /+gAAOpBmqbvbI77x6ItnnYc Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:46:59 -0800 IronPort-SDR: uLklHmgwEaF8tBN3auOHR4MVZL+V87EEWho4Gtf4ymQxEWywmJV9/68vwR3vSP6OFcptpJhbMF j/DLY9gXq6lhYbLZAxwFmi9+IbX0GpyxWJkXt0SYdTRZ/SoqmGAlmjmLLS0+p12SjUy8yDNFGN I2mX3DAXAlFb/QFCuch0TyI65IC5CHfCxoZtPj8PbY36D83NxeOQAKq1eTBnm1MM6O/jXO1k6U qIiJP0mltybLUDJndpRS9Wd0Kw7Ae5HCA0b+YpBWNUQH5r9d7Jq1XPtbsAqK7xS10aagF2Wn+9 Zc4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:22 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzF4F2Fz1SVp5 for ; Thu, 17 Feb 2022 19:15:21 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154121; x=1647746122; bh=G72px9zteVEyav9xzE EG21fzNpn0jSxqg6FF7e4Vh/0=; b=iY8Ia2N8CSjmc9igHRfipGnP8f0LHn54OG +VbyjNXFvLUitPgH4j0dfqqpZpSBIh1FF0GLFxAEWMUk/ZqvdcUxPwe4dzhlRmax fPlllRVPJDj6ujGMloR3msH9G9V5kwRlDGGhLEezb4tuVYmX27Amk3mLXyzU7sG4 Umeg9ntHoGxSIx5AA1dUqwLwU4IfTJYVTR6zA72Ejncg90GijdWv7vTg+U3Xrwuj llV/slOHygZE1WI1SHnCoYnXWt/gwtQFWgaa98ogqWqiCCOsp/5uuJQ2P1Tf91Di +EVt9fDS/AJzd5Fe5nftcrzHip5uOWxQvaTLMNS1tM9vK272gsQQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Pg1nhreGmMtu for ; Thu, 17 Feb 2022 19:15:21 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzD0Dszz1SHwl; Thu, 17 Feb 2022 19:15:19 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 23/31] scsi: libsas: Simplify sas_ata_qc_issue() detection of NCQ commands Date: Fri, 18 Feb 2022 12:14:37 +0900 Message-Id: <20220218031445.548767-24-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect if a command is NCQ, there is no need to test all possible NCQ command codes. Instead, use ata_is_ncq() to test the command protocol. Signed-off-by: Damien Le Moal --- drivers/scsi/libsas/sas_ata.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 50f779088b6e..fcfc8fd4b14f 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -181,14 +181,9 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) task->task_proto = SAS_PROTOCOL_STP; task->task_done = sas_ata_task_done; - if (qc->tf.command == ATA_CMD_FPDMA_WRITE || - qc->tf.command == ATA_CMD_FPDMA_READ || - qc->tf.command == ATA_CMD_FPDMA_RECV || - qc->tf.command == ATA_CMD_FPDMA_SEND || - qc->tf.command == ATA_CMD_NCQ_NON_DATA) { - /* Need to zero out the tag libata assigned us */ + /* For NCQ commands, zero out the tag libata assigned us */ + if (ata_is_ncq(qc->tf.protocol)) qc->tf.nsect = 0; - } ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, (u8 *)&task->ata_task.fis); task->uldd_task = qc; From patchwork Fri Feb 18 03:14:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544212 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02D0FC433EF for ; Fri, 18 Feb 2022 03:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231910AbiBRDRi (ORCPT ); Thu, 17 Feb 2022 22:17:38 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbiBRDPo (ORCPT ); Thu, 17 Feb 2022 22:15:44 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A6111BBF70 for ; Thu, 17 Feb 2022 19:15:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154122; x=1676690122; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tlHIdFApo5g6hgALfBkITWbmb7bVUTixO9xcTWj6QPw=; b=qNn514jwNMBFovOJbDmOYdQs6zBCT7pgQNKYKbdtVuq/lD1O3l337gU7 WmS+sHiDX1yHPi+kwkZdRjRgv3zka1hYCXpubTdbfpgzzfXFOQxfbsLL+ mbseIdnJUF077ebzgbEjmdvRZicQcBbRAk9l8M2qJeYQUB2tQQDebuDqW UpyV1t9BetCc6Q+um8iWNaL1l3/UZcb4hJD/ycIDSd2cb0JJkBcsDkJYX RO63H6zjgvbzDZAbc1ErKCeAwZB602Uwxq/6vAkBpGWQo9efovfoRHtof B37odRXWfLVP+3OarqfTGuYpVd89Yhoc0cWMtPS0ziuXJLvMbY0PNYfd5 Q==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="198074198" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:22 +0800 IronPort-SDR: m8Z5yXsRTpymrC/iNrpVRaMwSP8a3rb3nf6c9bXHunkRyZ3qysQS5wj0XcL6oDld+k9NMZ7sRW 9OmrmZR5bE8yzbDaTZZ+yD47Q/S0tysHAVi511JLtRper5ZJvRHRa+hYrh/lyqQGai+NcewyMZ 5wQwEszqaDfE56NC08bX+bN82zWU+7qgcc2RHlgfP4JN7YBYH5BgyYeJM34jKIr8t4YgIdWABF coxlkSAVkk+WFP0KHhgUCn3DqMrSFS2lgsqDcEHIjhxN9Z3co9lN5Rq7c8ga1/0PMnSzVPitip d2QkbyeBITDDSN7dH4QYZ5f2 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:47:01 -0800 IronPort-SDR: gcCLiBeuOlUDHtUUt5h31/R2Svtc+XLEcvGHlU7MVPnsg6xW9745OCboLDCVq/kypOQ0hERLDP X9Jjfh92SDZzkT1a7JBMHTPEqhpdyvgpvTcs+pgr8eWOkkpNgsvPtwFd2eUX10LCNkxEj3ZUkG MnlUUaSPx8mLJ2PBkXFlVDKkPwS5C1Wlkr6wApNCmFQAvrpSffITxrM3TO4z444eqL6TzPP9/8 Sl2Zu48HWU32EOxwZF31rHVSpfP5ZIDfFrTHXOkbpugt0HxNNkKyfztH65Xsv2yo9qLrgIuQOj /PE= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:23 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzH08FDz1SVp4 for ; Thu, 17 Feb 2022 19:15:23 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154122; x=1647746123; bh=tlHIdFApo5g6hgALfB kITWbmb7bVUTixO9xcTWj6QPw=; b=O+Dki+ZZDFDu05JMo/YJq3KS+lenmuQvzA praSPXzIf3qCEDB1cOURhwAo3h+SUFU441zFy/RrEMO+fhD7C+KM7uNMJRSlS1ma eFbpkr6NJ1T4Z5+dlitrIY0ZevlxTTUf49c/4PTLAaYxdZbzvmGexouHP43tklbn 69oTYql1mUazNkTD9/HiRYlQs1YT+K8Uwj0s42MVZcLlBYaxBjeIwYQ+CE75IMoK NMaW+O+vPrrxVqEPzjfVpgZqpTWSlFlZBtNqTz/iutg3aryFuwWqrIRqvR6C9itP EkZfAXpn2I4QOqHuEaYRQoe8mpdPCdszYF1cL4KO1tFHkCt/L62w== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Ja9cBsloVKHs for ; Thu, 17 Feb 2022 19:15:22 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzF2zh4z1Rwrw; Thu, 17 Feb 2022 19:15:21 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 24/31] scsi: pm8001: Cleanup pm8001_exec_internal_task_abort() Date: Fri, 18 Feb 2022 12:14:38 +0900 Message-Id: <20220218031445.548767-25-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace the goto statement in the for loop with "break" and remove the ex_err label. Also fix long lines, identation and blank lines to make the code more readable. Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_sas.c | 38 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 3e186cd6792d..98a25f158615 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -829,50 +829,54 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, task->task_proto = dev->tproto; task->task_done = pm8001_task_done; task->slow_task->timer.function = pm8001_tmf_timedout; - task->slow_task->timer.expires = jiffies + PM8001_TASK_TIMEOUT * HZ; + task->slow_task->timer.expires = + jiffies + PM8001_TASK_TIMEOUT * HZ; add_timer(&task->slow_task->timer); res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); if (res) - goto ex_err; + break; + ccb = &pm8001_ha->ccb_info[ccb_tag]; ccb->device = pm8001_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; ccb->n_elem = 0; - res = PM8001_CHIP_DISP->task_abort(pm8001_ha, - pm8001_dev, flag, task_tag, ccb_tag); + res = PM8001_CHIP_DISP->task_abort(pm8001_ha, pm8001_dev, flag, + task_tag, ccb_tag); if (res) { del_timer(&task->slow_task->timer); - pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n"); + pm8001_dbg(pm8001_ha, FAIL, + "Executing internal task failed\n"); pm8001_tag_free(pm8001_ha, ccb_tag); - goto ex_err; + break; } + wait_for_completion(&task->slow_task->completion); res = TMF_RESP_FUNC_FAILED; + /* Even TMF timed out, return direct. */ if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { pm8001_dbg(pm8001_ha, FAIL, "TMF task timeout.\n"); - goto ex_err; + break; } if (task->task_status.resp == SAS_TASK_COMPLETE && task->task_status.stat == SAS_SAM_STAT_GOOD) { res = TMF_RESP_FUNC_COMPLETE; break; - - } else { - pm8001_dbg(pm8001_ha, EH, - " Task to dev %016llx response: 0x%x status 0x%x\n", - SAS_ADDR(dev->sas_addr), - task->task_status.resp, - task->task_status.stat); - sas_free_task(task); - task = NULL; } + + pm8001_dbg(pm8001_ha, EH, + " Task to dev %016llx response: 0x%x status 0x%x\n", + SAS_ADDR(dev->sas_addr), + task->task_status.resp, + task->task_status.stat); + sas_free_task(task); + task = NULL; } -ex_err: + BUG_ON(retry == 3 && task != NULL); sas_free_task(task); return res; From patchwork Fri Feb 18 03:14:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C24AC433F5 for ; Fri, 18 Feb 2022 03:17:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbiBRDRh (ORCPT ); Thu, 17 Feb 2022 22:17:37 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbiBRDPo (ORCPT ); Thu, 17 Feb 2022 22:15:44 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD3801BBF72 for ; Thu, 17 Feb 2022 19:15:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154123; x=1676690123; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dsWEUSFRCeu5tdZvPF/qQ+3R67+FzF5PZKWqtJvVHGE=; b=Quu4N9cnA2mvj15T1Bo9cOQG0gcJ3e+wB9jB5/iIeGYLvCgfcAD9yaKZ o0T2WLs4lg37BUei7MmluEPOAme1ZVGZb5Y7Vnrc/fGTCj6BUWLrbQpkJ Q1PlPBYUi6U66ongeMTkMC4t2m1jnt2MEd5sSrf0UBPpfV6mjBRTukBZ7 7mINNIE0pxJVao6JpOQ/EQCXk3YzXh0D0OHjhxNzZef7o7SiRBb8pMnpD uYcrC97eDM2tYGsv+3Tp/jOc9vjuPz7RP4Ur1zpt89y66FdWAYRJOfB75 nm7QG/5mBXhvjBj3gkSes3GhYrUyyBc/iYcwc5ms/GSp1VfzcqM6TFtxb w==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="198074200" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:23 +0800 IronPort-SDR: Sm1kUMbAd4iiMuCU2xL5HITMYogP5W62Q2VfcwjEfj16IeYcSV/RsHDwrRlpnWs/UzigqSxq3P t7DDPVv5PGqxF6Eah+77Me8Exo0zZqPoXtQMFU3WNsHFUHvjT9KWXMqhNCJsbT6UzdQYbj+HvY PRqj6jWcCd+qP3v57cvE946NYzF/ELHKcKhvOwslMnCZn6IFyX0XyO5kYL+st4WiIQf9FM5cV9 ns3qd0cukEWoIn7zhxaD/ClDC3RVyeIOFqw+eHCswS0cDmA4EzrycTGPIk38oK+mXPNthWwcZX KMQHdPeAMqxIZXmwYe3pgIys Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:47:02 -0800 IronPort-SDR: O0idZ4vzUt+SC6rh6wj2fPeJUJ5hTVzDpXy7IibTUEAUTVd8V1wpnEiaBnHwroOkQXp5/TCaHz KJkCnXXJyQnQLhNvMu+7it9aYTIpyOrxHz2uroPPQjeylI4h3/zLTtejl7CPBTRKR4DPZM3dxm uaaHmodp/ZByrr3vNk5P3sASTaattP5Kjp6pLL9R3Jfp6KMnY9Pckh/M/u/2MHa1qv2yIiynXa S1BRKXHqVdAR8s/ztsMtpRo/+RdcRRJ4uoAsKN1iaSxU1FBtjhpVmkaLyiLYJE//LiqTQUr3UN ofw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:24 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzJ2Sdpz1SVp3 for ; Thu, 17 Feb 2022 19:15:24 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154123; x=1647746124; bh=dsWEUSFRCeu5tdZvPF /qQ+3R67+FzF5PZKWqtJvVHGE=; b=C1npjBtvBIXPZvSJh+tCsEX5DhhN2weURT xbn31VYMxjeM2EFdGnam0zicv6rmrf5LCRyjY0LMOa84m89bqDg2oebGZUilKzMH v1MVkHqITTRrrOd9Zbj1iYIgq7Sw0J7zIFDoSHVL7EnTqylQO/Txu1F4ZPlgeGUa cTQXfNeQmnNbOYSyPhJ5QJTYlgcoS9DqA+ooJFvJHOtv3Cz9ngxHED+S8BCao0Y6 eUGrpzj2qVq/Ugw+GDpjY+6yDLLE38j8dMnVEt/fsByPV0ATeZJQ7hMn4/i8DzIk /em5Z1MNiUYi+mYkvqajK/TtRcllVBuHnkU8/2kDPZfkz3T5DX7g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Lz2QO-fmeeaF for ; Thu, 17 Feb 2022 19:15:23 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzG5yzBz1SHwl; Thu, 17 Feb 2022 19:15:22 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 25/31] scsi: pm8001: Simplify pm8001_get_ncq_tag() Date: Fri, 18 Feb 2022 12:14:39 +0900 Message-Id: <20220218031445.548767-26-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect if a command is NCQ, there is no need to test all possible NCQ command codes. Instead, use ata_is_ncq() to test the command protocol. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_sas.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 98a25f158615..177a9d194d18 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -304,16 +304,12 @@ static int pm8001_task_prep_smp(struct pm8001_hba_info *pm8001_ha, u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag) { struct ata_queued_cmd *qc = task->uldd_task; - if (qc) { - if (qc->tf.command == ATA_CMD_FPDMA_WRITE || - qc->tf.command == ATA_CMD_FPDMA_READ || - qc->tf.command == ATA_CMD_FPDMA_RECV || - qc->tf.command == ATA_CMD_FPDMA_SEND || - qc->tf.command == ATA_CMD_NCQ_NON_DATA) { - *tag = qc->tag; - return 1; - } + + if (qc && ata_is_ncq(qc->tf.protocol)) { + *tag = qc->tag; + return 1; } + return 0; } From patchwork Fri Feb 18 03:14:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C8C9C433F5 for ; Fri, 18 Feb 2022 03:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231917AbiBRDRk (ORCPT ); Thu, 17 Feb 2022 22:17:40 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231965AbiBRDPo (ORCPT ); Thu, 17 Feb 2022 22:15:44 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44192B65C5 for ; Thu, 17 Feb 2022 19:15:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154126; x=1676690126; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eMq2tZBb3PyEQUQJ8laagTpLdN0cr45nZ8MsOvKTkkM=; b=CJlis0ECqjhIsdlW9eeNCYvv4aU/teDf81YZ/q5+69hx8iByi4Innl+D JRlx56ZuMEH7kpOEoCK8HTJzMkxIwunwQc9t6XgfctyKEWUwDwF5/feRP XD1kWgxOPgeUaIBxl7bZkZeyp9SGp9rOM4dPjOQaTVg4vcaOwgXV3DPiQ GzLxHxCoOwbz6kpcQae/obBYcTaCKWDfEfjJ5k7jQJVihguWulFeMnkPi 12Q3jjtFVGGt3qSR9xClrAQ6DhyY/S4QvQw8ND3nfTH+JGQx0g4I9iubd NJytSUkH8Vu2H/MerXuD1NdIBY45LN7Jj349S179ChE6uVeeakn0DLTxm w==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="198074205" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:26 +0800 IronPort-SDR: mpU4N+rn63klQmb8OBEZC5dzGqSpNyDAL3KiV0GTJ21Bcftza4bfLfKfqznTE2tliPbpr5EVxa 62p1JqbXjjzErOcqTzcJiOLcEsaZhIMfIw5ysceIeNuOtWcUr3JquQwMlSFT9/fpKrxZ6WMfqt 37lFnXtX/vr58aRLm3ywXW6LBJ+UAlvS3PuU3whpXYuqhc7u2UIp0DR58y1SJETLb0I1LlVaPC SxAQ13TNM1E4nswNrcptWiP33hdcl5LskVGz9mgsWZToSmPP2ziz8DWZw9HoZBIxLrqAdJoQbj Tc1NLdWgS+4sDalu7C7xDzrW Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:47:06 -0800 IronPort-SDR: xyYI9f8RLmkH/3g81y6n1p1KPcHM8L/fBuIKm7lDD4D/e/hOMxuf6PD29wJigkHYR6wl0+yNlp AU6+/IK+aJTMK4x8gzhKvJdGfoY3sU2ycPaFHTClPij3VrQTNmisIAYAfK1KE9sD82omoTXnQj lkLk3pErUMFQfz+F4EcMDl0BiKX3z02vR0g8pKOkXfNXKo1Gron3q3irtPvrqXWdtakPNNEBr/ VBixn9GzMeSkNHtg/j5op/AGs1/C9oYPNKSH7vgIASpi6SMZrKDCEfSfm0KNfcj3ELlAmxY4cg Dkg= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:28 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzM2phkz1SVp2 for ; Thu, 17 Feb 2022 19:15:27 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154125; x=1647746126; bh=eMq2tZBb3PyEQUQJ8l aagTpLdN0cr45nZ8MsOvKTkkM=; b=MX5k43FrMzNP26A89ji54AfQtq3Vb85mn2 gFkmS9qcoM8+I7rDjvu6eiA0Nj8mSra0z1uWriIuFj+mtG1qMTBfW51g92HUv3DB 7NpCH8RAE7gBqmq71edFTgMrxa8WH7wTq3bZIx20leGtjpGj+S1bEBFz9i33E779 eWEYqisE6j2YzhfeM4wfKKcvJYB5jjEiJkS92SV/EyqVEaZnAIh4tdZdX2lBwJO+ JzsSXSjfntwhXi9faJLvRxLONqByvBFm228wnXTsBKXE84JW9xrRpV2IWFNCSz08 0GRBYIt7kT0C+Dw+P3w3bno5ML4G8OBG082nJXCi8L2bQz6UpXbw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id PU96-9csxuSF for ; Thu, 17 Feb 2022 19:15:25 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzJ16hDz1Rwrw; Thu, 17 Feb 2022 19:15:24 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 26/31] scsi: pm8001: Introduce ccb alloc/free helpers Date: Fri, 18 Feb 2022 12:14:40 +0900 Message-Id: <20220218031445.548767-27-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Introduce the pm8001_ccb_alloc() and pm8001_ccb_free() helpers to replace the typical code patterns: res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); if (res) ... ccb = &pm8001_ha->ccb_info[ccb_tag]; ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; ccb->n_elem = 0; and ccb->task = NULL; ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); With the simpler function calls: ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); if (!ccb) ... and pm8001_ccb_free(pm8001_ha, ccb); The pm8001_ccb_alloc() helper ensures that all fields of the ccb info structure for the newly allocated tag are all initialized, except the buf_prd field. The pm8001_ccb_free() helper clears the initialized fields and the ccb tag to ensure that iteration over the adapter ccb_info array detects ccbs that are in use. All call site of the pm8001_tag_alloc() function that use a ccb info associated with an allocated tag are converted to use the new helpers. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 180 +++++++++++++------------------ drivers/scsi/pm8001/pm8001_sas.c | 46 ++++---- drivers/scsi/pm8001/pm8001_sas.h | 47 ++++++++ drivers/scsi/pm8001/pm80xx_hwi.c | 64 +++++------ 4 files changed, 166 insertions(+), 171 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 41077c84eec9..699fecc09267 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1710,7 +1710,7 @@ void pm8001_work_fn(struct work_struct *work) pm8001_dev->dcompletion = NULL; } complete(pm8001_ha->nvmd_completion); - pm8001_tag_free(pm8001_ha, ccb->ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); } } /* Deregister all the device ids */ @@ -1749,8 +1749,6 @@ int pm8001_handle_event(struct pm8001_hba_info *pm8001_ha, void *data, static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev) { - int res; - u32 ccb_tag; struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct task_abort_req task_abort; @@ -1771,32 +1769,25 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, task->task_done = pm8001_task_done; - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) { + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); + if (!ccb) { sas_free_task(task); return; } - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_ha_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&task_abort, 0, sizeof(task_abort)); task_abort.abort_all = cpu_to_le32(1); task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); - task_abort.tag = cpu_to_le32(ccb_tag); + task_abort.tag = cpu_to_le32(ccb->ccb_tag); ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, sizeof(task_abort), 0); if (ret) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); } - } static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, @@ -1804,7 +1795,6 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, { struct sata_start_req sata_cmd; int res; - u32 ccb_tag; struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct host_to_dev_fis fis; @@ -1820,20 +1810,13 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, } task->task_done = pm8001_task_done; - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) { - sas_free_task(task); - pm8001_dbg(pm8001_ha, FAIL, "cannot allocate tag !!!\n"); - return; - } - - /* allocate domain device by ourselves as libsas - * is not going to provide any - */ + /* + * Allocate domain device by ourselves as libsas is not going to + * provide any. + */ dev = kzalloc(sizeof(struct domain_device), GFP_ATOMIC); if (!dev) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); pm8001_dbg(pm8001_ha, FAIL, "Domain device cannot be allocated\n"); return; @@ -1841,11 +1824,13 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, task->dev = dev; task->dev->lldd_dev = pm8001_ha_dev; - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_ha_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); + if (!ccb) { + sas_free_task(task); + kfree(dev); + return; + } + pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; @@ -1860,7 +1845,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, fis.lbal = 0x10; fis.sector_count = 0x1; - sata_cmd.tag = cpu_to_le32(ccb_tag); + sata_cmd.tag = cpu_to_le32(ccb->ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); sata_cmd.ncqtag_atap_dir_m = cpu_to_le32((0x1 << 7) | (0x5 << 9)); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); @@ -1869,7 +1854,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, sizeof(sata_cmd), 0); if (res) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); kfree(dev); } } @@ -3038,12 +3023,12 @@ void pm8001_mpi_set_dev_state_resp(struct pm8001_hba_info *pm8001_ha, u32 device_id = le32_to_cpu(pPayload->device_id); u8 pds = le32_to_cpu(pPayload->pds_nds) & PDS_BITS; u8 nds = le32_to_cpu(pPayload->pds_nds) & NDS_BITS; - pm8001_dbg(pm8001_ha, MSG, "Set device id = 0x%x state from 0x%x to 0x%x status = 0x%x!\n", + + pm8001_dbg(pm8001_ha, MSG, + "Set device id = 0x%x state from 0x%x to 0x%x status = 0x%x!\n", device_id, pds, nds, status); complete(pm8001_dev->setds_completion); - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) @@ -3053,15 +3038,14 @@ void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) u32 tag = le32_to_cpu(pPayload->tag); struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[tag]; u32 dlen_status = le32_to_cpu(pPayload->dlen_status); + complete(pm8001_ha->nvmd_completion); pm8001_dbg(pm8001_ha, MSG, "Set nvm data complete!\n"); if ((dlen_status & NVMD_STAT) != 0) { pm8001_dbg(pm8001_ha, FAIL, "Set nvm data error %x\n", dlen_status); } - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } void @@ -3086,9 +3070,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) /* We should free tag during failure also, the tag is not being * freed by requesting path anywhere. */ - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); return; } if (ir_tds_bn_dps_das_nvm & IPMode) { @@ -3132,9 +3114,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) */ complete(pm8001_ha->nvmd_completion); pm8001_dbg(pm8001_ha, MSG, "Get nvmd data complete!\n"); - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha, void *piomb) @@ -3545,9 +3525,7 @@ int pm8001_mpi_reg_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) break; } complete(pm8001_dev->dcompletion); - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, htag); + pm8001_ccb_free(pm8001_ha, ccb); return 0; } @@ -3580,6 +3558,7 @@ int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info *pm8001_ha, (struct fw_flash_Update_resp *)(piomb + 4); u32 tag = le32_to_cpu(ppayload->tag); struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[tag]; + status = le32_to_cpu(ppayload->status); switch (status) { case FLASH_UPDATE_COMPLETE_PENDING_REBOOT: @@ -3617,9 +3596,7 @@ int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info *pm8001_ha, break; } kfree(ccb->fw_control_context); - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); complete(pm8001_ha->nvmd_completion); return 0; } @@ -4412,7 +4389,7 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, u32 stp_sspsmp_sata = 0x4; struct inbound_queue_table *circularQ; u32 linkrate, phy_id; - int rc, tag = 0xdeadbeef; + int rc; struct pm8001_ccb_info *ccb; u8 retryFlag = 0x1; u16 firstBurstSize = 0; @@ -4423,13 +4400,11 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) - return rc; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->device = pm8001_dev; - ccb->ccb_tag = tag; - payload.tag = cpu_to_le32(tag); + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); + if (!ccb) + return -SAS_QUEUE_FULL; + + payload.tag = cpu_to_le32(ccb->ccb_tag); if (flag == 1) stp_sspsmp_sata = 0x02; /*direct attached sata */ else { @@ -4459,7 +4434,7 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); if (rc) - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); return rc; } @@ -4624,7 +4599,6 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, u32 opc = OPC_INB_GET_NVMD_DATA; u32 nvmd_type; int rc; - u32 tag; struct pm8001_ccb_info *ccb; struct inbound_queue_table *circularQ; struct get_nvm_data_req nvmd_req; @@ -4639,15 +4613,15 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, fw_control_context->len = ioctl_payload->rd_length; circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&nvmd_req, 0, sizeof(nvmd_req)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) { + + ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); + if (!ccb) { kfree(fw_control_context); - return rc; + return -SAS_QUEUE_FULL; } - ccb = &pm8001_ha->ccb_info[tag]; - ccb->ccb_tag = tag; ccb->fw_control_context = fw_control_context; - nvmd_req.tag = cpu_to_le32(tag); + + nvmd_req.tag = cpu_to_le32(ccb->ccb_tag); switch (nvmd_type) { case TWI_DEVICE: { @@ -4708,7 +4682,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, sizeof(nvmd_req), 0); if (rc) { kfree(fw_control_context); - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } return rc; } @@ -4719,7 +4693,6 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, u32 opc = OPC_INB_SET_NVMD_DATA; u32 nvmd_type; int rc; - u32 tag; struct pm8001_ccb_info *ccb; struct inbound_queue_table *circularQ; struct set_nvm_data_req nvmd_req; @@ -4735,15 +4708,15 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, &ioctl_payload->func_specific, ioctl_payload->wr_length); memset(&nvmd_req, 0, sizeof(nvmd_req)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) { + + ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); + if (!ccb) { kfree(fw_control_context); - return -EBUSY; + return -SAS_QUEUE_FULL; } - ccb = &pm8001_ha->ccb_info[tag]; ccb->fw_control_context = fw_control_context; - ccb->ccb_tag = tag; - nvmd_req.tag = cpu_to_le32(tag); + + nvmd_req.tag = cpu_to_le32(ccb->ccb_tag); switch (nvmd_type) { case TWI_DEVICE: { u32 twi_addr, twi_page_size; @@ -4793,7 +4766,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, sizeof(nvmd_req), 0); if (rc) { kfree(fw_control_context); - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } return rc; } @@ -4839,7 +4812,6 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, struct fw_control_info *fw_control; struct fw_control_ex *fw_control_context; int rc; - u32 tag; struct pm8001_ccb_info *ccb; void *buffer = pm8001_ha->memoryMap.region[FW_FLASH].virt_ptr; dma_addr_t phys_addr = pm8001_ha->memoryMap.region[FW_FLASH].phys_addr; @@ -4863,19 +4835,19 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, fw_control_context->virtAddr = buffer; fw_control_context->phys_addr = phys_addr; fw_control_context->len = fw_control->len; - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) { + + ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); + if (!ccb) { kfree(fw_control_context); - return -EBUSY; + return -SAS_QUEUE_FULL; } - ccb = &pm8001_ha->ccb_info[tag]; ccb->fw_control_context = fw_control_context; - ccb->ccb_tag = tag; + rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, - tag); + ccb->ccb_tag); if (rc) { kfree(fw_control_context); - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } return rc; @@ -4967,26 +4939,25 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, struct inbound_queue_table *circularQ; struct pm8001_ccb_info *ccb; int rc; - u32 tag; u32 opc = OPC_INB_SET_DEVICE_STATE; + memset(&payload, 0, sizeof(payload)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) - return -1; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->ccb_tag = tag; - ccb->device = pm8001_dev; + + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); + if (!ccb) + return -SAS_QUEUE_FULL; + circularQ = &pm8001_ha->inbnd_q_tbl[0]; - payload.tag = cpu_to_le32(tag); + payload.tag = cpu_to_le32(ccb->ccb_tag); payload.device_id = cpu_to_le32(pm8001_dev->device_id); payload.nds = cpu_to_le32(state); + rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); if (rc) - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); return rc; - } static int @@ -4996,25 +4967,26 @@ pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha) struct inbound_queue_table *circularQ; struct pm8001_ccb_info *ccb; int rc; - u32 tag; u32 opc = OPC_INB_SAS_RE_INITIALIZE; + memset(&payload, 0, sizeof(payload)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) - return -ENOMEM; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->ccb_tag = tag; + + ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); + if (!ccb) + return -SAS_QUEUE_FULL; + circularQ = &pm8001_ha->inbnd_q_tbl[0]; - payload.tag = cpu_to_le32(tag); + payload.tag = cpu_to_le32(ccb->ccb_tag); payload.SSAHOLT = cpu_to_le32(0xd << 25); payload.sata_hol_tmo = cpu_to_le32(80); payload.open_reject_cmdretries_data_retries = cpu_to_le32(0xff00ff); + rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); if (rc) - pm8001_tag_free(pm8001_ha, tag); - return rc; + pm8001_ccb_free(pm8001_ha, ccb); + return rc; } const struct pm8001_dispatch pm8001_8001_dispatch = { diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 177a9d194d18..6c6138effab1 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -74,7 +74,7 @@ void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag) * @pm8001_ha: our hba struct * @tag_out: the found empty tag . */ -inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) +int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) { unsigned int tag; void *bitmap = pm8001_ha->tags; @@ -382,7 +382,7 @@ static int pm8001_task_exec(struct sas_task *task, struct pm8001_port *port = NULL; struct sas_task *t = task; struct pm8001_ccb_info *ccb; - u32 tag = 0xdeadbeef, rc = 0, n_elem = 0; + u32 rc = 0, n_elem = 0; unsigned long flags = 0; enum sas_protocol task_proto = t->task_proto; @@ -426,10 +426,12 @@ static int pm8001_task_exec(struct sas_task *task, continue; } } - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) + + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, t); + if (!ccb) { + rc = -SAS_QUEUE_FULL; goto err_out; - ccb = &pm8001_ha->ccb_info[tag]; + } if (!sas_protocol_ata(task_proto)) { if (t->num_scatter) { @@ -439,7 +441,7 @@ static int pm8001_task_exec(struct sas_task *task, t->data_dir); if (!n_elem) { rc = -ENOMEM; - goto err_out_tag; + goto err_out_ccb; } } } else { @@ -448,9 +450,7 @@ static int pm8001_task_exec(struct sas_task *task, t->lldd_task = ccb; ccb->n_elem = n_elem; - ccb->ccb_tag = tag; - ccb->task = t; - ccb->device = pm8001_dev; + switch (task_proto) { case SAS_PROTOCOL_SMP: atomic_inc(&pm8001_dev->running_req); @@ -479,15 +479,15 @@ static int pm8001_task_exec(struct sas_task *task, if (rc) { pm8001_dbg(pm8001_ha, IO, "rc is %x\n", rc); atomic_dec(&pm8001_dev->running_req); - goto err_out_tag; + goto err_out_ccb; } /* TODO: select normal or high priority */ } while (0); rc = 0; goto out_done; -err_out_tag: - pm8001_tag_free(pm8001_ha, tag); +err_out_ccb: + pm8001_ccb_free(pm8001_ha, ccb); err_out: dev_printk(KERN_ERR, pm8001_ha->dev, "pm8001 exec failed[%d]!\n", rc); if (!sas_protocol_ata(task_proto)) @@ -558,10 +558,7 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, } task->lldd_task = NULL; - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - ccb->open_retry = 0; - pm8001_tag_free(pm8001_ha, ccb_idx); + pm8001_ccb_free(pm8001_ha, ccb); } /** @@ -812,7 +809,6 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, u32 task_tag) { int res, retry; - u32 ccb_tag; struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; @@ -829,23 +825,19 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, jiffies + PM8001_TASK_TIMEOUT * HZ; add_timer(&task->slow_task->timer); - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, task); + if (!ccb) { + res = -SAS_QUEUE_FULL; break; - - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; + } res = PM8001_CHIP_DISP->task_abort(pm8001_ha, pm8001_dev, flag, - task_tag, ccb_tag); + task_tag, ccb->ccb_tag); if (res) { del_timer(&task->slow_task->timer); pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n"); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); break; } diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 1791cdf30276..824ada7f6a3f 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -740,6 +740,53 @@ extern const struct attribute_group *pm8001_host_groups[]; #define PM8001_INVALID_TAG ((u32)-1) +/* + * Allocate a new tag and return the corresponding ccb after initializing it. + */ +static inline struct pm8001_ccb_info * +pm8001_ccb_alloc(struct pm8001_hba_info *pm8001_ha, + struct pm8001_device *dev, struct sas_task *task) +{ + struct pm8001_ccb_info *ccb; + u32 tag; + + if (pm8001_tag_alloc(pm8001_ha, &tag)) { + pm8001_dbg(pm8001_ha, FAIL, "Failed to allocate a tag\n"); + return NULL; + } + + ccb = &pm8001_ha->ccb_info[tag]; + ccb->task = task; + ccb->n_elem = 0; + ccb->ccb_tag = tag; + ccb->device = dev; + ccb->fw_control_context = NULL; + ccb->open_retry = 0; + + return ccb; +} + +/* + * Free the tag of an initialized ccb. + */ +static inline void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, + struct pm8001_ccb_info *ccb) +{ + u32 tag = ccb->ccb_tag; + + /* + * Cleanup the ccb to make sure that a manual scan of the adapter + * ccb_info array can detect ccb's that are in use. + * C.f. pm8001_open_reject_retry() + */ + ccb->task = NULL; + ccb->ccb_tag = PM8001_INVALID_TAG; + ccb->device = NULL; + ccb->fw_control_context = NULL; + + pm8001_tag_free(pm8001_ha, tag); +} + static inline void pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, struct sas_task *task, struct pm8001_ccb_info *ccb, diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 4419fdb0db78..57ea933dab66 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1767,8 +1767,6 @@ pm80xx_chip_interrupt_disable(struct pm8001_hba_info *pm8001_ha, u8 vec) static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev) { - int res; - u32 ccb_tag; struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct task_abort_req task_abort; @@ -1790,31 +1788,25 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, task->task_done = pm8001_task_done; - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) { + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); + if (!ccb) { sas_free_task(task); return; } - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_ha_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&task_abort, 0, sizeof(task_abort)); task_abort.abort_all = cpu_to_le32(1); task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); - task_abort.tag = cpu_to_le32(ccb_tag); + task_abort.tag = cpu_to_le32(ccb->ccb_tag); ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, sizeof(task_abort), 0); pm8001_dbg(pm8001_ha, FAIL, "Executing abort task end\n"); if (ret) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); } } @@ -1823,7 +1815,6 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, { struct sata_start_req sata_cmd; int res; - u32 ccb_tag; struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct host_to_dev_fis fis; @@ -1839,20 +1830,13 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, } task->task_done = pm8001_task_done; - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) { - sas_free_task(task); - pm8001_dbg(pm8001_ha, FAIL, "cannot allocate tag !!!\n"); - return; - } - - /* allocate domain device by ourselves as libsas - * is not going to provide any - */ + /* + * Allocate domain device by ourselves as libsas is not going to + * provide any. + */ dev = kzalloc(sizeof(struct domain_device), GFP_ATOMIC); if (!dev) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); pm8001_dbg(pm8001_ha, FAIL, "Domain device cannot be allocated\n"); return; @@ -1861,11 +1845,13 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, task->dev = dev; task->dev->lldd_dev = pm8001_ha_dev; - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_ha_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); + if (!ccb) { + sas_free_task(task); + kfree(dev); + return; + } + pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; @@ -1880,7 +1866,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, fis.lbal = 0x10; fis.sector_count = 0x1; - sata_cmd.tag = cpu_to_le32(ccb_tag); + sata_cmd.tag = cpu_to_le32(ccb->ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); sata_cmd.ncqtag_atap_dir_m_dad = cpu_to_le32(((0x1 << 7) | (0x5 << 9))); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); @@ -1890,7 +1876,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, pm8001_dbg(pm8001_ha, FAIL, "Executing read log end\n"); if (res) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); kfree(dev); } } @@ -4834,7 +4820,7 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, u32 stp_sspsmp_sata = 0x4; struct inbound_queue_table *circularQ; u32 linkrate, phy_id; - int rc, tag = 0xdeadbeef; + int rc; struct pm8001_ccb_info *ccb; u8 retryFlag = 0x1; u16 firstBurstSize = 0; @@ -4845,13 +4831,11 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) - return rc; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->device = pm8001_dev; - ccb->ccb_tag = tag; - payload.tag = cpu_to_le32(tag); + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); + if (!ccb) + return -SAS_QUEUE_FULL; + + payload.tag = cpu_to_le32(ccb->ccb_tag); if (flag == 1) { stp_sspsmp_sata = 0x02; /*direct attached sata */ @@ -4888,7 +4872,7 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); if (rc) - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); return rc; } From patchwork Fri Feb 18 03:14:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25803C433FE for ; Fri, 18 Feb 2022 03:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231992AbiBRDQC (ORCPT ); Thu, 17 Feb 2022 22:16:02 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231966AbiBRDPs (ORCPT ); Thu, 17 Feb 2022 22:15:48 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91E78264F for ; Thu, 17 Feb 2022 19:15:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154130; x=1676690130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wo6G/4/9r5WjKldfToa178zcZDAG5AhMvecLxuFIUiQ=; b=IJ6IsZPAhUNCfCzGUUbi8gmEMuGT0Qw7wS01ixIw5j0sBTsT01fdF+al NRWJ7NUOb6YAmyBIV0aaKffObvlqhhCA60CXJTKJsrhoJDo2JncWv6rQd 9CpWzfOj+/kT2/Bsr3mYRmxo/haIxSrBYEcR+0scWc8SF4V1Vf6SVSlVK o6AoCK+psxZNswHkzF8Fah1ghV32rbx5bQXH90R+z8+gsN2UMnlBYxxlS FGicHOntnkzHhI9gjSOd6nxQO17ClJVUfhe3uCN4Lo5fPQZdkrynIHAVN xsIQuG5YSAYUZ+ISNWgJdCj74FcQZuM3F9+LrRXPRFWPsS1x77eEoaaLG w==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="198074211" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:30 +0800 IronPort-SDR: mTNAo+eMQAXLECqygteJI5Wn+L2mZfOTf8pai7nfbpTtlik8LSqquBqvWHHgNsBw4KKGFQTF0P V/d+dpBD4SggTy44CyTIWnjT/oMfwtM3qHSF973PzdsS8sWghnR6L/oK3u6SqrrOHRaphGruEt bjwga6nzBdQuwSDRf8kQMzNgzjTuLq6Dlr6RFOkfAoLhS8w53reGanJi/Mm/o6mNWbFJ48TozH 48TecSv3z4HBhlpnzAG2AAicFQnRMLpdvH0KR8VIabQhI29g6ADzGdSKHx7LJAS4HHqti5E+XV bLkOSRdo/CCE2RR5CMeYe+wP Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:47:08 -0800 IronPort-SDR: K4o/kdPVd1FDWqgjFK30iOyOFYv1s5O7fVTF7sRh8LXGYknYfznLqXIu42Z4oBOJS8ZmoVn3+f OSoFnE1cEM7lPZsfWDOGLLi163oDfShBXoHAE+3Ae1spAXESlRKEKRKHKO7UCAF4SPKw7itgA8 g3h8VOqEXHJ/9lInqBpz12R7LJBupgXLpHrK2VICqoNxGKpGIBbYjR6trWN2RLJxhVYcsDZ9Vb +ekl02Yb+a8w8o2s+Ny0LjPdGW/k1rPd7IChsBlm8X5YCNracx3R8buAaBvyX2TjDo0Cw5eNSw ucs= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:31 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzQ3nQXz1SVp2 for ; Thu, 17 Feb 2022 19:15:30 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154127; x=1647746128; bh=Wo6G/4/9r5WjKldfTo a178zcZDAG5AhMvecLxuFIUiQ=; b=rIGewjbNM0sgeD07XdkOwBTbL9JK8b3idn CGm1aQADJUIyVw6GywtoRx68gfOz1sSKfZfDvKSRSbsKQet54FOjgWDGFA2sBIJX Q3B3F1r6XKqLvzH7cNln2U7cAQFppOp89hAVFNdFw238UDRTOp03bsvfHtwGkvvj cyaiiO9Yr1Hzj8siHRLqvvU99MMxI/Z7MEqQ3VxYEWp/6zzfGDTwfT05KrcYxyqp tuOV14sSkg3g2S6XJws832lvfPLhe4J1+yfHIPpYErPxyK9Q1732YfCL3a/p/22i aqPtodSSt/G2LEomG3ivSVdQ92S/a7scCYIRRXtBw3L7XcJqucXw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id rNyUeq2AcOG9 for ; Thu, 17 Feb 2022 19:15:27 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzK4Mypz1SHwl; Thu, 17 Feb 2022 19:15:25 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 27/31] scsi: pm8001: Simplify pm8001_mpi_build_cmd() interface Date: Fri, 18 Feb 2022 12:14:41 +0900 Message-Id: <20220218031445.548767-28-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There is no need to pass a pointer to a struct inbound_queue_table to pm8001_mpi_build_cmd(). Passing the start index in the inbound queue table of the adapter is enough. This change allows avoiding the declaration of a struct inbound_queue_table pointer (circularQ variables) in many functions, simplifying the code. While at it, blank lines are added i(e.g. after local variable declarations) to make the code more readable. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 154 +++++++++++-------------------- drivers/scsi/pm8001/pm8001_sas.h | 3 +- drivers/scsi/pm8001/pm80xx_hwi.c | 98 +++++++------------- 3 files changed, 89 insertions(+), 166 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 699fecc09267..03bcf7497bf9 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1309,21 +1309,20 @@ int pm8001_mpi_msg_free_get(struct inbound_queue_table *circularQ, * pm8001_mpi_build_cmd- build the message queue for transfer, update the PI to * FW to tell the fw to get this message from IOMB. * @pm8001_ha: our hba card information - * @circularQ: the inbound queue we want to transfer to HBA. + * @q_index: the index in the inbound queue we want to transfer to HBA. * @opCode: the operation code represents commands which LLDD and fw recognized. * @payload: the command payload of each operation command. * @nb: size in bytes of the command payload * @responseQueue: queue to interrupt on w/ command response (if any) */ int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha, - struct inbound_queue_table *circularQ, - u32 opCode, void *payload, size_t nb, + u32 q_index, u32 opCode, void *payload, size_t nb, u32 responseQueue) { u32 Header = 0, hpriority = 0, bc = 1, category = 0x02; void *pMessage; unsigned long flags; - int q_index = circularQ - pm8001_ha->inbnd_q_tbl; + struct inbound_queue_table *circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; int rv; u32 htag = le32_to_cpu(*(__le32 *)payload); @@ -1752,7 +1751,6 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct task_abort_req task_abort; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SATA_ABORT; int ret; @@ -1775,15 +1773,13 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, return; } - circularQ = &pm8001_ha->inbnd_q_tbl[0]; - memset(&task_abort, 0, sizeof(task_abort)); task_abort.abort_all = cpu_to_le32(1); task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); task_abort.tag = cpu_to_le32(ccb->ccb_tag); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, - sizeof(task_abort), 0); + ret = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &task_abort, + sizeof(task_abort), 0); if (ret) { sas_free_task(task); pm8001_ccb_free(pm8001_ha, ccb); @@ -1799,11 +1795,9 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, struct sas_task *task = NULL; struct host_to_dev_fis fis; struct domain_device *dev; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SATA_HOST_OPSTART; task = sas_alloc_slow_task(GFP_ATOMIC); - if (!task) { pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task !!!\n"); return; @@ -1834,9 +1828,6 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; - memset(&sata_cmd, 0, sizeof(sata_cmd)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; - /* construct read log FIS */ memset(&fis, 0, sizeof(struct host_to_dev_fis)); fis.fis_type = 0x27; @@ -1845,13 +1836,14 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, fis.lbal = 0x10; fis.sector_count = 0x1; + memset(&sata_cmd, 0, sizeof(sata_cmd)); sata_cmd.tag = cpu_to_le32(ccb->ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); sata_cmd.ncqtag_atap_dir_m = cpu_to_le32((0x1 << 7) | (0x5 << 9)); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); - res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, - sizeof(sata_cmd), 0); + res = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &sata_cmd, + sizeof(sata_cmd), 0); if (res) { sas_free_task(task); pm8001_ccb_free(pm8001_ha, ccb); @@ -3261,17 +3253,14 @@ static void pm8001_hw_event_ack_req(struct pm8001_hba_info *pm8001_ha, struct hw_event_ack_req payload; u32 opc = OPC_INB_SAS_HW_EVENT_ACK; - struct inbound_queue_table *circularQ; - memset((u8 *)&payload, 0, sizeof(payload)); - circularQ = &pm8001_ha->inbnd_q_tbl[Qnum]; payload.tag = cpu_to_le32(1); payload.sea_phyid_portid = cpu_to_le32(((SEA & 0xFFFF) << 8) | ((phyId & 0x0F) << 4) | (port_id & 0x0F)); payload.param0 = cpu_to_le32(param0); payload.param1 = cpu_to_le32(param1); - pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + pm8001_mpi_build_cmd(pm8001_ha, Qnum, opc, &payload, sizeof(payload), 0); } static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, @@ -4103,7 +4092,6 @@ static int pm8001_chip_smp_req(struct pm8001_hba_info *pm8001_ha, u32 req_len, resp_len; struct smp_req smp_cmd; u32 opc; - struct inbound_queue_table *circularQ; memset(&smp_cmd, 0, sizeof(smp_cmd)); /* @@ -4129,7 +4117,6 @@ static int pm8001_chip_smp_req(struct pm8001_hba_info *pm8001_ha, } opc = OPC_INB_SMP_REQUEST; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; smp_cmd.tag = cpu_to_le32(ccb->ccb_tag); smp_cmd.long_smp_req.long_req_addr = cpu_to_le64((u64)sg_dma_address(&task->smp_task.smp_req)); @@ -4140,8 +4127,8 @@ static int pm8001_chip_smp_req(struct pm8001_hba_info *pm8001_ha, smp_cmd.long_smp_req.long_resp_size = cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_resp)-4); build_smp_cmd(pm8001_dev->device_id, smp_cmd.tag, &smp_cmd); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, - &smp_cmd, sizeof(smp_cmd), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, + &smp_cmd, sizeof(smp_cmd), 0); if (rc) goto err_out_2; @@ -4169,9 +4156,7 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_dev = dev->lldd_dev; struct ssp_ini_io_start_req ssp_cmd; u32 tag = ccb->ccb_tag; - int ret; u64 phys_addr; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SSPINIIOSTART; memset(&ssp_cmd, 0, sizeof(ssp_cmd)); memcpy(ssp_cmd.ssp_iu.lun, task->ssp_task.LUN, 8); @@ -4187,7 +4172,6 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7); memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cmd->cmnd, task->ssp_task.cmd->cmd_len); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; /* fill in PRD (scatter/gather) table, if any */ if (task->num_scatter > 1) { @@ -4208,9 +4192,9 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.len = cpu_to_le32(task->total_xfer_len); ssp_cmd.esgl = 0; } - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &ssp_cmd, - sizeof(ssp_cmd), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &ssp_cmd, + sizeof(ssp_cmd), 0); } static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, @@ -4220,17 +4204,15 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, struct domain_device *dev = task->dev; struct pm8001_device *pm8001_ha_dev = dev->lldd_dev; u32 tag = ccb->ccb_tag; - int ret; struct sata_start_req sata_cmd; u32 hdr_tag, ncg_tag = 0; u64 phys_addr; u32 ATAP = 0x0; u32 dir; - struct inbound_queue_table *circularQ; unsigned long flags; u32 opc = OPC_INB_SATA_HOST_OPSTART; + memset(&sata_cmd, 0, sizeof(sata_cmd)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { ATAP = 0x04; /* no data*/ @@ -4316,9 +4298,8 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, } } - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, - sizeof(sata_cmd), 0); - return ret; + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &sata_cmd, + sizeof(sata_cmd), 0); } /** @@ -4330,11 +4311,9 @@ static int pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) { struct phy_start_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 tag = 0x01; u32 opcode = OPC_INB_PHYSTART; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(tag); /* @@ -4351,9 +4330,9 @@ pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) memcpy(payload.sas_identify.sas_addr, pm8001_ha->sas_addr, SAS_ADDR_SIZE); payload.sas_identify.phy_id = phy_id; - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opcode, &payload, + sizeof(payload), 0); } /** @@ -4365,17 +4344,15 @@ static int pm8001_chip_phy_stop_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) { struct phy_stop_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 tag = 0x01; u32 opcode = OPC_INB_PHYSTOP; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(tag); payload.phy_id = cpu_to_le32(phy_id); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opcode, &payload, + sizeof(payload), 0); } /* @@ -4387,7 +4364,6 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, struct reg_dev_req payload; u32 opc; u32 stp_sspsmp_sata = 0x4; - struct inbound_queue_table *circularQ; u32 linkrate, phy_id; int rc; struct pm8001_ccb_info *ccb; @@ -4397,7 +4373,6 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, struct domain_device *dev = pm8001_dev->sas_device; struct domain_device *parent_dev = dev->parent; struct pm8001_port *port = dev->port->lldd_port; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); @@ -4431,8 +4406,9 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, cpu_to_le32(ITNT | (firstBurstSize * 0x10000)); memcpy(payload.sas_addr, pm8001_dev->sas_device->sas_addr, SAS_ADDR_SIZE); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); if (rc) pm8001_ccb_free(pm8001_ha, ccb); @@ -4447,18 +4423,15 @@ int pm8001_chip_dereg_dev_req(struct pm8001_hba_info *pm8001_ha, { struct dereg_dev_req payload; u32 opc = OPC_INB_DEREG_DEV_HANDLE; - int ret; - struct inbound_queue_table *circularQ; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(1); payload.device_id = cpu_to_le32(device_id); pm8001_dbg(pm8001_ha, MSG, "unregister device device_id = %d\n", device_id); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); } /** @@ -4471,17 +4444,15 @@ static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, u32 phyId, u32 phy_op) { struct local_phy_ctl_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 opc = OPC_INB_LOCAL_PHY_CONTROL; + memset(&payload, 0, sizeof(payload)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(1); payload.phyop_phyid = cpu_to_le32(((phy_op & 0xff) << 8) | (phyId & 0x0F)); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); } static u32 pm8001_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha) @@ -4519,9 +4490,7 @@ static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc, u32 dev_id, u8 flag, u32 task_tag, u32 cmd_tag) { struct task_abort_req task_abort; - struct inbound_queue_table *circularQ; - int ret; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&task_abort, 0, sizeof(task_abort)); if (ABORT_SINGLE == (flag & ABORT_MASK)) { task_abort.abort_all = 0; @@ -4533,9 +4502,9 @@ static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc, task_abort.device_id = cpu_to_le32(dev_id); task_abort.tag = cpu_to_le32(cmd_tag); } - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, - sizeof(task_abort), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &task_abort, + sizeof(task_abort), 0); } /* @@ -4575,9 +4544,7 @@ int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha, struct domain_device *dev = task->dev; struct pm8001_device *pm8001_dev = dev->lldd_dev; u32 opc = OPC_INB_SSPINITMSTART; - struct inbound_queue_table *circularQ; struct ssp_ini_tm_start_req sspTMCmd; - int ret; memset(&sspTMCmd, 0, sizeof(sspTMCmd)); sspTMCmd.device_id = cpu_to_le32(pm8001_dev->device_id); @@ -4587,10 +4554,9 @@ int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha, sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag); if (pm8001_ha->chip_id != chip_8001) sspTMCmd.ds_ads_m = cpu_to_le32(0x08); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd, - sizeof(sspTMCmd), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &sspTMCmd, + sizeof(sspTMCmd), 0); } int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, @@ -4600,7 +4566,6 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, u32 nvmd_type; int rc; struct pm8001_ccb_info *ccb; - struct inbound_queue_table *circularQ; struct get_nvm_data_req nvmd_req; struct fw_control_ex *fw_control_context; struct pm8001_ioctl_payload *ioctl_payload = payload; @@ -4611,7 +4576,6 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, return -ENOMEM; fw_control_context->usrAddr = (u8 *)ioctl_payload->func_specific; fw_control_context->len = ioctl_payload->rd_length; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&nvmd_req, 0, sizeof(nvmd_req)); ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); @@ -4678,8 +4642,9 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, default: break; } - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req, - sizeof(nvmd_req), 0); + + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &nvmd_req, + sizeof(nvmd_req), 0); if (rc) { kfree(fw_control_context); pm8001_ccb_free(pm8001_ha, ccb); @@ -4694,7 +4659,6 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, u32 nvmd_type; int rc; struct pm8001_ccb_info *ccb; - struct inbound_queue_table *circularQ; struct set_nvm_data_req nvmd_req; struct fw_control_ex *fw_control_context; struct pm8001_ioctl_payload *ioctl_payload = payload; @@ -4703,7 +4667,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, fw_control_context = kzalloc(sizeof(struct fw_control_ex), GFP_KERNEL); if (!fw_control_context) return -ENOMEM; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memcpy(pm8001_ha->memoryMap.region[NVMD].virt_ptr, &ioctl_payload->func_specific, ioctl_payload->wr_length); @@ -4762,7 +4726,8 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, default: break; } - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req, + + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &nvmd_req, sizeof(nvmd_req), 0); if (rc) { kfree(fw_control_context); @@ -4783,12 +4748,9 @@ pm8001_chip_fw_flash_update_build(struct pm8001_hba_info *pm8001_ha, { struct fw_flash_Update_req payload; struct fw_flash_updata_info *info; - struct inbound_queue_table *circularQ; - int ret; u32 opc = OPC_INB_FW_FLASH_UPDATE; memset(&payload, 0, sizeof(struct fw_flash_Update_req)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; info = fw_flash_updata_info; payload.tag = cpu_to_le32(tag); payload.cur_image_len = cpu_to_le32(info->cur_image_len); @@ -4799,9 +4761,9 @@ pm8001_chip_fw_flash_update_build(struct pm8001_hba_info *pm8001_ha, cpu_to_le32(lower_32_bits(le64_to_cpu(info->sgl.addr))); payload.sgl_addr_hi = cpu_to_le32(upper_32_bits(le64_to_cpu(info->sgl.addr))); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); } int @@ -4936,7 +4898,6 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_dev, u32 state) { struct set_dev_state_req payload; - struct inbound_queue_table *circularQ; struct pm8001_ccb_info *ccb; int rc; u32 opc = OPC_INB_SET_DEVICE_STATE; @@ -4947,13 +4908,12 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, if (!ccb) return -SAS_QUEUE_FULL; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(ccb->ccb_tag); payload.device_id = cpu_to_le32(pm8001_dev->device_id); payload.nds = cpu_to_le32(state); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); if (rc) pm8001_ccb_free(pm8001_ha, ccb); @@ -4964,7 +4924,6 @@ static int pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha) { struct sas_re_initialization_req payload; - struct inbound_queue_table *circularQ; struct pm8001_ccb_info *ccb; int rc; u32 opc = OPC_INB_SAS_RE_INITIALIZE; @@ -4975,14 +4934,13 @@ pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha) if (!ccb) return -SAS_QUEUE_FULL; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(ccb->ccb_tag); payload.SSAHOLT = cpu_to_le32(0xd << 25); payload.sata_hol_tmo = cpu_to_le32(80); payload.open_reject_cmdretries_data_retries = cpu_to_le32(0xff00ff); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); if (rc) pm8001_ccb_free(pm8001_ha, ccb); diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 824ada7f6a3f..aec4572906cf 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -668,8 +668,7 @@ int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr, void pm8001_chip_iounmap(struct pm8001_hba_info *pm8001_ha); int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha, - struct inbound_queue_table *circularQ, - u32 opCode, void *payload, size_t nb, + u32 q_index, u32 opCode, void *payload, size_t nb, u32 responseQueue); int pm8001_mpi_msg_free_get(struct inbound_queue_table *circularQ, u16 messageSize, void **messagePtr); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 57ea933dab66..ce19aa361d26 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1182,7 +1182,6 @@ int pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) { struct set_ctrl_cfg_req payload; - struct inbound_queue_table *circularQ; int rc; u32 tag; u32 opc = OPC_INB_SET_CONTROLLER_CONFIG; @@ -1193,7 +1192,6 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) if (rc) return rc; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); if (IS_SPCV_12G(pm8001_ha->pdev)) @@ -1211,7 +1209,7 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) "Setting up thermal config. cfg_pg 0 0x%x cfg_pg 1 0x%x\n", payload.cfg_pg[0], payload.cfg_pg[1]); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); @@ -1228,7 +1226,6 @@ static int pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) { struct set_ctrl_cfg_req payload; - struct inbound_queue_table *circularQ; SASProtocolTimerConfig_t SASConfigPage; int rc; u32 tag; @@ -1238,11 +1235,9 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) memset(&SASConfigPage, 0, sizeof(SASProtocolTimerConfig_t)); rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) return rc; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); SASConfigPage.pageCode = cpu_to_le32(SAS_PROTOCOL_TIMER_CONFIG_PAGE); @@ -1284,7 +1279,7 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) memcpy(&payload.cfg_pg, &SASConfigPage, sizeof(SASProtocolTimerConfig_t)); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); @@ -1390,7 +1385,6 @@ pm80xx_get_encrypt_info(struct pm8001_hba_info *pm8001_ha) static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) { struct kek_mgmt_req payload; - struct inbound_queue_table *circularQ; int rc; u32 tag; u32 opc = OPC_INB_KEK_MANAGEMENT; @@ -1400,7 +1394,6 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) if (rc) return rc; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); /* Currently only one key is used. New KEK index is 1. * Current KEK index is 1. Store KEK to NVRAM is 1. @@ -1413,7 +1406,7 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) "Saving Encryption info to flash. payload 0x%x\n", le32_to_cpu(payload.new_curidx_ksop)); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); @@ -1770,7 +1763,6 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct task_abort_req task_abort; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SATA_ABORT; int ret; @@ -1794,15 +1786,13 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, return; } - circularQ = &pm8001_ha->inbnd_q_tbl[0]; - memset(&task_abort, 0, sizeof(task_abort)); task_abort.abort_all = cpu_to_le32(1); task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); task_abort.tag = cpu_to_le32(ccb->ccb_tag); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, - sizeof(task_abort), 0); + ret = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &task_abort, + sizeof(task_abort), 0); pm8001_dbg(pm8001_ha, FAIL, "Executing abort task end\n"); if (ret) { sas_free_task(task); @@ -1819,11 +1809,9 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, struct sas_task *task = NULL; struct host_to_dev_fis fis; struct domain_device *dev; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SATA_HOST_OPSTART; task = sas_alloc_slow_task(GFP_ATOMIC); - if (!task) { pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task !!!\n"); return; @@ -1856,7 +1844,6 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; memset(&sata_cmd, 0, sizeof(sata_cmd)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; /* construct read log FIS */ memset(&fis, 0, sizeof(struct host_to_dev_fis)); @@ -1871,8 +1858,8 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, sata_cmd.ncqtag_atap_dir_m_dad = cpu_to_le32(((0x1 << 7) | (0x5 << 9))); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); - res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, - sizeof(sata_cmd), 0); + res = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &sata_cmd, + sizeof(sata_cmd), 0); pm8001_dbg(pm8001_ha, FAIL, "Executing read log end\n"); if (res) { sas_free_task(task); @@ -3209,17 +3196,15 @@ static void pm80xx_hw_event_ack_req(struct pm8001_hba_info *pm8001_ha, struct hw_event_ack_req payload; u32 opc = OPC_INB_SAS_HW_EVENT_ACK; - struct inbound_queue_table *circularQ; - memset((u8 *)&payload, 0, sizeof(payload)); - circularQ = &pm8001_ha->inbnd_q_tbl[Qnum]; payload.tag = cpu_to_le32(1); payload.phyid_sea_portid = cpu_to_le32(((SEA & 0xFFFF) << 8) | ((phyId & 0xFF) << 24) | (port_id & 0xFF)); payload.param0 = cpu_to_le32(param0); payload.param1 = cpu_to_le32(param1); - pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + pm8001_mpi_build_cmd(pm8001_ha, Qnum, opc, &payload, + sizeof(payload), 0); } static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, @@ -4198,7 +4183,6 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, u32 req_len, resp_len; struct smp_req smp_cmd; u32 opc; - struct inbound_queue_table *circularQ; u32 i, length; u8 *payload; u8 *to; @@ -4227,7 +4211,6 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, } opc = OPC_INB_SMP_REQUEST; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; smp_cmd.tag = cpu_to_le32(ccb->ccb_tag); length = sg_req->length; @@ -4295,8 +4278,8 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, kunmap_atomic(to); build_smp_cmd(pm8001_dev->device_id, smp_cmd.tag, &smp_cmd, pm8001_ha->smp_exp_mode, length); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &smp_cmd, - sizeof(smp_cmd), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &smp_cmd, + sizeof(smp_cmd), 0); if (rc) goto err_out_2; return 0; @@ -4356,10 +4339,8 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_dev = dev->lldd_dev; struct ssp_ini_io_start_req ssp_cmd; u32 tag = ccb->ccb_tag; - int ret; u64 phys_addr, end_addr; u32 end_addr_high, end_addr_low; - struct inbound_queue_table *circularQ; u32 q_index, cpu_id; u32 opc = OPC_INB_SSPINIIOSTART; @@ -4383,7 +4364,6 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, task->ssp_task.cmd->cmd_len); cpu_id = smp_processor_id(); q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num); - circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; /* Check if encryption is set */ if (pm8001_ha->chip->encrypt && @@ -4500,9 +4480,9 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.esgl = 0; } } - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, - &ssp_cmd, sizeof(ssp_cmd), q_index); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, q_index, opc, &ssp_cmd, + sizeof(ssp_cmd), q_index); } static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, @@ -4513,7 +4493,6 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev = dev->lldd_dev; struct ata_queued_cmd *qc = task->uldd_task; u32 tag = ccb->ccb_tag; - int ret; u32 q_index, cpu_id; struct sata_start_req sata_cmd; u32 hdr_tag, ncg_tag = 0; @@ -4521,13 +4500,11 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, u32 end_addr_high, end_addr_low; u32 ATAP = 0x0; u32 dir; - struct inbound_queue_table *circularQ; unsigned long flags; u32 opc = OPC_INB_SATA_HOST_OPSTART; memset(&sata_cmd, 0, sizeof(sata_cmd)); cpu_id = smp_processor_id(); q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num); - circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { ATAP = 0x04; /* no data*/ @@ -4742,9 +4719,8 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, ccb->ccb_tag, opc, qc ? qc->tf.command : 0, // ata opcode ccb->device ? atomic_read(&ccb->device->running_req) : 0); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, - &sata_cmd, sizeof(sata_cmd), q_index); - return ret; + return pm8001_mpi_build_cmd(pm8001_ha, q_index, opc, &sata_cmd, + sizeof(sata_cmd), q_index); } /** @@ -4756,11 +4732,9 @@ static int pm80xx_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) { struct phy_start_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 tag = 0x01; u32 opcode = OPC_INB_PHYSTART; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(tag); @@ -4782,9 +4756,9 @@ pm80xx_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) memcpy(payload.sas_identify.sas_addr, &pm8001_ha->sas_addr, SAS_ADDR_SIZE); payload.sas_identify.phy_id = phy_id; - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opcode, &payload, + sizeof(payload), 0); } /** @@ -4796,17 +4770,15 @@ static int pm80xx_chip_phy_stop_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) { struct phy_stop_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 tag = 0x01; u32 opcode = OPC_INB_PHYSTOP; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(tag); payload.phy_id = cpu_to_le32(phy_id); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opcode, &payload, + sizeof(payload), 0); } /* @@ -4818,7 +4790,6 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, struct reg_dev_req payload; u32 opc; u32 stp_sspsmp_sata = 0x4; - struct inbound_queue_table *circularQ; u32 linkrate, phy_id; int rc; struct pm8001_ccb_info *ccb; @@ -4828,7 +4799,6 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, struct domain_device *dev = pm8001_dev->sas_device; struct domain_device *parent_dev = dev->parent; struct pm8001_port *port = dev->port->lldd_port; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); @@ -4869,7 +4839,7 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, memcpy(payload.sas_addr, pm8001_dev->sas_device->sas_addr, SAS_ADDR_SIZE); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_ccb_free(pm8001_ha, ccb); @@ -4889,18 +4859,18 @@ static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, u32 tag; int rc; struct local_phy_ctl_req payload; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_LOCAL_PHY_CONTROL; + memset(&payload, 0, sizeof(payload)); rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) return rc; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + payload.tag = cpu_to_le32(tag); payload.phyop_phyid = cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF)); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); @@ -4946,7 +4916,6 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, u32 tag, i, j = 0; int rc; struct set_phy_profile_req payload; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SET_PHY_PROFILE; memset(&payload, 0, sizeof(payload)); @@ -4956,7 +4925,6 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, return; } - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); payload.ppc_phyid = cpu_to_le32(((operation & 0xF) << 8) | (phyid & 0xFF)); @@ -4967,8 +4935,8 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, payload.reserved[j] = cpu_to_le32(*((u32 *)buf + i)); j++; } - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); } @@ -4992,7 +4960,6 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, u32 tag, opc; int rc, i; struct set_phy_profile_req payload; - struct inbound_queue_table *circularQ; memset(&payload, 0, sizeof(payload)); @@ -5002,7 +4969,6 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, return; } - circularQ = &pm8001_ha->inbnd_q_tbl[0]; opc = OPC_INB_SET_PHY_PROFILE; payload.tag = cpu_to_le32(tag); @@ -5013,7 +4979,7 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, for (i = 0; i < length; i++) payload.reserved[i] = cpu_to_le32(*(buf + i)); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); From patchwork Fri Feb 18 03:14:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B6C6C433EF for ; Fri, 18 Feb 2022 03:15:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbiBRDQA (ORCPT ); Thu, 17 Feb 2022 22:16:00 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231937AbiBRDPr (ORCPT ); Thu, 17 Feb 2022 22:15:47 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C173166F8B for ; Thu, 17 Feb 2022 19:15:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154130; x=1676690130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K6ZoULG/Hjdqc12xeSNdtQ8HkebdTxwEHmR2H/cwol4=; b=G0FoiOpMx+0C5+M/T74Ez7dorQidNpGamzGmDG1nYFpxSuaPCpUWIEz0 7gl+Ej73ysixfb5ogVcqPmlFDaZBOEdTX7dokPrD29OCvl/f7UKOVnKFh 0/5xWtgnWitczESVMvJVaszUtpD6jsYnXvLDYvgnrQLF8VhbWiSCzffHT 3phohQZyYzCch06K0wPInpfTvyg5TA989O4TMeLTtOe94S1J4tjciKEEQ 1gBtS8Vv9KHnD13va0S3l0Z/TW82e/E1e0gzFwjv0USTNAeuAh9anbEFP vekZRkwSbjftu+ltYJSB2awShP/SwZfMlSHIF334vBBiTUTMt3/b54Bcj g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="198074213" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:30 +0800 IronPort-SDR: 5XA9yzBI+T8lxdU2Y0rcMkeVTQCAPPW+1iKhSK42jyIo1ooH4RMlb7/GjVYWziKyPZDRPVJTY4 FFaIiDoBYFEn+buN4iPwyHsDPBgsfuRMrCDGZRD5JmE1/neqQdZwp7RemWD71a0EDudfSAQ+58 vtM5865S6oTKfnbpFE18NeIgGURThu4DXFw0H0tMR/KQm55NQ4n70NkWUWjffvr+3tg+6duY71 mkmHGB8GAUnUlHfjS+lBlar49bnXuZF8yreMOBlA6m6miSyDrcdJWirJmcHndSb/s+gYgG9BRQ e7UlgQ3kVRyNiN2nXXL85rrH Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:47:09 -0800 IronPort-SDR: sZiikbjxEjNjhIiZrIVInHaumSNhYOzvknHrqucS32Tl1XQW/rYtD/CyiLHIEop55MdUyx4O3u LRft0XSpadAlZR/+RDreJe9WTukmZkbrYG2HKlTXxCZ2HoqfGKbNE56i7HzXWIUVGcPq+VBpGB H5ZE6r43LBaDug4eaeWCW9ZOgYeTWCgTHnQVlyZEstbsGPFAB3megY84cZXGFfsDPqbOLBuAWP /MPdz7qf0SDzsNhM1e7eEa+qXdkE4FB5IYVZSzY5/veK4dokInTk3Uw7PSqZWPtSIvVtq/VXCa vV8= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:31 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzQ5nMbz1SVp5 for ; Thu, 17 Feb 2022 19:15:30 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154129; x=1647746130; bh=K6ZoULG/Hjdqc12xeS NdtQ8HkebdTxwEHmR2H/cwol4=; b=ftQOmckuHT7dO2jpvMEJALhBaMX/pgdwbj 6lJvudUAPjGe9NlDStxllX4pumjlh9etGLZvYVrhfKXvo//6TxZfv3h16RmUmos6 hNaWpH1ZjnRiUH3dWL6gJvGaNOZ2Dy1tNFlwHE9MoG336OxiC+G81a50tl+jXCpD IlKk21DA5b7/Czut6pbdvDTSjEPepxP0gLaHkBnLo343oZC17GsUIUvzwml/zHPJ of3A6O9Jre2hU5pL5nbKagSh68w0FWlT30BOfRSLYwJVoFRPtUmRmLzeasXND48l 2ee88UY2E2DnQ0Bhz1xMYV/NAWhafBThtga4/iQJy6tJncKhQ09Q== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 9GYk8N_emvFw for ; Thu, 17 Feb 2022 19:15:29 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzM3dTLz1SVp6; Thu, 17 Feb 2022 19:15:27 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 28/31] scsi: pm8001: Simplify pm8001_task_exec() Date: Fri, 18 Feb 2022 12:14:42 +0900 Message-Id: <20220218031445.548767-29-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The main part of the pm8001_task_exec() function uses a do {} while(0) loop that is useless and only makes the code harder to read. Remove this loop. The unnecessary local variable t is also removed. Additionally, avoid repeatedly declaring "struct task_status_struct *ts" to handle error cases by declaring this variable for the entire function scope. This allows simplifying the error cases, and together with the addition of blank lines make the code more readable. Finally, handling of the running_req counter is fixed to avoid decrementing it without a corresponding incrementation in the case of an invalid task protocol. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_sas.c | 174 ++++++++++++++----------------- 1 file changed, 80 insertions(+), 94 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 6c6138effab1..03c275b53ff4 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -373,129 +373,115 @@ static int sas_find_local_port_id(struct domain_device *dev) * @is_tmf: if it is task management task. * @tmf: the task management IU */ -static int pm8001_task_exec(struct sas_task *task, - gfp_t gfp_flags, int is_tmf, struct pm8001_tmf_task *tmf) +static int pm8001_task_exec(struct sas_task *task, gfp_t gfp_flags, int is_tmf, + struct pm8001_tmf_task *tmf) { + struct task_status_struct *ts = &task->task_status; + enum sas_protocol task_proto = task->task_proto; struct domain_device *dev = task->dev; + struct pm8001_device *pm8001_dev = dev->lldd_dev; struct pm8001_hba_info *pm8001_ha; - struct pm8001_device *pm8001_dev; struct pm8001_port *port = NULL; - struct sas_task *t = task; struct pm8001_ccb_info *ccb; - u32 rc = 0, n_elem = 0; - unsigned long flags = 0; - enum sas_protocol task_proto = t->task_proto; + unsigned long flags; + u32 n_elem = 0; + int rc = 0; if (!dev->port) { - struct task_status_struct *tsm = &t->task_status; - tsm->resp = SAS_TASK_UNDELIVERED; - tsm->stat = SAS_PHY_DOWN; + ts->resp = SAS_TASK_UNDELIVERED; + ts->stat = SAS_PHY_DOWN; if (dev->dev_type != SAS_SATA_DEV) - t->task_done(t); + task->task_done(task); return 0; } - pm8001_ha = pm8001_find_ha_by_dev(task->dev); - if (pm8001_ha->controller_fatal_error) { - struct task_status_struct *ts = &t->task_status; + pm8001_ha = pm8001_find_ha_by_dev(dev); + if (pm8001_ha->controller_fatal_error) { ts->resp = SAS_TASK_UNDELIVERED; - t->task_done(t); + task->task_done(task); return 0; } + pm8001_dbg(pm8001_ha, IO, "pm8001_task_exec device\n"); + spin_lock_irqsave(&pm8001_ha->lock, flags); - do { - dev = t->dev; - pm8001_dev = dev->lldd_dev; - port = &pm8001_ha->port[sas_find_local_port_id(dev)]; - if (DEV_IS_GONE(pm8001_dev) || !port->port_attached) { - if (sas_protocol_ata(task_proto)) { - struct task_status_struct *ts = &t->task_status; - ts->resp = SAS_TASK_UNDELIVERED; - ts->stat = SAS_PHY_DOWN; - spin_unlock_irqrestore(&pm8001_ha->lock, flags); - t->task_done(t); - spin_lock_irqsave(&pm8001_ha->lock, flags); - continue; - } else { - struct task_status_struct *ts = &t->task_status; - ts->resp = SAS_TASK_UNDELIVERED; - ts->stat = SAS_PHY_DOWN; - t->task_done(t); - continue; - } - } + pm8001_dev = dev->lldd_dev; + port = &pm8001_ha->port[sas_find_local_port_id(dev)]; - ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, t); - if (!ccb) { - rc = -SAS_QUEUE_FULL; - goto err_out; + if (DEV_IS_GONE(pm8001_dev) || !port->port_attached) { + ts->resp = SAS_TASK_UNDELIVERED; + ts->stat = SAS_PHY_DOWN; + if (sas_protocol_ata(task_proto)) { + spin_unlock_irqrestore(&pm8001_ha->lock, flags); + task->task_done(task); + spin_lock_irqsave(&pm8001_ha->lock, flags); + } else { + task->task_done(task); } + rc = -ENODEV; + goto err_out; + } - if (!sas_protocol_ata(task_proto)) { - if (t->num_scatter) { - n_elem = dma_map_sg(pm8001_ha->dev, - t->scatter, - t->num_scatter, - t->data_dir); - if (!n_elem) { - rc = -ENOMEM; - goto err_out_ccb; - } + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, task); + if (!ccb) { + rc = -SAS_QUEUE_FULL; + goto err_out; + } + + if (!sas_protocol_ata(task_proto)) { + if (task->num_scatter) { + n_elem = dma_map_sg(pm8001_ha->dev, task->scatter, + task->num_scatter, task->data_dir); + if (!n_elem) { + rc = -ENOMEM; + goto err_out_ccb; } - } else { - n_elem = t->num_scatter; } + } else { + n_elem = task->num_scatter; + } - t->lldd_task = ccb; - ccb->n_elem = n_elem; + task->lldd_task = ccb; + ccb->n_elem = n_elem; - switch (task_proto) { - case SAS_PROTOCOL_SMP: - atomic_inc(&pm8001_dev->running_req); - rc = pm8001_task_prep_smp(pm8001_ha, ccb); - break; - case SAS_PROTOCOL_SSP: - atomic_inc(&pm8001_dev->running_req); - if (is_tmf) - rc = pm8001_task_prep_ssp_tm(pm8001_ha, - ccb, tmf); - else - rc = pm8001_task_prep_ssp(pm8001_ha, ccb); - break; - case SAS_PROTOCOL_SATA: - case SAS_PROTOCOL_STP: - atomic_inc(&pm8001_dev->running_req); - rc = pm8001_task_prep_ata(pm8001_ha, ccb); - break; - default: - dev_printk(KERN_ERR, pm8001_ha->dev, - "unknown sas_task proto: 0x%x\n", task_proto); - rc = -EINVAL; - break; - } + atomic_inc(&pm8001_dev->running_req); - if (rc) { - pm8001_dbg(pm8001_ha, IO, "rc is %x\n", rc); - atomic_dec(&pm8001_dev->running_req); - goto err_out_ccb; - } - /* TODO: select normal or high priority */ - } while (0); - rc = 0; - goto out_done; + switch (task_proto) { + case SAS_PROTOCOL_SMP: + rc = pm8001_task_prep_smp(pm8001_ha, ccb); + break; + case SAS_PROTOCOL_SSP: + if (is_tmf) + rc = pm8001_task_prep_ssp_tm(pm8001_ha, ccb, tmf); + else + rc = pm8001_task_prep_ssp(pm8001_ha, ccb); + break; + case SAS_PROTOCOL_SATA: + case SAS_PROTOCOL_STP: + rc = pm8001_task_prep_ata(pm8001_ha, ccb); + break; + default: + dev_printk(KERN_ERR, pm8001_ha->dev, + "unknown sas_task proto: 0x%x\n", task_proto); + rc = -EINVAL; + break; + } + if (rc) { + atomic_dec(&pm8001_dev->running_req); + if (!sas_protocol_ata(task_proto) && n_elem) + dma_unmap_sg(pm8001_ha->dev, task->scatter, + task->num_scatter, task->data_dir); err_out_ccb: - pm8001_ccb_free(pm8001_ha, ccb); + pm8001_ccb_free(pm8001_ha, ccb); + err_out: - dev_printk(KERN_ERR, pm8001_ha->dev, "pm8001 exec failed[%d]!\n", rc); - if (!sas_protocol_ata(task_proto)) - if (n_elem) - dma_unmap_sg(pm8001_ha->dev, t->scatter, t->num_scatter, - t->data_dir); -out_done: + pm8001_dbg(pm8001_ha, IO, "pm8001_task_exec failed[%d]!\n", rc); + } + spin_unlock_irqrestore(&pm8001_ha->lock, flags); + return rc; } From patchwork Fri Feb 18 03:14:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544214 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44DC5C433EF for ; Fri, 18 Feb 2022 03:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231942AbiBRDQF (ORCPT ); Thu, 17 Feb 2022 22:16:05 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:59018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbiBRDPu (ORCPT ); Thu, 17 Feb 2022 22:15:50 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74570120F7A for ; Thu, 17 Feb 2022 19:15:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154133; x=1676690133; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bisDyyzh3Z8JkeTW8FlVEwn2u5adpcI42HFL/TB7C8A=; b=ohwADtXbRaDkLUDIpHlDNlPmvbef2qjIy0i6YKZ/lySkTxojOkcWPGxR KsXqM5cGgKOFRj2EZEh1PtiBBJZcxZGQ8Clt+m+bVcjRPob7cmaPFy9gq RWnWZ0HWNfIdHY1iHYGkPWiqBnJ5LgZyWVdWZmb93wq63OGTk8b9+m2Ey pHy7R2n1hIbcO7K0RHlyZ1JlW+aMPwDslM9ccgCp1JfZNITs/GclUuK6a CPfTN5bt2UNAnWFPJT536+dDxsKERdUWxEHbFECjW3TZKLTkm2dBtLaiL L5PH34w5g67WfiMPN+r7d/P7WVUbdhswHtmw82QykjxgRXh1GbjTwb1af A==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="192180424" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:32 +0800 IronPort-SDR: O3PVrO0bIqefQZ+Juu777FhlSS9+70CtpDZbPp++zeHZYwrjBJ9RBpJEiVMmGIJmVUf4XieKiz +pOSldu8VKQSuS1BFYTmuqnQnEKTQIHCerdVFAIuu/siqu3jL2ZVuybNAh89YrHC9QMcDmFjtQ xGxcrhf+A1fOhYZ4jjrQQY6gA1hJhblzEr6we/W1/UOPJz1NEjoMsig019wed3pLxWsFNoc857 O6XiKB+Q0f92Q1ZIVzeaYB4aO0dQ+CLn3ddcOZnZbvQRQyIdSya9mtWKC+I3rIsuVn5Qs/28QN IKAK46RFEptHBBuQxEEORb5O Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:47:10 -0800 IronPort-SDR: HY1ReURS69cntXec820Yh7f5WbEpJIlcab/FjRKcTGVfUFE0dU2eb6sCCCugdZDLu8ykNEqAA8 eSK4dSF3UzXspO7NyrL7eTGOv08vTJhOn4adWoH8gjiuZdVFNkuE3U2r8xIKceJRxKomVHN7d0 PmOGMA8j+pbQqef8R+5nXIk3oOiqnT9N5ZYXp2kKUDkU0igsVbdnOIBxdjjTRfuTDoAGIeEmAl IneYATwalDznxIpxJFIT0XrrDdYUjFNHk92G72n//KMuYsAb6BBcFl59FeWdzBE9dwB3halQts Ci0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:32 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzS35V4z1SVnx for ; Thu, 17 Feb 2022 19:15:32 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154131; x=1647746132; bh=bisDyyzh3Z8JkeTW8F lVEwn2u5adpcI42HFL/TB7C8A=; b=cpE9qJjEjQoEYnHmd8s0l0FNbH9ZLeNtRj o8HQf1cGsRZbY30E4SDKn/nYtUauu1jJBhtUoh7+tPLt49QxcGeFL+1bIgv9yzXX Vp5+QAgJ4cxUU453RtlW0btfoT/xqvS8MnW5LbulAptaPPDe0Yyrbzpg9Wj6ezP+ RCHPDahpqwgJCGCAmw12ZHukd8P5pAOfWNio0Rl7W5QWR/ED/F9F+ox5w4hZhagx bbjK7H4YcqF/lq5Dc8aOYFw3h6DX8iFEwT5ATg2lBO+aZP7VAFF1JZbBEiy97mlb oHAqmtw9BAqOIqWJ2RyTwgKoX7x9d2y37gZpSsYtfKNxszMOYrlQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id jBpqF1repCMX for ; Thu, 17 Feb 2022 19:15:31 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzP6lb4z1Rwrw; Thu, 17 Feb 2022 19:15:29 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 29/31] scsi: pm8001: Simplify pm8001_ccb_task_free() Date: Fri, 18 Feb 2022 12:14:43 +0900 Message-Id: <20220218031445.548767-30-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The task argument of the pm8001_ccb_task_free() function can be infered from the ccb argument ccb_task field. So there is no need to have this argument. Likewise, the ccb_index argument is always equal to the ccb tag field and is not needed either. Remove both arguments and update all call sites. The pm8001_ccb_task_free_done() helper is also modified to match this change. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 42 +++++++++++++++----------------- drivers/scsi/pm8001/pm8001_sas.c | 25 +++++++++---------- drivers/scsi/pm8001/pm8001_sas.h | 12 ++++----- drivers/scsi/pm8001/pm80xx_hwi.c | 35 ++++++++++++-------------- 4 files changed, 52 insertions(+), 62 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 03bcf7497bf9..c2dbadb5d91e 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1564,11 +1564,11 @@ void pm8001_work_fn(struct work_struct *work) spin_unlock_irqrestore(&t->task_state_lock, flags1); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with event 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, pw->handler, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); + pm8001_ccb_task_free(pm8001_ha, ccb); spin_unlock_irqrestore(&pm8001_ha->lock, flags); } else { spin_unlock_irqrestore(&t->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb();/* in order to force CPU ordering */ spin_unlock_irqrestore(&pm8001_ha->lock, flags); t->task_done(t); @@ -1697,8 +1697,7 @@ void pm8001_work_fn(struct work_struct *work) continue; } /*complete sas task and update to top layer */ - pm8001_ccb_task_free(pm8001_ha, task, ccb, - ccb->ccb_tag); + pm8001_ccb_task_free(pm8001_ha, ccb); ts->resp = SAS_TASK_COMPLETE; task->task_done(task); } else if (ccb->ccb_tag != PM8001_INVALID_TAG) { @@ -2084,10 +2083,10 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) spin_unlock_irqrestore(&t->task_state_lock, flags); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb();/* in order to force CPU ordering */ t->task_done(t); } @@ -2251,10 +2250,10 @@ static void mpi_ssp_event(struct pm8001_hba_info *pm8001_ha, void *piomb) spin_unlock_irqrestore(&t->task_state_lock, flags); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with event 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, event, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb();/* in order to force CPU ordering */ t->task_done(t); } @@ -2480,7 +2479,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2496,7 +2495,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2518,7 +2517,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2589,7 +2588,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_DS_NON_OPERATIONAL); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2609,7 +2608,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_DS_IN_ERROR); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2639,10 +2638,10 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); } } @@ -2994,12 +2993,10 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) spin_unlock_irqrestore(&t->task_state_lock, flags); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); - mb();/* in order to force CPU ordering */ - t->task_done(t); + pm8001_ccb_task_free_done(pm8001_ha, ccb); } } @@ -3649,7 +3646,7 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) t->task_state_flags &= ~SAS_TASK_STATE_PENDING; t->task_state_flags |= SAS_TASK_STATE_DONE; spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb(); if (pm8001_dev->id & NCQ_ABORT_ALL_FLAG) { @@ -4287,12 +4284,11 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, "task 0x%p resp 0x%x stat 0x%x but aborted by upper layer\n", task, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&task->task_state_lock, flags); - pm8001_ccb_task_free_done(pm8001_ha, task, - ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return 0; } } diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 03c275b53ff4..c5d4311887c3 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -499,22 +499,21 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags) /** * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb. * @pm8001_ha: our hba card information - * @ccb: the ccb which attached to ssp task - * @task: the task to be free. - * @ccb_idx: ccb index. + * @ccb: the ccb which attached to ssp task to free */ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, - struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx) + struct pm8001_ccb_info *ccb) { + struct sas_task *task = ccb->task; struct ata_queued_cmd *qc; struct pm8001_device *pm8001_dev; - if (!ccb->task) + if (!task) return; - if (!sas_protocol_ata(task->task_proto)) - if (ccb->n_elem) - dma_unmap_sg(pm8001_ha->dev, task->scatter, - task->num_scatter, task->data_dir); + + if (!sas_protocol_ata(task->task_proto) && ccb->n_elem) + dma_unmap_sg(pm8001_ha->dev, task->scatter, + task->num_scatter, task->data_dir); switch (task->task_proto) { case SAS_PROTOCOL_SMP: @@ -533,12 +532,12 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, } if (sas_protocol_ata(task->task_proto)) { - // For SCSI/ATA commands uldd_task points to ata_queued_cmd + /* For SCSI/ATA commands uldd_task points to ata_queued_cmd */ qc = task->uldd_task; pm8001_dev = ccb->device; trace_pm80xx_request_complete(pm8001_ha->id, pm8001_dev ? pm8001_dev->attached_phy : PM8001_MAX_PHYS, - ccb_idx, 0 /* ctlr_opcode not known */, + ccb->ccb_tag, 0 /* ctlr_opcode not known */, qc ? qc->tf.command : 0, // ata opcode pm8001_dev ? atomic_read(&pm8001_dev->running_req) : -1); } @@ -961,11 +960,11 @@ void pm8001_open_reject_retry( & SAS_TASK_STATE_ABORTED))) { spin_unlock_irqrestore(&task->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, task, ccb, ccb->ccb_tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&task->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, task, ccb, ccb->ccb_tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb();/* in order to force CPU ordering */ spin_unlock_irqrestore(&pm8001_ha->lock, flags); task->task_done(task); diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index aec4572906cf..2aab357d9a23 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -641,7 +641,7 @@ int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out); void pm8001_tag_init(struct pm8001_hba_info *pm8001_ha); u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag); void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, - struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx); + struct pm8001_ccb_info *ccb); int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, void *funcdata); void pm8001_scan_start(struct Scsi_Host *shost); @@ -786,12 +786,12 @@ static inline void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, pm8001_tag_free(pm8001_ha, tag); } -static inline void -pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, - struct sas_task *task, struct pm8001_ccb_info *ccb, - u32 ccb_idx) +static inline void pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, + struct pm8001_ccb_info *ccb) { - pm8001_ccb_task_free(pm8001_ha, task, ccb, ccb_idx); + struct sas_task *task = ccb->task; + + pm8001_ccb_task_free(pm8001_ha, ccb); smp_mb(); /*in order to force CPU ordering*/ task->task_done(task); } diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index ce19aa361d26..b5e1aaa0fd58 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -2157,14 +2157,12 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); if (t->slow_task) complete(&t->slow_task->completion); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); - mb();/* in order to force CPU ordering */ - t->task_done(t); + pm8001_ccb_task_free_done(pm8001_ha, ccb); } } @@ -2340,12 +2338,10 @@ static void mpi_ssp_event(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with event 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, event, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); - mb();/* in order to force CPU ordering */ - t->task_done(t); + pm8001_ccb_task_free_done(pm8001_ha, ccb); } } @@ -2579,7 +2575,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2599,7 +2595,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2627,7 +2623,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2702,7 +2698,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2726,7 +2722,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2760,14 +2756,14 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); if (t->slow_task) complete(&t->slow_task->completion); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); } @@ -3171,10 +3167,10 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%xstat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb();/* in order to force CPU ordering */ t->task_done(t); } @@ -4702,13 +4698,12 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, "task 0x%p resp 0x%x stat 0x%x but aborted by upper layer\n", task, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); return 0; } else { spin_unlock_irqrestore(&task->task_state_lock, flags); - pm8001_ccb_task_free_done(pm8001_ha, task, - ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); atomic_dec(&pm8001_ha_dev->running_req); return 0; } From patchwork Fri Feb 18 03:14:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB7F2C433FE for ; Fri, 18 Feb 2022 03:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231982AbiBRDQH (ORCPT ); Thu, 17 Feb 2022 22:16:07 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:59020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231977AbiBRDPu (ORCPT ); Thu, 17 Feb 2022 22:15:50 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EEC9168082 for ; Thu, 17 Feb 2022 19:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154134; x=1676690134; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ot2ANyjiSvfWLWkj+FYcOdGIqJ4Hq++lbLMv8ADJsaM=; b=AUcg2cOUQBtmq8jMSVLBHNZmSmxT/QA3QLWZvbQz5CZ9gWMdAfXpyhgP bFjkzoJ9zl+jINw59FwK0FPbn9IO4mdHVjf8g/hanufjbNdYG2ym3o1n8 nHbrbyV3ll4Kdcmhw1fvBwaPY5t9zoc4PhWsgSLdo/mhzsaVu5wC3+iFt 5+ojQIWzo8k/3EPlYj73oc4HnOvdw7rtCzFFL4untIFJRPGBYRSHT3HmD jMfTyOlNoXAmtenT8RDnhzfiaS2zQBw9ijF+txUaJtLDrPrpiVWKI8kgl yhXnpt+z7pPKK8B4lwRB50+8Q+CIub44/Z7kjqnvCrXJuvoQsWPac5JkZ w==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="192180429" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:33 +0800 IronPort-SDR: cKoGV9vu/ipPoWkFp2XaGbmXPbnyn5HGtm+O2TppS7WUEb3tiRiJ7/UkZfetv+ygc9ncsSBlmL a+U6W5rPmXs7EXEA6JrYSDE0vHT//YxZiRJ2VS99c3yNoDDmjaxL4c9/g324ORceNVVv07c67B X7z0IlmzO/pJGJ9CNrldir19WsnyDoEjT/RyB3nxp2/Js0RK3AaHyE7MWjk4HX65psfCmbkyOO P6UZKrmJkDdPVrP4ARd9FkzAi4JW3jCFUOm+nNkA6Vxw2WkmyhKl5DZFJaiIFS6qC3ir97hHhr iUzAEe19OXDcSPvbzkdyBUZq Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:47:11 -0800 IronPort-SDR: wG4oyu2wtoaJwvmGfWhx87Pmg+LASzs7ak6jVfSLPmuKtwVyIcGRgmBArPLc6foGbd4qIWRnK+ lTTLvZqaD9NCVE621f0IdKj5hPFITO7ZuSvhBKW9W/QzKfDSU2Cuf2Vv7yqQQ2ciYd2JqZXcnw rbSV93lUGGURoaIYRsyzbAHGbCqfRjI6jt9eVQqBdO5AMZoKnA4UHX+kOF/HgDCMrF/0MIC1nM +BRC3SMKXYJTb3wnNv4nQ/OsUX9elASo7uBV6tKLXGDdZF75fYouQj9uRoLW8PP1HfmPQiPck9 Fkg= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:34 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzT4v9Pz1SVp3 for ; Thu, 17 Feb 2022 19:15:33 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154133; x=1647746134; bh=Ot2ANyjiSvfWLWkj+F YcOdGIqJ4Hq++lbLMv8ADJsaM=; b=P5+Rjxpge+2r6pCJY1K5yaYNaE8KPjRzsi dM0LTsYtUCn1DkNtC22qo2bf2H8uH5rj1qwACj7uk3W79UVRIiVeFFcc62hLpBr+ HQt8eP/MJDCymAa4U5a18C+LBn27Kk98q8IAaxWr1b5WRJMrw8L1zOfLV5hwxE3Q TkyUUbFxCBDKS4lNypyLk5Fm5vqFsVGlvWoM5KasPTHWmMtoHQxrJaEr5kyHU5gS 2psLQMZJcfaj4he2Zh0GgbWYGsPoDnwWeg7hAbS4sGc1/r05S1KnPf+UrsVzA67V dE3/nY481k2P+ZZGXoGPgosrYErzx9Mez8xPdZUcKKDlvgcip6tA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XYz5gqaeei5N for ; Thu, 17 Feb 2022 19:15:33 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzR4SvBz1SHwl; Thu, 17 Feb 2022 19:15:31 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 30/31] scsi: pm8001: improve pm80XX_send_abort_all() Date: Fri, 18 Feb 2022 12:14:44 +0900 Message-Id: <20220218031445.548767-31-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Both pm8001_send_abort_all() and pm80xx_send_abort_all() are called only for a non null device with the NCQ_READ_LOG_FLAG set, so remove the device check on entry of these functions. Furthermore, setting the NCQ_ABORT_ALL_FLAG device id flag and clearing the NCQ_READ_LOG_FLAG is always done before calling these functions. Move these operations inside the functions. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 14 ++++---------- drivers/scsi/pm8001/pm80xx_hwi.c | 16 ++++------------ 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index c2dbadb5d91e..edf83b8a6bd0 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1748,15 +1748,13 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev) { struct pm8001_ccb_info *ccb; - struct sas_task *task = NULL; + struct sas_task *task; struct task_abort_req task_abort; u32 opc = OPC_INB_SATA_ABORT; int ret; - if (!pm8001_ha_dev) { - pm8001_dbg(pm8001_ha, FAIL, "dev is null\n"); - return; - } + pm8001_ha_dev->id |= NCQ_ABORT_ALL_FLAG; + pm8001_ha_dev->id &= ~NCQ_READ_LOG_FLAG; task = sas_alloc_slow_task(GFP_ATOMIC); if (!task) { @@ -2358,11 +2356,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) ts->stat = SAS_SAM_STAT_GOOD; /* check if response is for SEND READ LOG */ if (pm8001_dev && - (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { - /* set new bit for abort_all */ - pm8001_dev->id |= NCQ_ABORT_ALL_FLAG; - /* clear bit for read log */ - pm8001_dev->id = pm8001_dev->id & 0x7FFFFFFF; + (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { pm8001_send_abort_all(pm8001_ha, pm8001_dev); /* Free the tag */ pm8001_tag_free(pm8001_ha, tag); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index b5e1aaa0fd58..9bb31f66db85 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1761,23 +1761,19 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev) { struct pm8001_ccb_info *ccb; - struct sas_task *task = NULL; + struct sas_task *task; struct task_abort_req task_abort; u32 opc = OPC_INB_SATA_ABORT; int ret; - if (!pm8001_ha_dev) { - pm8001_dbg(pm8001_ha, FAIL, "dev is null\n"); - return; - } + pm8001_ha_dev->id |= NCQ_ABORT_ALL_FLAG; + pm8001_ha_dev->id &= ~NCQ_READ_LOG_FLAG; task = sas_alloc_slow_task(GFP_ATOMIC); - if (!task) { pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task\n"); return; } - task->task_done = pm8001_task_done; ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); @@ -2446,11 +2442,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_SAM_STAT_GOOD; /* check if response is for SEND READ LOG */ if (pm8001_dev && - (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { - /* set new bit for abort_all */ - pm8001_dev->id |= NCQ_ABORT_ALL_FLAG; - /* clear bit for read log */ - pm8001_dev->id = pm8001_dev->id & 0x7FFFFFFF; + (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { pm80xx_send_abort_all(pm8001_ha, pm8001_dev); /* Free the tag */ pm8001_tag_free(pm8001_ha, tag); From patchwork Fri Feb 18 03:14:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 544213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79341C4332F for ; Fri, 18 Feb 2022 03:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231996AbiBRDQI (ORCPT ); Thu, 17 Feb 2022 22:16:08 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:59074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231978AbiBRDPu (ORCPT ); Thu, 17 Feb 2022 22:15:50 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E9091BAC68 for ; Thu, 17 Feb 2022 19:15:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645154135; x=1676690135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3co+YfVmCl22mdl0oAzrKAatpfLkzp43oEFR53BRMyM=; b=cXzM1JwU2V0x0H3GsDHWl+Tm8Dh92zV1dFITYnHiNeWkfXR8dCM9buTJ XJlvHSI8nw4RDS0vVkOctpJ0zrtA9B7PbQrP0xZJzrCsABAozzGyoC7+Z H16llSiTAL49MNhEb4ZutGJ+SrD/UJX68vPAcDJpwoX9BnD4QCA5Dq1AG QnYofdqBEdwXp+FOF27Sm+rwK27dhsRnjZaNkgE6ATUN9Fg66MaLIFGsR bcwT68mFqS/Y5xRR6F9RLpm0gh+QeGeXIVkriFuEXZtHPWxtrH7JwwVdA wDSCvZ1/vRynxN4fG2nK9F2STWBzxWMmhZgHuEhVd/U0+LcK5EY6E/Ebi g==; X-IronPort-AV: E=Sophos;i="5.88,377,1635177600"; d="scan'208";a="192180431" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Feb 2022 11:15:35 +0800 IronPort-SDR: ZFW4XFhEQISesgzRbCkK88f0zltdTTPCiLvgsJJnaJjsqDRl/rl0S8q0OQqPNI2biE8N8mLGZL jFbtN6sMlelY4/ULNSHugrFWpKayhUvXhfwV3wNBw0OooZWISG55YUJ+2HVBVMGZnoYQcuKr2u kvrCBbKWuUOERaEFN0Tahm48U7P9iynKHN+iYe//nAnIW3j8z3knnmj7X4Hkx/5qI1qe9cX5Ie Kydjkvk1SjaZIRSfXD46C1mf2P4rxjPyH7/xkg0hLhss13cKpmi9FTkwE3WQw66z+0epXonQwb buYq2ti65lNKJoeqKMa4cewJ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 18:47:13 -0800 IronPort-SDR: y8RCpg9DJpDvB1AaWVTfjV0/Khd1FgYu/dE1KyaRAEtj13hHUPf7kFDZGs7bZEYZ3ca0OOjPDV TdkG/eyirs92OJ/mnFt4Xol+DWJGish+g97mvCDBfSQIqgvmXL18qDCWYRgYM/pINcWbMNFAUK qF1uYiEidwZKUHpTdkJv+2ANNsHvtBJuLgsoTOL5Z7xfuGRMEss6ux0s+6UYPqbGSracEDDC4P j2jmQ/taU2zDOQ/llA90XExe9RRH6kXk9WplH4lhSUiwN7TPm2ZHTQ84sG/RMwkkmKvdnZV5RR 9Ws= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 19:15:35 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K0GzV6Y5jz1SVnx for ; Thu, 17 Feb 2022 19:15:34 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645154134; x=1647746135; bh=3co+YfVmCl22mdl0oA zrKAatpfLkzp43oEFR53BRMyM=; b=k6ZY4vFf7B4gRrfnrJ0gGgC0O3m3kv9w9c Kzk+5s0wXvI0aeSisO5H7eWtBcVeE71BIpHlkF1nHLxLjI1Y0LJJ+VKHo6e5bCEU FhvOx31Npun9PW5c01LqVvINJbTIkb1kJUWokCdVgTj0BwZ3G5tVqTrPT97ky+Ec HCQ6Dh9kteAyxMYQr8XDFXtdPOL47ROCFNcnNE1BGzqxCFLAjWshpV4eEmH5+F6S K2GbQKM39nHSIfnxaCWa4L1HLSEjofAux/H1hrw53byZRy9Wv+V9RNvqq05KGbX6 NVgeVKE+xPqPAz9UkPfn5gYqrQhqgb8MnMkh6/iZNrXbvp1CXdvw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Vtaanc2Zf4Tw for ; Thu, 17 Feb 2022 19:15:34 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K0GzT3PYSz1Rwrw; Thu, 17 Feb 2022 19:15:33 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v5 31/31] scsi: pm8001: Fix pm8001_info() message format Date: Fri, 18 Feb 2022 12:14:45 +0900 Message-Id: <20220218031445.548767-32-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> References: <20220218031445.548767-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make the driver messages more readable by adding a space after the message prefix ":" and removing the extra space between function name and line number. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_sas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 2aab357d9a23..d78e6690333f 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -71,7 +71,7 @@ #define PM8001_IOERR_LOGGING 0x200 /* development io err message logging */ #define pm8001_info(HBA, fmt, ...) \ - pr_info("%s:: %s %d:" fmt, \ + pr_info("%s:: %s %d: " fmt, \ (HBA)->name, __func__, __LINE__, ##__VA_ARGS__) #define pm8001_dbg(HBA, level, fmt, ...) \