From patchwork Thu Feb 17 13:29: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: 12750045 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 8666BC433FE for ; Thu, 17 Feb 2022 13:30:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240595AbiBQNaQ (ORCPT ); Thu, 17 Feb 2022 08:30:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239103AbiBQNaP (ORCPT ); Thu, 17 Feb 2022 08:30:15 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D9EA2AE2BE for ; Thu, 17 Feb 2022 05:30: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=1645104601; x=1676640601; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MDhhb181EccMwnLd3hc+xNPmlMVSvpeLw+Zq8aeckxg=; b=L3UV+Hsl2Y53eAYyvwNWRUrOZ3yUiMJviQkTK03yiUAj70V8A1MU8LYx wpYzVftRdWp1fuYGJ9ZqobtP61KNEi/AsOTZ/n/qOzI76s1cgPzDshzEU N/TfL1A2lBikqvd8gTSaJuV8H/ZhUigV5MLl17UQWJt2bmlfNIN/fE33j 5rFseY4LW3HLAolAEUHw1QWBAbhwVRrQygRYfFDz1rtkAnAuorb62Taxg /yMkG2r9H41/DRYwTpwa6L5FhmjYOjiBNEnGchuFsxes1NV9OOswaP+JI XO54u85ajXiHhD12u+4lfiLl/ORyt9+ZQcl3kmlkWZ/IdWtYhZ0dpiwjE A==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303129" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:01 +0800 IronPort-SDR: eC0SZq9v40aBy0evUopx0NXUGiSOYuxio3SjHluLpnXoZObZ242T+G7uMNUf0OsOZq9n0rT/1Q Y9ZjsyB9HjFg7C+KC15t4fidSw8I0p8z1fZ3WLR7vfycEuXO6BHZ0xQTOmeZmGJDJlq71fW8Di fgykIDXkz8kWIwPMFESsKV9pE+QnSGDMhqvZ6o3buQ3HcMKXcuVoYZz3hEY5enyL8DUo2NUTxp cm248RMUEDxB9oa0z5KthiUheBo5E83QWEWAvmic4e9Bngepx+tt5xj4JNiEbsjVrChma/2U2Q sy+egMkDVpCy5GIySnTrAU4q 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 05:01:40 -0800 IronPort-SDR: 6eO3CShNA3fWxzIjp2OQDPYesUspKV0/aZ2jzGJz5I8HID9DbtSV5TKEbUZGLksBpjteBKUqDo qTDG9lfnhtXLFTkgDvjiWMTDkNkd4QtczMl9hoz13W7g11GOtiUmkZTtteGNoUyXYWiSXt6AWi Fl0jgkxdbMJYemPCJV7uarywDIeHIrsc7ecRNA4FjfnshB3W4H4uanak/7Z9j3IFBwf5Z25jFo 0UoCfQFJUGGHdpnSSCHiX2tldPcaXp8oMgCuWVPf4+eVICd/a4kZk+u1PowWxiAPsoAJJ5zRWY eGo= 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 05:30: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 4Jzwfw6dzwz1SVp2 for ; Thu, 17 Feb 2022 05:30: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=1645104600; x=1647696601; bh=MDhhb181EccMwnLd3h c+xNPmlMVSvpeLw+Zq8aeckxg=; b=q9YI+6ffJSQ0ABDJ8yYYFHC7d4L2NQUa19 frPzdC5DpTDW74Cv8GXSr0hqXPxyYHVaPcinFWAlYvwSwGcmJaykSeKW/Cm8gYIk s+qLnY9kEZdrz58lQIbA3n/LhhZe1x3AAVbZb7renS3CC6J3XIdXD0HJL4tapMZb K0rjabVMuQrjamY24b1DIoMFUEQ1XOkGu2Nsv2zrYYYGTRNLVJmTFlkBJR7IF0X2 eOCx4fxEgg13Orh5VqglHgYL38qSPicFMwPe/FT8+fJJ7lxemdRo91Z9SiGbUqIZ t53CnchsPk6ONZnkBWt4LIi8xzS6ZIQFDnyw2x9IlaGnfjLISAsg== 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 anKfEu7KwslM for ; Thu, 17 Feb 2022 05:30: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 4Jzwfv24Dkz1SHwl; Thu, 17 Feb 2022 05:29: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 v4 01/31] scsi: libsas: Fix sas_ata_qc_issue() handling of NCQ NON DATA commands Date: Thu, 17 Feb 2022 22:29:26 +0900 Message-Id: <20220217132956.484818-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750046 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 9F720C433F5 for ; Thu, 17 Feb 2022 13:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240794AbiBQNaW (ORCPT ); Thu, 17 Feb 2022 08:30:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239103AbiBQNaR (ORCPT ); Thu, 17 Feb 2022 08:30:17 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA3602782B3 for ; Thu, 17 Feb 2022 05:30:02 -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=1645104602; x=1676640602; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1yvh82HH2UmUw3aBo1/a9AgaELousAEViKy+r0E76aI=; b=rt+ia7gfcPFfH3ctNCvMeilBMOLgIvU2B+2A5Mc+Ez6KsqwDlk1H1iB8 jgjbe8+aM1Aj5AFGFNdjoxrUmbhhE/GXoMQF2PRYno9UhtJKpzPYuSH+h 0ZBfT6CRKD/qjKBwTbNSdaY6vACYmvfvbzg/I2k8QxGbdJOJSa+FFytSa 24k07SpL56ewiJ+dqm2M3z7c48JhHbWgCzQoue+HNLp0AuikzmHYWiGCK qQUtjysrwA8EGIe94pBgkYBsxJhLJF5f7+rL74TlhaHKJveYO+GK+92tm K/kvEJfON5RkSVoUJCC76qKNC5H7zFNSdX5KDm759gav4lH7UnisIObeY w==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303131" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:02 +0800 IronPort-SDR: xKTOm6DPq1SuaYgMRzLPq+Y6PDdUcqxVD1bSc1L0B+MmLrwIlKyLJugS8ilBn+qwy0PwNkrGSs D/IqK4PFAfbKXJbYqY2lxSgUPePgbRuRLbEE5GeoNIGYWB8/hfatAdfbySpFu7/Ff5Ww/1PXxO 86cQ3WC/8lKadLxfAkX1lU554QCItT0+oEjJ3gQiZOiHTWNCh/749QDCIWmFcaPG1AqIM2JhGw XpOT7cUGuweXYHODIJpP/ylPjfzd7tXmZB1Pbo6qcB1qhQ77Gk4dddKbzovUs0ngEi2Fy9NILc AQJo4x+H9SgBeUKjQQ/Ts0kR 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 05:01:41 -0800 IronPort-SDR: hHN8UBHBERC+kGsWK63Mb+rqnDdDC9Cu5V/x6gjtV38NLCHwCa1z2L2DURFyUSxADLB65jGg8X Lpe3dGhoSNNLTXYGBWhtYFd9D1uU8dovC9yJXbnK9C4WXO7nWiLD3rSAID07cj7U8G+bONmGvj nYZYPYibI0ENsmdSiOGjTqVEpgP+MLsHZGBW6hilLX8uyu0hpKis+wkhi/qhZXmen7OM0v76WF 3DMKmL9bMisSDRuyhn8DfzTZnmc28g96IQY20AERk11iaJHdoEJsbBfWL1FIjTzQCAIP+XGViu ajU= 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 05:30: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 4Jzwfy2YgFz1SVp0 for ; Thu, 17 Feb 2022 05:30: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=1645104601; x=1647696602; bh=1yvh82HH2UmUw3aBo1 /a9AgaELousAEViKy+r0E76aI=; b=BEr6xUjZuDkFVvPJ3AqFfLKCUvCLjnirK9 OYh2qpsT2UslKPGJct5i+WA8wneYNcEqig2fdjNiwQxq1cu4QB332Xzv0rObDtIw n8oiZGVQqsdcuVpR65X76B5fL8bf+NCKfbauVU8T5L7vJ9OIzTF84VwoajvzHq4X +aLI8rl05ASOaTA6N/U4LzZje8Xa0SWVB01bp6X5UmACM7VeD9NJ8lxCaiIqec8w HI/Obz8u3yX3m0l6DAs1mV19edd8PLShFYJmd3GM6E54JwimLeiWq2JUgOKBBmZ9 LZdOsZ3/cEwwzus/CmhWOCGploETdh84LXyBFZJ4bgp78ozVxlRg== 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 2TaZXoEgQMcU for ; Thu, 17 Feb 2022 05:30:01 -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 4Jzwfw5Pyzz1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 02/31] scsi: pm8001: Fix __iomem pointer use in pm8001_phy_control() Date: Thu, 17 Feb 2022 22:29:27 +0900 Message-Id: <20220217132956.484818-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750047 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 9C577C433EF for ; Thu, 17 Feb 2022 13:30:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240891AbiBQNaX (ORCPT ); Thu, 17 Feb 2022 08:30:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240603AbiBQNaS (ORCPT ); Thu, 17 Feb 2022 08:30:18 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 712722AE2BE for ; Thu, 17 Feb 2022 05:30:04 -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=1645104604; x=1676640604; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MDPQos9blKV8Oo0LcYELhApb03Psw+soVXabs2uNE4Y=; b=BuwZ9FNVjU9afuxjWNQIwkIqdymJMlIe43xI8u3RtcvJ662lp6EDCsJL fhJ7k+3yTfjompgmBydFfR4V0VigQOavkgBVSL75o2/c6eDZuZS4YeoGy u77M7S0t72jbm/sM/poNd7mbhjk4s0FV0XSJl1M4NIo7kN/W6egCDGWot oICU5oJpHcixzKWs2ehl0QVA7hLftXfUjHV6z7xZ10+dlwubaqSbgx0xY BemiVqf2u1Vchuctlf3gVv0mVhDvQxorWKVSMIWRqNkTb2Pcqi4ufGkhz xSUb5fWI34zQgTduVnd7p3AOo6Cy+LKtNAphJtKlNieTpoutVzu4BKwZt w==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303134" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:04 +0800 IronPort-SDR: KRlqNIpfDWHhDbAhfuzijtkC6wl4pJ//wGE06Eqfy2ZC7/EwQW4C9V8wlbqmd9k93Ic8qiJxiV DQ60NWzqRRK67E7Slzm/MWDps2IUiqUXocbvKpRSlKIbO4taYv9itaI7RZ4grQvR0spBROtTUw /ZMIS1OwyAnTGLLOY//NPkQItuhcpi5gpfVJrXIE/uVVH/yrR58krCAm61aHwVUKsSEriOzChO OYc94Lm2FAFW1RRVM25Hh9hLnktY6OUh2QsqyzjrFRUvR0ADPl5LhzzT3VxUnylnGgPirjhK4q /tDBwuJ/4RI8Y/z87LJOedRk 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 05:01:43 -0800 IronPort-SDR: P2SbA1bCaDKhDWfuYmdvNYXq+erYkt4U1y6cbsMxeoX4aLjkCVlDaup9UEdfqc34rzR9AUjBUM eX5dqCYZkiTdkLAWed8xtYK52Se//JD0QfMmXgr1s6tDftc0QTJun+uV3WVqgZt29VoTVKfR6N sQ8R/Rml2qt0lT+QdZtyDZPag40dFh53bWbhNwJ8eFjIgGeviEaoNec8tWweLpEUcnbu89Gjix uyVaFf6slqf/jDXKjL2D0M6B5P/gJuNXiht8XSIFimrD/P00d9kz/QrmD7uZbuKzGRqGRU8u+M bI0= 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 05:30:04 -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 4Jzwfz5z0cz1SVp3 for ; Thu, 17 Feb 2022 05:30:03 -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=1645104603; x=1647696604; bh=MDPQos9blKV8Oo0LcY ELhApb03Psw+soVXabs2uNE4Y=; b=rgrHs4rMupliXBa1TlJbshmn6HBAz4c7jl dOPfD+dUm+PtzZ/jOTiqDfWJv27pbMhM/SqXAfhBcGyvqRRgD8XRkwf9sxeMFrE2 pEOKwbDuzsK3q1jGexCIc4P+9xYKaEbvSiRhcvZHVcwEmjF7AEjWWw4ZOjuMpPC1 R/liIlRLtdVmWZS6/I/7pW/+s3pNXI+XCXotgH1jkFy3rejDKqMLxsVco6iThMBM wx/6t+00i+9Qc9LvOMufUVFjyTOCaSHohxixyjEtWZOLT/uuPEx5FQa9VYdvxkNn uwFwIuZpW4bgol5wNBwqNWrg+NQUQ1MfaDnc/zDH2WGdb3NloAPw== 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 l_963ByZinZU for ; Thu, 17 Feb 2022 05:30: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 4Jzwfy1G2Tz1SHwl; Thu, 17 Feb 2022 05:30:01 -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 v4 03/31] scsi: pm8001: Fix pm8001_update_flash() local variable type Date: Thu, 17 Feb 2022 22:29:28 +0900 Message-Id: <20220217132956.484818-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750048 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 8399DC4332F for ; Thu, 17 Feb 2022 13:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240908AbiBQNaY (ORCPT ); Thu, 17 Feb 2022 08:30:24 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240620AbiBQNaT (ORCPT ); Thu, 17 Feb 2022 08:30:19 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8381F2AE709 for ; Thu, 17 Feb 2022 05:30: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=1645104605; x=1676640605; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nIVG0sFjkIorcrheJ1UfoRawD5kq2+itLtArlFm6OoA=; b=Y1YWM5Dr07H+gQvI3+3ndPH/j0TeiwCZ/F7ixLGkqQciIT1hkQF6rNZS avUhGv12FbGKSf+B24We3i8HoVEqHak9oBzEUC9EQptGrbBndhsDenh3v uBXo14I8URQ9N0ee7Y+vtUxi2NNC+Nq52jbmy/PChVSOF9ArqL7Y/CiQy Pkp0OXxOGQGOWeg1+TkgI4D5l3LMMGFCZRZHJnxC51bjU0p4FqdaWZ+PP r3I1hoGEV1efyI0rEIRmy5b5AWsf9oWXsTN9Fc/Vl+RpFNvpmY9T6azsK d8QBpbSZidR4TqUMZrmCpJrv+oXjUqN3pW68bgFMufxeolOcoCdRQFNnJ Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303136" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:05 +0800 IronPort-SDR: nZvcAY/RBg/Yn3rvX5y0BtHy5FBU0jutn4I8k3+/d4m6IqNxAc4Wd7PCRZpsDaZIPskyDZRPyM DGPOl2W3De4BVug7h5mvHlJ48LBKqbDmapoMZGj8ETaWVzrEl1t6Q3BsHTt6TEgAtfqTl7hxYb t0pV5hmiE1mIipN0HcoirpYcQ0yvRge9/HNo6E8DRsxTM7Y6xizLNEwhMgcMUS2HOsq/ko3MgB PxtA39thlDvZsmRBhT/Wep5ah4iE6ybkU+rYorbhteY8NxFs9GipjWGa+TX9siTIyHjORFV5TM 5b6SAOT15AMKdNn/wrFGxk69 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 05:01:44 -0800 IronPort-SDR: iLA12uWmOmv4f+gA8HCDUTJiwvD+QGag2Mpy0o/WdKoP0RMDI9EBH7QCS/pmDzbr6lyJ5tTmXT 4Zz8/Pc3K5IBhm43ljIwUjXIwc9Rj9pxXYtKVfa9L68AxL2vmK2p4GsZ3OIW1X57UspoP0sIF+ xwiIbr0qAOi9WXRoOfT405Rk9k1Y4/749iCaz0CthxgOmrEa6Bdi3SmXHEsQW9forRBR2wQbPt qU7e3OMpP+MjFKggd5mWjdHHW9EgTiDudQ3qbhGKcaCzrNZa+MqlhoZ+f3utHN65iviiQi7MvK Rp4= 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 05:30: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 4Jzwg10TxLz1SVnx for ; Thu, 17 Feb 2022 05:30: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=1645104604; x=1647696605; bh=nIVG0sFjkIorcrheJ1 UfoRawD5kq2+itLtArlFm6OoA=; b=LFab5CraCQAfiK7/zLyx87YzEvEwGi6Sgj pM9ubCu7ypHmiaYOgpKb1veyEqvXzkcG0MTI74s0isfPfijI/Or96IUg0LasnSwH 44Zu7lAjyBHjKps4ozEcaq/rdb4IpSSrLlCTJ4xzTeVg9B5qUMqhG4MBmPz4OVrL cssBFzqT3tA73jv65mqBBRuOx+zqLFw439VZstwPP1FQ99U0+p0HZ8pHUqHo7u5e 2Bb1gsxhT8RiZfjVnURi/1bNpSIKqpMDcLc7ClO06EumRo99TdeGhqqPD/eEiE6f HewndbI+wRgyZOoQyqsFqK3i3OKZSXO7hKWy8ieZDabqPJ0xTt0w== 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 kLpB2OhirWdx for ; Thu, 17 Feb 2022 05:30:04 -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 4Jzwfz45X4z1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 04/31] scsi: pm8001: Fix command initialization in pm80XX_send_read_log() Date: Thu, 17 Feb 2022 22:29:29 +0900 Message-Id: <20220217132956.484818-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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") Reviewed-by: John Garry Signed-off-by: Damien Le Moal 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 Thu Feb 17 13:29: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: 12750049 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 26FD1C433F5 for ; Thu, 17 Feb 2022 13:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240909AbiBQNaZ (ORCPT ); Thu, 17 Feb 2022 08:30:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240767AbiBQNaW (ORCPT ); Thu, 17 Feb 2022 08:30:22 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F12442AE73A for ; Thu, 17 Feb 2022 05:30: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=1645104607; x=1676640607; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/0x4t7rrbd5xsprpsKFXXlX196gTnxRlNAkn8TTlNpE=; b=ReUkLGX7d2AQVDDzKbSaks6FelWx9pgvdr4s5cbDOfYf4OGIBwtijnuQ T1Q+T9gbo9WRnOZY46zMCK/oeghRF7poYr9E7lEmQyWWWGSpcv1ZvDXsv xQLrSOqv1OE3gTPEYKKi/nx/jS5gEivZueV9LpIm5tO5F1Lf5t4y8bJBY biJQocLLc4a58ztaC31VspwL3AEg1ddLsSAKxdKIG3iMdTzPmkUt0ZfiN zgECRYP5rNTPIjSQs0+MmhNQma0Atf+1zM1D/2E7L5nmbIvo47SIQHZYW ZvgxnTWiqCDKPg38d2Edu9q1ZsSXma8zUpOMrK6OzpVaptampsZbkY0TS Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303138" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:06 +0800 IronPort-SDR: QgLhQa+KlXdrGvldOvwHyIBx84gpF9fi+ruk//27Bx2FhzRXTrLCjnCIHDX4YgHrpAXV9S87GD Pjku0ob4kFTzLBIFvYvha70YWq+9Scl5Q7mHrk8xtxsMh99dgGw2JOJDizBq0NtXMH0qj76/L8 uIy83B16zimDsMsg8AI0FY0UkjJRSdLXop+5JjZbDr/nuI9Od8+jIaYlypvygOyFXZjWxSTgx2 nD/iYziXS5iiDcuae4AOdC3bZtwd8GJUukou38LrndhS8GQbPpMzu1is3eKLzT/sH+0cmBoShb hveffZ/5yqA3TtG6tThu5f1t 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 05:01:45 -0800 IronPort-SDR: 54S1eyyQZpFCh5akO3a3zMECRIO5mMYsiI3jgrmfbZ8rFRg+2jVQ3XHyHh/5/F0FYB0YfAfc/Z Lhgq0ca05WJIIYAzqI1/+2aMtliCjz/MLbvFeaOfWBnIooWdHq2cSgga3qJCiKb8JZMMoIPf7z TvtU96jQ8CsKoReuP1d2mvoOwnnnj8E+CFEceYRlWgMBgbQZTLmPFZvD6db1w0x1lxJlVsnSAU /e024urtWcfS7qps/s0T+KZQWOGCbK/bsUW4N3jAz9c2o1ujNwRTfzELVjktY0+Y+XBC/EEK9d i2A= 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 05:30: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 4Jzwg24NjDz1SVp1 for ; Thu, 17 Feb 2022 05:30:06 -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=1645104606; x=1647696607; bh=/0x4t7rrbd5xsprpsK FXXlX196gTnxRlNAkn8TTlNpE=; b=Mukz2LLlOexzQWDvdK92yk8EUB6KNsIkzH Pb9WESh/awSX7GJGTn/vBVEwZIxeVeSIatefWmNqIHWTPOTRagUUwRTT9kjjw+iz UM2Ui5QTN3t95iLN3pHjrOiQniTeDbFAnlME8L5F9XK9ld/eeDqKm+owEguO2eEH pyQy3GVAd0GBJ18F+RpRIYyq9soSZke9nDRVxJm7uRVR6nDL1lVrqf2IbYLuO+C3 nxVJUTc2F+vTLyHW8gAX7pJHub1paxZzlP4EamdpTI1/fpfY9KQctyc0kpo3j4vp N7bXUGzbgnkTtm5di7uwO4lCPq+i8sAAmVod6S1ywv8NlXhHp2tQ== 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 81b_HomPlzHy for ; Thu, 17 Feb 2022 05:30: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 4Jzwg075Zwz1SHwl; Thu, 17 Feb 2022 05:30:04 -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 v4 05/31] scsi: pm8001: Fix pm80xx_pci_mem_copy() interface Date: Thu, 17 Feb 2022 22:29:30 +0900 Message-Id: <20220217132956.484818-6-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750050 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 BDEFCC433FE for ; Thu, 17 Feb 2022 13:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240921AbiBQNaZ (ORCPT ); Thu, 17 Feb 2022 08:30:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240817AbiBQNaX (ORCPT ); Thu, 17 Feb 2022 08:30:23 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C52C2AE709 for ; Thu, 17 Feb 2022 05:30:08 -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=1645104608; x=1676640608; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FRwkDIbpah/fWM4dnE3n8IBBSfL3CzeUT5j6zZjx4s0=; b=HyPr7SDnquohtPAY5S6wEi85piy2kSYbe7BcnRMqKHGteTaJBh6OhIue 9gjI9eyxTGVWwBAJffSQ5zv5Ivd7+syK65CjJ7/f359GasLCtx1fdfXSx siuJEpBRQxP+mx4Nj0wPSUFyoxuukK065d0P6jmhK0CbQZyfSPEPcCvyl +AXXmENOjDgg4jB/bPEIRo1kzT+EMpR04AMqbajSupYf0ws2bZq5n88eO UB3KjhdSLu7Aaku7O3qdNUUAjG0Qq7HFka0mzT7wezFEFdttpJDy6y0Yh toKQFU7ZjhvOPZY220Zvreh1VRkjyO9dEod3ErkNHJjfxdlMk+BVfcDzC w==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303140" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:08 +0800 IronPort-SDR: IPmCngVR9TprUnUb1CgWSDAoTZXBldegMqffVvh8VucOINh1WWrl+JjErT/XGTIZOLWAprE43B tV4M0hXwHILELjsSXvFFdn3goNNmFANY3NT8EsC7AYOxSZKn2AJuCk3Bf/sNlpkhyZ+/osrieW YFrNyueHmDdPx45KDx5rMaIIMsatI0DbVqOJrWHlrQ73nmAo1b00KW1hxcXwFJNO4JfTWQqaE6 VE0RPh/mosj5o0v5iiRxqdtIutVhkMoceoRIi18Kx9tFNVAdzw3engA6rzxEdjF2dFrWRx407t vrO/7cMbw2GbQuDx3jYL84z9 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 05:01:47 -0800 IronPort-SDR: xN3s/BlLMoHcHgAyjPy6KOChZfvtQ4Hl1VP3altt+gkTe8taaY/zeMpEgHWI30idkJmaJXxfsk DvU3EJJsIamPAlMeG9mMausoAf01Ob2OvtZK4jmOp7DnPfsBlU1T0rHTX8jM+kDXJyz1o5usUG Z4hr8Z4PeVXpN02HUYyZaBCQ3DbLEvOHtvUmT/6zM8CBllTU06DkrqdNc17b/ZQIr9du0UJFOn IKqEK0OvWE01uGvUsuqukmtk2WVqBBZmXywg/sHry/w+OWSkjsZ9lRPJqC3Pl9iHwFyjlENe5T 0bE= 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 05:30: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 4Jzwg375Q7z1SVp4 for ; Thu, 17 Feb 2022 05:30: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=1645104607; x=1647696608; bh=FRwkDIbpah/fWM4dnE 3n8IBBSfL3CzeUT5j6zZjx4s0=; b=TfOLsC+6eq/JcVSxNRRrXV5cChs6YpfBZD rMn4qpG/uoer+Y+wznNQ3JRNSPgwX9jqKPmBtM93aXUO/17d3EC2LCTiwAB6mYgz vYQxgKsfAEItQMXAhkWLbocxz90LihVGqPYKz7PcuqOdNey/1DNIlMv3Qxh4ykaQ tzqpQNONGuHhYaEfGDSdrTlaqbUK9geShwSHUojAUUBW9I+2Jwadd8Yl0nrSrDc2 QV9I+XYSiRHSxaBM/0D+GwEjmYD0/sOy4j6so/R00UaFUzpZmeS3Q8Vx1LlouL4T SauWIOfdxN7CeIa1XdfC6UYsc1E+hJxH6t45SJsGzQ4wvOAGZNEA== 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 FJYOgkuvwzwS for ; Thu, 17 Feb 2022 05:30:07 -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 4Jzwg23DF4z1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 06/31] scsi: pm8001: Fix command initialization in pm8001_chip_ssp_tm_req() Date: Thu, 17 Feb 2022 22:29:31 +0900 Message-Id: <20220217132956.484818-7-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750052 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 0B707C433FE for ; Thu, 17 Feb 2022 13:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240799AbiBQNa3 (ORCPT ); Thu, 17 Feb 2022 08:30:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240907AbiBQNaY (ORCPT ); Thu, 17 Feb 2022 08:30:24 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD67E2AE73A for ; Thu, 17 Feb 2022 05:30: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=1645104609; x=1676640609; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GPbMoL3MX4jnOalYG4xolb6yV5fav/eAI5AHjuo0FmU=; b=mpi8Fjpmsp0ErIBheKyRBxEOqDmGVhCXW5xeKGM8T5fNCYqJrG46qGlV GvWrqjlmZhpSFXPbAIyRL9BFutHZBkPVmJdVef8ZMLDQYhVD6sHOZAWwd HfwlpYQBDBh5NlrHdPcx20xAB4VvMkLiKUyGrhb4Td8RMYEL7Ls3e28Ew nlbYx8gKeob9vWWlwkrcj9SPj3q+UUQWUILdpnOsoVy9MPWdMk7ogyAxL apVfklWBaYSaNr2f2Q7SU/NVJHkVGGHrHiTnPcqN4kp+SOPfxqIg8wsGc 63OiHptSJRxnZ3XuLWcbiTfGQedfG0IN4njR2oEkwRbVIG0kn5IW5dXAr A==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303141" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:09 +0800 IronPort-SDR: ohAs7CjcPBTOUt5qHFX5DFHgDePj8vDiNIKa9VYI+hYI6g/iBvbKdGlBmRvB2V4wkSIUvjjLyH ublcFGq+Kl/S7J0ZN83lVUvvvZ4D6J4EsI3qAfSjVFNdomZz0TZcXV3Go4lytGTn3y+b4AdW3A 17qZ3WfYhOYBg18i2khPOqUM12jGG1/EDB+RLqgsTo3+t08QwYZbhKCuWkEPCJvAJvAeaT/wxV XJjRhsF1B26ThydacEtw5z4Uoz4p4HdyW2xyoEkSxOZ6B1WaQ3qr+p7z7Rd1RvEQ102ybB6pki HpRo5sl4RaHKTWnBni2BkSGU 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 05:01:48 -0800 IronPort-SDR: cYI4+fj0C96zGMunI/bVnqzOSArhERu/HOpsZaMeM/cDks+Dspfp6AwMBLOqZlTLjqlm/+A+ku wI3jBXXuWutrD9PeIk50Wyd2dZL7HOBbb5FqDoOYu18R/1cCyviV3NXbb8NLEZeTPm4NdOspSz WBWi/kHQKW7Sj2h8FHqXAozvp0tC3m2lzXxq41tu6wQEmYB853eNmICF4a7z0fVDtZODBH5hxv YING/Sei8HKChmV+fVhUx6MR34lMRl+JkGEhrgbNYlohQQZfNB9WZ49dro+sGNLPZ1bEYtQ/yq T6Q= 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 05:30: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 4Jzwg52rxgz1SVp6 for ; Thu, 17 Feb 2022 05:30: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=1645104608; x=1647696609; bh=GPbMoL3MX4jnOalYG4 xolb6yV5fav/eAI5AHjuo0FmU=; b=ZKO7aWtgc2BiYC6dYFQ/hI7EuwNEUa23h1 PKmje/ddscTNv++hhEcnl3e741H/5DEpj6NJKwyhS/qcnThnCG7E//RyUPJS4S6w GNT2bW/OXEkSaYYB9jhfdqyEb9jOsEkpsvoEUuO8u8ZGb6WDm8u8DmLP/EuYAMVy t0qCGpv3r5o5kb/ol8YBF5LTYVaoSJlC7EvNrB/aY0nljuVN5AnPBc2lgysTG499 8HPvJEYL5rE7N8UTqso1RK0LEWJggCo34x1Jlw5/Aofyl0aIkq47JdElelyMyCZo EP4wfZHpjnwSe/vs2hUFfMfHFZOR/PmatRBLKzcoaW8Kc6TLjHOA== 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 3-7auYmdcTLx for ; Thu, 17 Feb 2022 05:30: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 4Jzwg35pKCz1SHwl; Thu, 17 Feb 2022 05:30:07 -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 v4 07/31] scsi: pm8001: Fix payload initialization in pm80xx_set_thermal_config() Date: Thu, 17 Feb 2022 22:29:32 +0900 Message-Id: <20220217132956.484818-8-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750051 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 0B73CC433EF for ; Thu, 17 Feb 2022 13:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240767AbiBQNa1 (ORCPT ); Thu, 17 Feb 2022 08:30:27 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240920AbiBQNaZ (ORCPT ); Thu, 17 Feb 2022 08:30:25 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50A2F2AE709 for ; Thu, 17 Feb 2022 05:30:11 -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=1645104611; x=1676640611; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C/MxlaPrgWa7HKKsPS5Az5xF33j9DbaItS7xYyT3z4Q=; b=nXSEV0kcGB2AKvbKHcvcUqKrIku4uZ1eTzTlAvUk2SI2NVUBeqHyAePV xFdE1h4Fb/wEDLKWDBzbd/SvGtJDrgKxKlFKqxe/srOxusPeT5s2E+N+g 1sgZsV7F0XoA97AuG146hSzPW54nEnlTvtWHuoSqnb6W3foJkb6Wh/ubA 490ctrTlTOkrY0GkYS1eUFpPpY40lcAl47ht5d/uoyA4xb/39nPv/Righ riCwqZaSQCYY1nbWOkggjOZTGSPfrxY/ET72eVKlFdK4rEht9T3hiZPQH hZhegQDrTQMNqohQHlL5t795vnBa6geNz65JFw4CF7ktyLxOaxWslRtWF g==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303149" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:11 +0800 IronPort-SDR: EFrCBrH/vb8zSsWae0NOl8rp6neTuL3HyZ1ID8wmyEbZ3CBVkubru8fA8ONLmWfThT/TwrPx7l boE4vheYGQtXSCQgez+g/pk8yAaMp9fHT/HyoODT8nL+mXIfxhhlYfIDSiPkMjEH+WGcUCO7tP HZG8Ow1p8iZtqtNnM2L8W2Iv2G1upYi+puk8qZV3+nbwcrtvTQ7/LUBgYtXgUx8h94TTYcdTsE wAC00YYVzoiQ+wcTj0jzVKG4oY706T4/MLzc7JhVekwlsODgbRb2bBK+jbu9DvC6CRbHIjAviC ezAsQikNHGMo8aBps403RXOp 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 05:01:50 -0800 IronPort-SDR: 3Bt8KLswaSJ9DN0sIO4WOtSGOYXm4GbreqsFYUUenfDO4BWPBcRJUZdeCLc/OIR1UPpmm73M7b aqTH0WomCn5dVunLsxxrtB++FbvBbJrRjlP8V5FvnjoY5bTH1AyO1uSEKAkDpIl5gWPuGbdOly brj6MCdmqWok+lZn4qbfxGBvaZjF4v4AhczBRPbbzuyGe0APsM7C6+I7kKCGgyrAz3rXfl4eqL 8qQwAMByivjoYWfwI0dNacWWqsGXoSPkANi7Kv2sQb/nN1w/JMvQT8QrFbloAkAY81tuPoP6Jx qII= 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 05:30:11 -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 4Jzwg66NLgz1SVp4 for ; Thu, 17 Feb 2022 05:30:10 -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=1645104610; x=1647696611; bh=C/MxlaPrgWa7HKKsPS 5Az5xF33j9DbaItS7xYyT3z4Q=; b=qIchhI7whiD482742EYAPn4LNmZ1CM0U0L uxJyUQoo1UVhGq7jZ//LNj6ee1lRyIkcxzqsvKFumQuDr7fppiR3JH3tGS2dXKZm 1hvWYueEOcmBfNGlTf78lRmE27kyUsyZirKNlF7LqvtvfS8kTCEo/NZimQ9PMjjn nkI2SbEZ/rAhgJbsw7MRM8ygQIoYEtfS914VDvMzCPj1Td1as5QZTglcjNplkAQD NDM82WyZnwohstueSVAXZA+4mS6uJJP5YcAFRjrsDVdccDDsng891v1I32xF6luf K3iG7lqbqEdcA777NdZ7QKC2u5OrJ0Xo9Xl0HqDvudn9jnjcqY8g== 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 srfIRaaQbHyI for ; Thu, 17 Feb 2022 05:30: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 4Jzwg51LQdz1SVnx; Thu, 17 Feb 2022 05:30: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 v4 08/31] scsi: pm8001: Fix le32 values handling in pm80xx_set_sas_protocol_timer_config() Date: Thu, 17 Feb 2022 22:29:33 +0900 Message-Id: <20220217132956.484818-9-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750053 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 D567BC433F5 for ; Thu, 17 Feb 2022 13:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240817AbiBQNaa (ORCPT ); Thu, 17 Feb 2022 08:30:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240922AbiBQNa0 (ORCPT ); Thu, 17 Feb 2022 08:30:26 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9149B2AED89 for ; Thu, 17 Feb 2022 05:30: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=1645104612; x=1676640612; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZHWwvTnBQeYLbzDlAXDuq3Laac+akeFkIm/67YdCyPU=; b=BOHE6RHDjImcB15zNDwhFh1+hu2gi/6mgHh46nyic/dqeTrGVIYo1p9W epFunu8lFRwP/HrUZTKbBvfH3TOjSANh4VCnorYFx2r3plkDJns29MqWQ 9Me7phtsYOzlroKuYumQZL5xwo4W+ryyeGsYFAdPJIhRO2CoiuGBzB029 1iOhVDAqD4R5yVDWSkhWcj3Yq+yv7E7MAQHi96GEOJ5jcpWQs6a1DVw61 S7p3cSP19F4lgf45ZcAKhb+jUuHWZln1q0jInA8p65TKtIYnhiRqEmUd/ USfMEHARepLgE4L/Jgs04ysqltKQftUdX1y3wFbt1GHgHDrWwLQOPKZC7 w==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303157" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:12 +0800 IronPort-SDR: eJ8gnuJ+HI8Jyt4AFXZx/LBEbW3ZbZmhK01Nb8Z6MPrOvNOeIBFa/njkkGFPVrLbCswsTX7PGi OKBLtuLpxZFj/oQSK77ZgIquk3Cwexzr39ltxI0KMYhl+Agsf/gI3pg440/tJPK8lomJqTnG8K 5PcIpDLh5+wgUpljdrMX67/qXa5BKpDWIrPnYj8L/dFY5PEFDQIf2NwRD83oUVAjyFxY8uUZhb Acb7vfYGglDCRsb5f4CZg4LSqSf/DTZtFBOEM0TuMItpTmPew2OURA5n5nsgvSaiP5pBDuUuos Q+yA8rbawwszDEL0tl9w4KwQ 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 05:01:51 -0800 IronPort-SDR: iNucdLnoZYN6Zcj4KXO0P2OLqfXhBnEdtcccY4ZXVp9gA8dfbW1EtwwOBDzUTaRa+Pm819Nd4L uIMy1PaAvDFkYYRwCwXpzpnvi/NROSArDZQqliHTZRDcX3z3+HXELJNxOBJnTgQCZckttoKuSI /e1UAg8EGK+G/pbriZNu/zHYmMcF12aXhCznF0elzf8ZzbuDxu1Fxcco/kp1I0SVpJl8NtX13z X3VgtouKvF6xO3olIfFgxLniv9hgNbrxhr+Ho0GKPj9srp007wSmiLwWVU94mvOK/ZAisZlHqV c2w= 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 05:30: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 4Jzwg81PyYz1SVp1 for ; Thu, 17 Feb 2022 05:30: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=1645104611; x=1647696612; bh=ZHWwvTnBQeYLbzDlAX Duq3Laac+akeFkIm/67YdCyPU=; b=mii4MaPu3fQcqpoix2dOaxCkRqeEbHefAl 17F9Cys/yoXg1lijqUlXxg8/EDpkVScn0Hvz28v+uKsE6gZI/s2mzeyGEz5F9B8c P+XWhcT2XRgDVtRZuhCL1xviwhjuKmlBJ9J0m1HtcXOcR6R46a/oHHstDX30Padq 4jclSh7ZA9TbYu65DbeQCLI1gIRSx2BjQ8GO+tzDPBBj2Bj66rk/6GfpDfgLzuOR FyKh0NAieGgIx3Zm9oOdbJtuvGq2NHI6Lf/xHEbiAIOXW72Husi2PWdSaOoeikIC 9nZdpJWre3AyHPGHADB16swMH1nZLm+Q3HJv5Zlgbqv3xxKh69pA== 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 9ockk91SXc8s for ; Thu, 17 Feb 2022 05:30:11 -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 4Jzwg64FKFz1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 09/31] scsi: pm8001: Fix payload initialization in pm80xx_encrypt_update() Date: Thu, 17 Feb 2022 22:29:34 +0900 Message-Id: <20220217132956.484818-10-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750054 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 EEA9EC433EF for ; Thu, 17 Feb 2022 13:30:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240921AbiBQNal (ORCPT ); Thu, 17 Feb 2022 08:30:41 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240907AbiBQNaa (ORCPT ); Thu, 17 Feb 2022 08:30:30 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA8EF2AE709 for ; Thu, 17 Feb 2022 05:30: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=1645104614; x=1676640614; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dQUjKQiDsJ8EX4GKIomyT/ztM2AAXt+07VinlMn4BA0=; b=XSA6VEPuRExm3JMAUZ7/uzOkryvqeKey4bBmkUt+7GOf1lB+NjZEPV05 oVuvVOER8dB/UiK/E+tCvnlTo3dkplUhM7D/cbQUF0kIGL42rRep9dVBL lrKEXp/qbs1HwHQcFM0cRO8I9ikeUIqpySbia3LOEVnc0YP867+Jl21wh QxyCofJO3RPhmhXZ7Cz7XqcAVxANZySQ3JcO5kIYE7r2zGp5oqhYQUptj z0a3a+m0Tf2/HsrmME1NuRkXGns4rgLEfnTv7Npy8qU+MQ5m98yLSLDvW QYh+ZWr6Bl4+Yq1yQNnPAjnlasY40mpYzhC2kc9s0S51Ic8JuS5/Y+uqO w==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303164" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:14 +0800 IronPort-SDR: 9E3kz8NHKjDEm+BQbrz7O6JEcVXFWh5FUFpH5xCIZjNdI4APbOGRD54kRkxGCx0JmZGRnMmZFe YQDZsua/AUVQBa/P6d9eJ0Icx9u5iB6H2Yit0G977m5JvJ1khJ4PokKy/sQC7UPo1xDnIemNZP C6XaDpkm9xG9eqoRD3orzytI1t5xUapuPy1dItW8z6r5c5zheRLUqQ8N7Q7ETKWpqtJKavrCmT 5bxXouZXKLkeNYqHT/1sdKSn3N07d6hZclINk92xdgwZUQwHw75JJOMxAkPjowSXpzfltNDJKp YLuUmwV1fch0vn1P3C3efXjw 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 05:01:53 -0800 IronPort-SDR: a20i7tzDxoyZr5ZDfDzUchxGArAsIb2wKvKeWnljAcvm+aI5bvW6Xi6+8BM+kfOA4fYunH26rd 5JrwBH8zjokDIrf4VO5L5kZpYd4QpPnZ+PtWOnkkytyJxZVhCgJWB9xYBgmssmpsQMpP6fZgod eKV75ynwZoc3G00Dqxm85rHVcNj7IyLJxiZqXBjdoHKe0zoJKd8vmmEq42uf+oX8DIk6qXAN3+ W0yyfMZzoNCuwAUST3fixUEx+1fYoKNxrQnHOgmfkQqz1bV4W49kGqZIvCYyFj3JVTtHDyEPLD PgE= 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 05:30: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 4Jzwg962d6z1SVp3 for ; Thu, 17 Feb 2022 05:30:13 -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=1645104613; x=1647696614; bh=dQUjKQiDsJ8EX4GKIo myT/ztM2AAXt+07VinlMn4BA0=; b=RjshfH6pz5FSYOWyQ7qkFH0D8HrznoygYs 1PGAwD9+gq0kgWnVfwGJrkOHRz9nhPrT2Ze39Jk68ld1G9Q8t8eR6OcO/SE1ER6W RX+XSzKCK23s8H8Du7cZbreeBnFodMfeIn2oT/rWvOoeaRIO6nuMDB+o6HPO3+/E uJxZkLA1S0QMBXYJSixU+gnrlvPebDJnwg5wWgbV4mBLM6i5Xg9vEg6V1hy7ycHb nbT2DTCAQvVQbEOUpNK+7nyGehUxO4eFEbSllSH4OsCUDfnbT1/rmkH8GRkd5H3a GLqZKS8GoOuGAT8skA0mJjmz+Diq6slUd9/8HUXX1IdaReCGCBCg== 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 FFUiS6nPLFd3 for ; Thu, 17 Feb 2022 05:30: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 4Jzwg80Df7z1SHwl; Thu, 17 Feb 2022 05:30:11 -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 v4 10/31] scsi: pm8001: Fix le32 values handling in pm80xx_chip_ssp_io_req() Date: Thu, 17 Feb 2022 22:29:35 +0900 Message-Id: <20220217132956.484818-11-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750055 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 11149C433FE for ; Thu, 17 Feb 2022 13:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240629AbiBQNam (ORCPT ); Thu, 17 Feb 2022 08:30:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240794AbiBQNaa (ORCPT ); Thu, 17 Feb 2022 08:30:30 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37A772AED8F for ; Thu, 17 Feb 2022 05:30:16 -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=1645104616; x=1676640616; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LvJrYpnn7P7dDvda1FFyw6fvYFHowDBmDvy9kpUTe5w=; b=ghlMyz0QQEuUolWKxIZ0XFD5dubmqoJM3XdeUAMoyY+Rx8IJCCO0OL1T pmJMN9CSvfiVoGNYgbHmWhdF0XplWa7WOHUMi6Kg19B8CWVYkkE1tKkPJ rYqZVxjEb/AxVVPSILnqtzSPsTUiSxB9idHaxAJAjyhBrrw0MD4NnvidL JeNYka7tlCgcgYP7consOIYilvd/RGfQ0TJXrECar9PfoCMqVbS2FnHqT 6XtlLXw8nFX4NZfF3VnA9/6CLncGCRGcu+wUb1ymCH53zSgiaM4ztZmO7 Wt2O/6QAtH9QX8xX4Ap7+ggCkPbsurcdxlugxDGPMLgQPe9QTaX3jgbeH Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303169" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:15 +0800 IronPort-SDR: WTKIUuQ8v/U2vFWFwNGDWJvkBCToBfuk6e205PXj2tUhy23v8hJ8dnNf4IQREv+sTYnd4nrpk/ Z+5KXeSp2FS4AXakPXo4XxUqpcZemd9hiC3slmEHC4vZm549Z57eRGyQpcaebb570NKAp53amh NTnYSvsQgtgMWWv6mjZ+lVHGu/K9b0y0kHOS6Xwb4EnRRVSvqrx8GyqzTGMgfnAGLjD94JNUZb yNkghaEwH9GAEDTqzTU3BNskX7/eQ0YuLgwVIEdipEgHnVKW/MT2lHL1xYuPb3YQ2Ift6PhQBl DYbsA+LraeVjs/N1GudaPGtj 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 05:01:54 -0800 IronPort-SDR: eaj490R087zF0IO3ZwNcYj3zDTZZ3AwqrE3WUD+ZgTi02cfdCCDJC/XZZYItPBfgs0A2sRCVNr 0H37qjM8ubUNv3Pi3jpceEDuLPqaqF7eZqcOs5MHkZ1jq+1VFEfFT6a4TJf4lB6rNgPlpNjcDi 9+0p4wFScnWTRj3w36un9DekVYZizlOdtKAa2yKjuBgyBduFuCoCgCHuQie2DsFBSO3XYg3cFL JRsoGNUW61pV9owMxQFMcBzu/D/yJ0nvEB/C+Ceszo9mG9KAXRGXuj6MUjzvbmAyGSvawJCkpA uLs= 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 05:30: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 4JzwgC44d0z1SVp6 for ; Thu, 17 Feb 2022 05:30:15 -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=1645104614; x=1647696615; bh=LvJrYpnn7P7dDvda1F Fyw6fvYFHowDBmDvy9kpUTe5w=; b=GWo9/iYWmDY91S0wYv9tolXAE/iK8ILphH HNeijjhJKVA+R2wIir3iPwtO0uk4Wr134Jb2TW+5r4DVyWG6qVVn3YTi2D11/bK1 zQFbd3Sc/dETTI4UOHspDs8/Lc1etWqlQAS8euhkxHfpA4Bnk/pe43w2LiJyqSqV kCFte0o6M7eH4zI7AoJusJycvAAzezM4VjIuyVYMd0ahF+j7dJJT/JXM2DHYIkCC H3RS51ZDnBM9elcsXvTw6fIDUhYAMsjgmTDCoawHvdbCnhOgxXh9345D8yhJYHOm DnI/EXY3fvryuZnV39AVmRkvbiRir45/O86a8q/3vIBymNwIFAOQ== 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 yv32vLo0Je2L for ; Thu, 17 Feb 2022 05:30:14 -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 4Jzwg93Hycz1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 11/31] scsi: pm8001: Fix le32 values handling in pm80xx_chip_sata_req() Date: Thu, 17 Feb 2022 22:29:36 +0900 Message-Id: <20220217132956.484818-12-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750056 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 81178C433F5 for ; Thu, 17 Feb 2022 13:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240920AbiBQNan (ORCPT ); Thu, 17 Feb 2022 08:30:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240922AbiBQNab (ORCPT ); Thu, 17 Feb 2022 08:30:31 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314F12782B3 for ; Thu, 17 Feb 2022 05:30:17 -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=1645104617; x=1676640617; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=isMoapX0/B1MJOpyA8jNGojhP/ZUw4xSusWBtiS0O8M=; b=HErr+5bL8/7nKQQQgS8eaSPmXla2z9JMgcw4xoIoscji01zMxHA20gic RTt5GyNkyM9e733MnkedvHzbb2rjvzT3fcZBibU+xi30yvJVRSGoP9FHF GDctGOXAgd8GxVuDiJutr5ghiBd7ZIEgj8bn+LH7mNTxKy1C3Wx1z60az 08ZzZ2CCuSAjsjLTIEyJIaSxcHAQKmKM/MYIHD6jhqG1XBzOId9E5ONCn bUIMgwhALyHDHZ/Jzjq4q9CjyiaxLte8tn/Oa9YD5rhqwHAJrB0J6c64a GQ5xX0RkJCv2xfNPQonq0ZpLD3DUa5OC2HdPrgGU7j1RNn5L18lKksGDF Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303170" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:17 +0800 IronPort-SDR: 5rgU+/jjy6drvfmIVemkwYym5fE5uaXckP5xRbuJ/tYJM0S30rZZjz5MwO0JTr0TBo/IQUO+3Y WBSUtG86gCH+lg0eceM68uj+Fz3dwjY12w1ynoQ3YYJHZB964Sf4LyeI5Lzk6s5Dh4efREMzj+ 0DbaG3yLmGrmm9CPle4Nil+WR990z8pL3c/GhtyTiiMl2SbskLI0aUK1sko9nIrzOe1IfJjnPK iLTaNZDnmS2q3x8Rzb51esGxyYoGeGKBpTMLWKn7X1WOYMlX21s1NmQIAC/hv64hW3UYLsH6y3 Al1yam/LpJgZM08p8dT3dvk8 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 05:01:55 -0800 IronPort-SDR: at0CWflymjf/Z+LrY1dnSllrSOPD01OTDf7/TQRq0E/rkc7d/2vbm1jttEHnhBHM6W5w/7KV4i 4w6pD6vOYHqrIoITpvMK+AaZyl9f5k21LddTYRy0e9SCtoxMioAgQXfKmWGVsmdr4w88QjFebM WYkdjw74K26Em0M0zVIDqhZo7kdxnA7XZYtvv+2isTuEjyBH7Hav+37X9ypUTwGi0hL/aigwSl cm7nzgHRpMt+Pdzgr7rqr5E9BSA7gnNhGy5g5NoMFnQU8kAvzZ6vc+3ViMJJBUk1sO7tkLhnWa 4Ao= 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 05:30: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 4JzwgD6028z1SVp1 for ; Thu, 17 Feb 2022 05:30: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=1645104616; x=1647696617; bh=isMoapX0/B1MJOpyA8 jNGojhP/ZUw4xSusWBtiS0O8M=; b=tRyP8cnmHPEXRLcDbDeTjJZUt1fpoTZ5zw au0e8wyKU8WRQee4zs8T0V6wsKDJen70CdKFzs7phvYlirDQ4GNnIqvBv8/Fic2b R3F52+q617/GNQ0gCvxTZyVNm4/pbm5zhmKDIlk/WDhzGCQmvZWnMiX4WhnLoR/1 Mn9v05O3zcMokyVNvW97Yu160wcEz1TjTkUhBqTqLGxjQFFnCToTyid20+51Z9Pt VwjLbHtnEcCtAy/Yjkbx/txEKYauFyrInimOqfboHep8eM2klrIzhUu7aAQ3kpTM FMomwFY8vq5OcKV9byhlXZV0muxtYl6QOTEXeCmCH0XjqRT8h71A== 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 2Xdw9WDVTOWA for ; Thu, 17 Feb 2022 05:30: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 4JzwgC0dhSz1SHwl; Thu, 17 Feb 2022 05:30:14 -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 v4 12/31] scsi: pm8001: Fix use of struct set_phy_profile_req fields Date: Thu, 17 Feb 2022 22:29:37 +0900 Message-Id: <20220217132956.484818-13-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750057 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 CD549C433EF for ; Thu, 17 Feb 2022 13:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240934AbiBQNao (ORCPT ); Thu, 17 Feb 2022 08:30:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240909AbiBQNal (ORCPT ); Thu, 17 Feb 2022 08:30:41 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3965D2AF3D4 for ; Thu, 17 Feb 2022 05:30: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=1645104619; x=1676640619; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xiP1M0lFxhMkb2FeSA/f5haQvFI94F08NJluHNNUbzw=; b=emiDe7K7vAq4jABx0frAvGH1XJIbwlakESBntSbVUWUXOIQyzkBfUd16 6AKcIfvorJKeAcSGPlvRvK4EdfUj18SF+8EwdJVSsVmwNb5fTz+urK6z7 nfrGWFaUVf6pcIqxNhsCqlcmbsC49pJmvivcOY8cU4wTJ/QGiFGDguK1K 2xqlmZgfVl2ESgwpCtr/9u7c6T4+39oFEvkoWS4o4bk7h2iZRmUeLJxTX K2JbU5Nt3mCARTNTfdQMhfA0YpuTRLMu6hioUGnZ1r8rgFOoX3fAhssm8 DrF22xSocKYJIiSZaDL4JOmBdSIrolbWOs9czx5mP3rE9it0cG8XrJ+tV A==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303174" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:18 +0800 IronPort-SDR: ihafkPllbugfp8hkekGrpVLJs0XdgTYtmi3J9ReVn7vNaCh7HMxzx5meU1A32Zmp4LJQpVQuiW CKxUdDmRtfeuLXk5+Q5f0XuyzG1sw7BotD350vBkJoV2li6MHrzh6PSD57BaW99g4SrwB/94aK 8Nrssw9T/y4Rnrc9VxNk40R3p4xSDCQcPI8JhcpH1YOOpQAHvLPjzrkQSjy2TLu8XXSu3Rg8qw lK4GYEAO35GRuKAaZCqwB+nxwa34o/3SdJEtlFF7iUta+VzQqRxhPxGJPjueqLz+y7mn/h0x4o md+x9eullS39ZVXkNJVxoGlf 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 05:01:57 -0800 IronPort-SDR: iU0fdLpHTbLgEsfoHHrRvNg02lfKDKI5NURS2pi5qBs+E+o9IiYXUcHl+yB4pNfCBdzbKbLekl f4HN7aPyf0Zwq2+O5aRw6IxRIVQBJ0CBZ1uc2eOgTdkHktMbpM8Gha8AF43JOTJNmgeeYEn8A8 3bt0f+Es+YKOQ4l9l4MrkP7VFxlVN2olbXyrOMOmJ2Njgm7syQbCGviUYtPQ7RGW7ExmegRSeO qk23yIWvcQWID90yHBXm04uXaxOogqlsUGc8wSH5GWVpU/jMeNqB6uYwmAZvgDNCK0vzQXFsNz SPQ= 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 05:30: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 4JzwgG1WgCz1SVp5 for ; Thu, 17 Feb 2022 05:30: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=1645104617; x=1647696618; bh=xiP1M0lFxhMkb2FeSA /f5haQvFI94F08NJluHNNUbzw=; b=Y5l2VScCvYC1WEVrcj/V0QUnNX78YInJQx jlMwL3enaewqQKJAYoi+SHC+nW/Rn9vPt+rh9mB26m4xRcNNu9gdKEP/O1ibgQVY 11qMx+lyR5xkNsZjpskSd98Eyq3Nrmv1suW00mtYBpwvUtPGM4p6miRE3q7nDzNh yZmp3bLppjMtdy/G/jQyfe6Iq9A5eaBWjYKEG/JFtculwkfO1/ZVXv++HrqdR7HB ti231v5YNMcX6LKUNzaFkx5jdmk+sVgWHAhgUQxG3M/InxooQD1sVb25Fb1LJR+T MpuSSxhDZnM/bwSe7zC6wa/GDlAsOEPrtFTp5xsvsTiRhSr44Rvw== 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 JXZ7RI6I01ok for ; Thu, 17 Feb 2022 05:30:17 -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 4JzwgD40Bpz1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 13/31] scsi: pm8001: Remove local variable in pm8001_pci_resume() Date: Thu, 17 Feb 2022 22:29:38 +0900 Message-Id: <20220217132956.484818-14-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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. Reviewed-by: John Garry Signed-off-by: Damien Le Moal 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 Thu Feb 17 13:29: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: 12750058 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 2C880C433F5 for ; Thu, 17 Feb 2022 13:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240938AbiBQNar (ORCPT ); Thu, 17 Feb 2022 08:30:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240925AbiBQNal (ORCPT ); Thu, 17 Feb 2022 08:30:41 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 253872AF3E2 for ; Thu, 17 Feb 2022 05:30: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=1645104620; x=1676640620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2ZQE1pOE9YcEN/n4KyjyAVRN9XwlQw1FqxLrAh53aEw=; b=CT6FKf+CLIc+ArePYvxDJCTRugoeETI0HCqIuM68swep5DMZSmhQkq5y uQsrs1NPVlZ/bYTkjdAsNjhMxSA+aepr5iD9LXKfmWPqYSOq/RUj94l8A p6+DuqFH7XivtOGaQDSId13BViHlHTmRiQmg7i22/ZFMoAC+pNy/UKZsX M5AELLu8FD/BoU/+OiIgwPh5ZmLsasfaiy5/OLN63G1EZnQ8JFL9yy3zP A+SQtTtfolm21xNdTnkkB4Jm3jk75oypDoEfJz+eXFkeAcxGxL28X4Q/+ ZyJ6aKq9jSaO6vN5fC/fMhctOxrHjORwqN1TfNIuSbkX1+zxlSDwnGib2 A==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303179" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:20 +0800 IronPort-SDR: 4dZszbW5k+1gKkKXrW5CYn4wP1xr9/iCnP0pcP/cd8fIQvW2SHeydHO9dZvxXB1MPwH/JLHms/ 8T8Kx9wOHq1rUpQe1zMvXXLQlcORj4FkQMZaMItzL9bX1tVL7kFQhMJB1oBvCo5enGL5a0pPYN NiruxkK9yD3ntLpn96OlodbaailhZVSmte4zVEbtncGXjR4L7pewhVZnjxKnDPeFFA7PxisAg3 SPXi9TefL5fNQjEOdl3sQ1D3HE0mTJYpDoYs+r34pSvFLoPey3g315v53QZZkAL4sH595K06sG 5XWnHdmhYy8p9Yx53OEmEqQs 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 05:01:58 -0800 IronPort-SDR: N6f2HNYY2s0kc9+3rEm2H4nuVQ5iCW9vzkTY/BZCkKOksBC8PMuiLik0b/5x6AI8KNm4wWBzsS RpIQ/e5dW1LE6+M1wgXgYDEUmcseHUL7xPsMWkzeF3BdxDmXiqG1e8y11PH3AHPfkoTggNUY0q ETHsM+mbuC9W9dqebtkH1pJTZt5+oVKkbgcbDR8/6l0AxFJ1S4Fv/iDoKAg5WikQr0uJVnkay7 Xnri0Mfxfe/UaZ5gRi1fTEpJ3cAxkIbe84pvRbxhW0q8Z+RkMjSZab2KZPsodxNefsDVFSaFjm zYE= 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 05:30: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 4JzwgH5CgYz1SVp5 for ; Thu, 17 Feb 2022 05:30:19 -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=1645104619; x=1647696620; bh=2ZQE1pOE9YcEN/n4Ky jyAVRN9XwlQw1FqxLrAh53aEw=; b=kChRK2xLai51C/zfQNpYAx9dJdXtPy4HIQ dxxkBJGvmcsQ+f69sNYsHH0VbTl3Qoil+P5TYu1HlDtfLGwb5q6uCFBa24x0dDBb XZoF09PwF4lM+BdrMZUgMy9NX6XKFYssodqcouPvGRyOGoBzf2VNoN3/ON+IyiBY RON/XA7xyVsxXo9zD18GWfiED6+7I+ABXwwqdbBZ7zikC/HSZxH5PX10jPwAFTVt BDy/UMaLPCGscvlSoeX9gzw5IkjsOVMfUNjlanLDedoELqa/ZWPBs/B407qbZOEb c5ufLta6BwGJJPUY3hzxyMivRTmuVzHeJA4GRk7SyuU9uxS0Ko7Q== 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 5WGpckGfL65t for ; Thu, 17 Feb 2022 05:30: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 4JzwgF6tz2z1SHwl; Thu, 17 Feb 2022 05:30:17 -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 v4 14/31] scsi: pm8001: Fix NCQ NON DATA command task initialization Date: Thu, 17 Feb 2022 22:29:39 +0900 Message-Id: <20220217132956.484818-15-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750059 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 3CF7FC433EF for ; Thu, 17 Feb 2022 13:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240767AbiBQNap (ORCPT ); Thu, 17 Feb 2022 08:30:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240927AbiBQNal (ORCPT ); Thu, 17 Feb 2022 08:30:41 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8200B2AF900 for ; Thu, 17 Feb 2022 05:30:21 -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=1645104621; x=1676640621; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I0yWM4Uw/bytOgd0fDYDX3YttfdAB2/YpBuXlQAFqBM=; b=oiZTPZwctCfmLMETwQn8BPagBedFG/GfVnXHiPQ+8KspAbEK9zLH2Ku7 M/h570XeOIZ8zy8wabhqRs+KOCUokYS7PxR/I540yl6uqjy2VqsZLxBG4 75GwXvyn605rFcM9jQdIfJ1nqcEUf7eFdcain8CdlrOaLOEod/e+kOMh2 ckYKka/J8HNdThs0QXGDTdqzRuWGEXF8bzjenRfiZsfs5bFQOXoGxsj43 zZYZUsMHCCvHcyrf3HuInhcxfcZ5FdExXfgBKFMioMeL94fDX58OutG4Q wtBtJLufEEZT/5uJ6/51QmhoeW4opg7WqyTlQGaS79R2vSjOFrBK8a54I A==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303187" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:21 +0800 IronPort-SDR: kbi8oerXJboVx9lKL3sV5EqZoe6yqm2Frakab64DWyKRr4IwBhZr1/yr0AqokGmlt5Abcjd8Aw 6nZGqbSpY1N20w1RXN/PWBooWryCt4B+FBx8aHEF7Lo4cSui7YbbQtrfrh8FkMfQKZt9iqCiHf hxobWnhr3zrQ2WjRTgT2WGnwC3yvflX93lfFtgmR1/ZTgWHRnBZAqKYT+JhChLGcoMmF+71Cl5 HCNaJmz+0S9/bwznv/u8GQMEt6cRxIp7X2ti7ewv9S03+j2VTTmD97tgmmbjqqJiZ9/jLr6zQw 0kCR8p2hRZTx5fEnn89lqsf+ 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 05:02:00 -0800 IronPort-SDR: wAM11K86sFBVR8CydEsi/baBvCraI6Qxj2LKqiC9iDIgel3BqIDZMqBJ68F1opYC+tP2tG6QQN Wf9/edIIJWVqOJjCD93XwigV9Sl7bOS1AjSghqZVnohdkrP8Y7dhRqe3H8oQ1BTO4Og5JtdzoR KewZ0efeUxH9pJXup0vdVDxsfDmOwvesX4X9xHQzp3hXV/u0nxLGVDzrWHhy5Vk71LspoVejwA pl3R6NyaAWQX1aBHQj694M7g6jsHsbFQbwkUT5CZWA6EB4bBhKNudqtWSeHWPLgPXbttMn+juZ k4Q= 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 05:30: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 4JzwgK0wyMz1SVp2 for ; Thu, 17 Feb 2022 05:30: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=1645104620; x=1647696621; bh=I0yWM4Uw/bytOgd0fD YDX3YttfdAB2/YpBuXlQAFqBM=; b=d0CvfOj3VYJ8+FZxuhWQhGC6x/3+W6EO3P D0yHgyhakshKx0mHlszDb+cYFfTHqpv6T8j54zypCOgK/avrURTJ+BTzIzAO3HYC udzeuxCiDtT8bV+erixqF9fN574AejrKluqUBEi0XEB36YZwGF24iWJlSYgUXptf c1IKjbrkv/FHkWTDYZGJ9iTrBLurSakXP+S6qGM4U0WNf9ddLE+cym4kTs8TrJ2O a4ZPqIb620MR6Pr8/lqSIQtxZw48Qi1rhHPdg2/KN6uQlmdagOVLtTd3cu/PISfX WreWSYas2rEeRcXo6vtCP+nCdvxXmp9n/9H/++6EsQN12Y4OfSnQ== 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 36wbF907_IOM for ; Thu, 17 Feb 2022 05:30:20 -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 4JzwgH3TGbz1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 15/31] scsi: pm8001: Fix NCQ NON DATA command completion handling Date: Thu, 17 Feb 2022 22:29:40 +0900 Message-Id: <20220217132956.484818-16-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750060 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 7FF15C433FE for ; Thu, 17 Feb 2022 13:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240794AbiBQNa7 (ORCPT ); Thu, 17 Feb 2022 08:30:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240928AbiBQNal (ORCPT ); Thu, 17 Feb 2022 08:30:41 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 336E72AF901 for ; Thu, 17 Feb 2022 05:30: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=1645104623; x=1676640623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+5QCLKkX1tq4PVqXmHlRUBfb2x38QS5lZPfcIwY/Y+0=; b=nZ56aZxG97CBmZd8sFsYW05YNsBX26FwOsRdMG6TaMJaZTnPN8UXKlCF RQ/dFKAGuf4U8I2MnwrI1LA8zma65zIOUo2VKpfNUzQL+K74xBFNxIck7 eNxDqIV8RHtR9wf8fmRQxiyg0FqGiOJoHlcXPzmwH//LXZp6XOiPkz2jN lrWfaBnCEpGt/8r70/MZqdW2q21RZNgbkO/diS3u4mg7xVhlps7Zupylg TwunYsKhVOcAyWOp9uB48X+tC7QtcAO5z58JfL/YJrvWMmYj+qFyhP7Fi L7uZu6KX8eVUq7S/BfejszvTedujM54IJl7v7QmBn0+jUOcaQzV6MV1eQ g==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303202" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:23 +0800 IronPort-SDR: Kl9AUfQVp4atJINlQUDIYRNdGr7+TdnR9/Wy04WO9OwUjHs68pAFdzZEvu3aIKbqzikSJ6BduR aEv9ejQeVY9DaaXbjW8hFg6pMhww+N/elDR9mqkCBdTnH9S049FL883xHmRsJpfsOe/M3J3oCd quFVbPbwHl/Q0wYzNtYGNdxKl2dv1VlNNy/7ahSZdbB9XoZg6AYLVPAtlvV44fT+6ICS4jIuY8 qBkjD5VHBKs2m5CkVVaWsbbOZswV/8h8N2VmjuicNiPePgpeXPnPesXSevwlRrRO3xFAVnOgai 9MnbIORKZqhFiEa/PdEGpRLd 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 05:02:01 -0800 IronPort-SDR: HTmwLiuRFLUHeaMg56EU56FR1Q/QsC5XP74uADUZAbAl9dgHwvyGQrpXb2lBoZSaEWxSDPzxKh PlIOj0WXLcf4IJlAr48X+R4MPxMBaS07Rpuve7vrJ085kuA4UjhSqGwyyYkKcGiHwlTc1WW4GV nYk8QqkIbg5bPuAIBuCA3nBsoKp3I504RkIvu5m3P8ePpq9hX46r27AfEZicynBymfYDYur2IA n6owjPhTutbLcA7wHVv+2xuq+KT7FW2AW7FYSl3FQcaHQLT4MeJccJWGKW6jXngnWzHyy3bt4o GTo= 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 05:30: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 4JzwgL5LXGz1SVp5 for ; Thu, 17 Feb 2022 05:30:22 -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=1645104622; x=1647696623; bh=+5QCLKkX1tq4PVqXmH lRUBfb2x38QS5lZPfcIwY/Y+0=; b=Y5If0SiTlrhoMI9O7lQTq7k1LH9w7X+RaT QxRNEF+py9dKvRyMxuIkEIw7CSprO2TUPx6VRGFnhIDdUogtGt3ZjiMiRXOlWiDz s4vNLnnhlsFh1wxjwtDTsoyE442zoNAtSKKRcaNAOWls5JThxrf0XUX8kQlvXKFv HI9I1iCNwDz+6QuRJzhcjxlqkp49gvVTQeJl0mc9lfjG8nKbpe+fKXcV2PpZZM7l BD48BUCoxbPjDzMcoRFtG87m7FMAeUX+jcCEzihbNzPk+EZXgedCPCPNUOWIURAc kkza1vO6x4vxyDHHDvsEEPSq7sF4Cl9wTZa7puT7epUb1V32u2Sg== 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 qrHdmW4qEBRs for ; Thu, 17 Feb 2022 05:30: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 4JzwgJ6Jstz1SVnx; Thu, 17 Feb 2022 05:30:20 -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 v4 16/31] scsi: pm8001: Fix abort all task initialization Date: Thu, 17 Feb 2022 22:29:41 +0900 Message-Id: <20220217132956.484818-17-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750062 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 E258FC433EF for ; Thu, 17 Feb 2022 13:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240925AbiBQNbB (ORCPT ); Thu, 17 Feb 2022 08:31:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240929AbiBQNal (ORCPT ); Thu, 17 Feb 2022 08:30:41 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3ECE2AF904 for ; Thu, 17 Feb 2022 05:30: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=1645104624; x=1676640624; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TVMRHdQyTJllbT9N8v3MkuVcvUSR3sbRM1CaOETmwwQ=; b=mfmpNRsISmmScbb3mgEZSL366IncDXYnKSfa7+exeZBrZT1tdXmiuzPq k9FvyEW+vvliGMAZ5DmwmtGon9QwxAXsa8W3DIHY6uCFa67e+1cI293e1 xvaasCgBVS3bnkz+iI56jx2lYHn8/o13Imo4DPzJwsZ6DyuzKTslrHcb5 1xzJW0/r6X4YIvh5hYToWVX1erru+8oSJrqwi2DN7TsMku3bZ3O8Vmso7 mAwjPfkvrRG3ZxXx61FLInXZKjuw3wp6Ih1g5OhWmiJLgrSQiskPXU8b+ QlD5NoELmWMhj3+cGD3oGaoWV3GVU17zvppJf8X7IR6I2dqi2UpG5rz9H Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303210" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:24 +0800 IronPort-SDR: 2qm9/HUnoDHuH2mvyPPKmf0pQjhe5tNxFEa9Wm467vassXM9vJgVG6mmRCXRzilu3DeW/prSty CzpZjXQF5sdybZlFOvBDTAkqyeqjbZTEMQx0TLqNyUSChCfx8pqj0boJCYDgK/haiSiMSuOacj j6IlNxg5pe7MT6MCVCaAqGqUYfXSO6t57MXH/zoBgT6VL4QVnQlU4y7aZSH4bl6rl8vmehlOhC KcIgZ3l1PtRMUnTVYA1lnCLsR8LZRXfYh7xrV1Kz5uCiYSKPd8RzzMKXb2LzCBP0Zko4geDjjX nLSy/KeLYlA3P6cLblE1wWL+ 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 05:02:03 -0800 IronPort-SDR: 7RsJXVrEm0RCp0VwkKh7s7KW/KWrhmqmRKbFzn1vahX4P7+plrnK49V6J2YA1YijofW2+o/pS8 4D1N8SKx8BEEvuXoHHrVfBUUBKFwtcI2hDnuzVdeg8aFkmov4fq2MvuAas7Kzq+kbSRbvUhh9+ +Txc7Zj0N5fuLMpPCNOUEhRxsgpamAxzw4gh32vdlfCkfzpN/kE15sFKgOwuzojP4MI+1esT/Y 03SjGk2NEHnZcqBg0si5vlgZ5yx8u0wlbqoNA8FS2o50vAAGhYYN4HrZbDW/HU9qiL/SLTKo2k kPE= 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 05:30: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 4JzwgN0f7Wz1SVp4 for ; Thu, 17 Feb 2022 05:30: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=1645104623; x=1647696624; bh=TVMRHdQyTJllbT9N8v 3MkuVcvUSR3sbRM1CaOETmwwQ=; b=Dvr9iIPP0L2bO8iaRhmi11OCEwQ94Q6qdm 51t/n79s2XTV+7/NwaxaKF2pvIR2vPn41Xl+hMuND9SSYKrwuczfKWdazFtp26AY kN7mkhYGEhcB1a8zaMgmU0Jx0oNhWT0t25maxygSvWua/NcEKMlXCk6NjTymp2rl 0UuJtQ56koDc9tNwzpJhPUqEuzl0VHPgQDmcJ+RmaCCG2T175XqZjY729hX3Y/eq Xi+qSucOHpFwGS34mDsFNHgmuOeIu1bDvbOmPTgVmObcPThFpNqI8M0AgI97Ijg0 JBhZRdWGW2+LsbNx5TbWvSXcAORBbEdF/fQY80Hukt6YGbPevuXA== 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 6YAe_Gds6twE for ; Thu, 17 Feb 2022 05:30: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 4JzwgL2yZmz1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 17/31] scsi: pm8001: Fix pm8001_tag_alloc() failures handling Date: Thu, 17 Feb 2022 22:29:42 +0900 Message-Id: <20220217132956.484818-18-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750061 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 2524BC433F5 for ; Thu, 17 Feb 2022 13:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240823AbiBQNbB (ORCPT ); Thu, 17 Feb 2022 08:31:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240931AbiBQNal (ORCPT ); Thu, 17 Feb 2022 08:30:41 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 002282AF90F for ; Thu, 17 Feb 2022 05:30:25 -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=1645104626; x=1676640626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/T+9kSoSa358h9hTSLs4JZ/Z6YNlu4T63rCI1ItSowk=; b=A7f2SXjVTk+RSyW8gjx8ZZeOGyZIukLY3AwV5XzRWTwvcCzqCsc5spqp qu1eI1gT1EIUaFK/x7WuW4OGWln81kunYfNRR15J+WPKKgmDVxkb1esc4 UtrG1nVpfwJhQXEVXy8ufmaMy0nXHDyE+pIRVXsfIZcwuUlBSF5XbKcdX QlbzxR5swng/zMkf1o65/y44cvIsNEQM8Me3KTa2YohdVQb59CbfR2xmP LYXp9/TuHAIa9uC4man7srHC7dTf3vQGEXPV8MfirlG0F87vTmneOFXC6 3OTQe6AF7FGBV7uDthwpe9ZiJM9sBAWKv5nW/AVwj2+pOP1KmBu24n05x Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303215" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:25 +0800 IronPort-SDR: hYuHzBBANpB6TOvFJpFjnF6IrY867BFNSI1NZw3SJaNi3x967KILnHpm2vdRmtu2ojntkosvGR CrWh1wXDFCeVrE1qT8oUHsBBM231zd9JvIC3KXtrDjOK3fFY9awdxriIb91zgfKb/aq7Mq53/A bsFuXxfFgDj3xvqBsSwzYINUf6wP1PGpyHnPrajsDwndYa6E4zN/NZ+kyS42NcfY0/vqtIoUtH HlKV0hZDPT9lsPR03lxeNNcAfOICrjFk79mApEQB/D7kWJ6obJ09tHj07i8BzMB/0PPnlOgzMH aubn3lS7v9HNx/RwiL1J7sRw 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 05:02:04 -0800 IronPort-SDR: nTTal7MzTNrWHO9b3AjXr5HzIjn+QlfNpIBLVzQBOMmMO6ZibkZketZLHQP26D719MbafQ883Z 0VKToQTXe/hL41WNXkFrW7ZTiU50c7N+Ojse9vGXxxn+NJ4aRlqb812vMr+PCmHz8GD1BRW/Ha WThykwMJ9JOu9g1vBwnJnx0+CPk1hEcXuVecOvao2FHVMBKzROY1d7mqLKIB3i8Ft0/2+nCSgy S9zKq0SpWGvnZNGZZHXkKTJgrwxcEFFgBLhmjPw1s3Wd/zou6S0GJlABU5FFxsKPKrzm2RSDlQ 2iA= 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 05:30:26 -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 4JzwgP2QGQz1SVp2 for ; Thu, 17 Feb 2022 05:30:25 -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=1645104624; x=1647696625; bh=/T+9kSoSa358h9hTSL s4JZ/Z6YNlu4T63rCI1ItSowk=; b=I/GJ1Jqr2RumsiYDPBsgX5Hh/OWb7pZNzk ZMlhiDJvVG0ssxM/NiPGikze8G20phNOqkkH47HlvwVcvYbmfO38Wq+hDIh3Q5Pf Fnr43PzRyDlX4KxG8wHIY47dkurQJs/MbYwJTz7Hhth/sL9HsQMFwgMDa+zUo1CJ eezh9+/owbuMi23l84S2XohyhiamolB27QfUFZt7my8zP+wpRJTGrYDopytxMSxA U6GMZ87gcAWjnF7cdf2r7mIX0ILQpMWsYgUHRSwCqRaUesMbTonz48VhgSGNmQi3 PFuPQfVPyihX0IyL6n2hNxRxl1ldh+Folr7ee6mmj5y4v5GmvPZQ== 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 oV-td7bFNLAT for ; Thu, 17 Feb 2022 05:30:24 -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 4JzwgM5kNlz1SHwl; Thu, 17 Feb 2022 05:30:23 -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 v4 18/31] scsi: pm8001: Fix pm80xx_chip_phy_ctl_req() Date: Thu, 17 Feb 2022 22:29:43 +0900 Message-Id: <20220217132956.484818-19-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If pm8001_mpi_build_cmd() fails, the allocated tag should be freed. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 76260d06b6be..a5a99d23cfbe 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4920,8 +4920,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 Thu Feb 17 13:29: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: 12750063 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 4DBAEC433F5 for ; Thu, 17 Feb 2022 13:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240928AbiBQNbC (ORCPT ); Thu, 17 Feb 2022 08:31:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240933AbiBQNal (ORCPT ); Thu, 17 Feb 2022 08:30:41 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 505572AF919 for ; Thu, 17 Feb 2022 05:30:27 -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=1645104627; x=1676640627; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MrC1fw2nz70gALcx2cH4uiSlZsu3d6xxykw4zEymJrs=; b=rf5bq2jQvipXV55ydyuu+m4SFRE/sSuflrq9BkQEwL2HwmGTWMW1F3rO nDyzXNsIYinXTaH0hUVwvcdIii6qQHCDiCwBPpwQFx+9MkIwpTQA5ANvo yH4v0zYmI595KL7DQtNHPw1yGt/5Mhu8cGKae3Kb7qLxiE21C+q6fD/4d mZfL6/sb8xfy/2djUBaPqtAZBVE52KN+2oPCbIcBVzPgF4hPe9xnkd7TM PvZ10n97b1otEgtK9TdOqKS4+6ytRFl07bCK0ipNuAkKtm0WHeWzPOXbQ bPwyRP7jnlSzWgNw9ZLjOjHhWm9HHW/9xtz4wXlfB3CGKvmajh/T1Gyhk Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303217" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:26 +0800 IronPort-SDR: 9CbMo/kNn1+3ZhLhwt2cEKxYGdIj3lTrXL4UuqSRMm/G05f87v5mgx21+1htGXhzMIKvO5KZEN 5ODBm+gWM3UjCpmh4zITwSxywJLMR3cCcgUJ1N/eqM/Ny5jUHOJdc6sXigdit1XJ7Chfy+kpmR HJRmn5SCbiuYDZMyVUpAWdR1TdGGCj+krMC/JrYlEkmg1iateybKTWuX5tMqrjsUstB8iCBKwa RFz05gW+69leblRR/dW9U8fSpF4AuWUbzEWZz18fe5RseldVpqe4rdvk81qGJI7wl/jlbADZhI mJRHeVz6ce+1Rm7bWgOfP/bi 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 05:02:05 -0800 IronPort-SDR: 0NUVtoEfZ1ycfwzJhai7kvpsCnvz9fZzdTD0ByiS6++PCvrdUK9AAmvvcJA9ieDXZ2AxdzktAY 0TczVwKw/LeKM1ootYmW02LAb+AOHikmWulQDv2EoZgYvrU0AznCbV0WGpWAANp1jz/8vq92m0 tpD/tNMQXj7wPlHfFfZ/0MLE2m9TcFISrXFN3pIhTPdVMcGLjXcIDKKFGV1yZjlcgLmf5mj95s 4F/3fTnkXXkdVMf6H8YcIeY1ZQVKgOyzX3Liqc4hOqV5f5bjX5+mlTIMupvHUU42XTC1CzYl6g Jtc= 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 05:30:27 -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 4JzwgQ51Qtz1SVp3 for ; Thu, 17 Feb 2022 05:30:26 -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=1645104626; x=1647696627; bh=MrC1fw2nz70gALcx2c H4uiSlZsu3d6xxykw4zEymJrs=; b=ElGbYGwiMjVYEE+2WhYmJNWy6ewyJjeqgr xThkv1OSGGEnYEBOw/FrlMAVjsyLnPGCY+61esW/31hmmp5nXB+/zG+6N1oIqeLs Ba4tgRMcJRJOGUBia+HyBTsIJW2BB2KuOIqstoFIpOhXDL6E3HlxbFBonX9dpdVD bPytvHBmjzkli/YrLkBqMJtdEgnu91dezvLN+JgtJP6sJvKx+stl7MjdGIy0veJB x0XVO4OX8HS3CMo5gdMfFgO25UU4DEsNDyRrR9tAG/cswvSmserw/lk2W7m63EGY np93aL1kuzVSENyhptaiO2K1O6kPScUJ1wNmhy5VyY6hM7akDqrg== 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 O4R_HNtcEZcR for ; Thu, 17 Feb 2022 05:30:26 -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 4JzwgP1Lc5z1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 19/31] scsi: pm8001: Fix pm8001_mpi_task_abort_resp() Date: Thu, 17 Feb 2022 22:29:44 +0900 Message-Id: <20220217132956.484818-20-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29: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: 12750066 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 F041EC4332F for ; Thu, 17 Feb 2022 13:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240953AbiBQNbG (ORCPT ); Thu, 17 Feb 2022 08:31:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240924AbiBQNan (ORCPT ); Thu, 17 Feb 2022 08:30:43 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49EEE2AE2BE for ; Thu, 17 Feb 2022 05:30:29 -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=1645104629; x=1676640629; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=txSxucpW0RHNmphEKQuGPgIQcMEiUrS1IVOyv7fFrMk=; b=CP/bgMMuRxQaoX2VlfcEf5Z22q4GCNFK2LytyOeanjdsZREGzcuhoWNf YOEEvVyZGOyzXte/+S+WUV/PdGuApNz2hv6uthBFRGnGTX/o9X+SVQvGY 6YznavmR7MucAJBAlIe9QjNXqg2DhfHlsE4yIIVRs5tzPpI72FYx6PMAb WOuCO6ChHCcxVUKgzspZDdWSM0nmpGZskfyS1BkLhN5F9KLfZ/XKkJJVj 7PcBYtIJHgOXSoYjtsL8THXXCwBD5weC0wIzRHDj/NwlRkdyhWEusYXSQ vrbcOO7HtQkdZMWwdnWi8sa86bznU7L4vuc3SgnoFtDiN2Lb+sUN5V0Ls Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303218" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:28 +0800 IronPort-SDR: J+6reeJlJWPLve+Caew0O/mX9F0RSQ9EL0Y42O2A5uXkGDZ0YZ5/nM+tXNoOV59KHjXKfZ7HAA KKiYKfYKqo8KEz69jxQpTOj7ZmY14UVbWKACJNMfLlGozgvEMzXvpa6ubGiD02CRvh0ZkW+wcF 0pOUFZBtO9vGnXE5fwDys+wSSNkdNw84w3B+JAVMEtopNn4EEoCf7aPzxtex+jcD3XouL6weTw Ujhelox0Bw2rRzMDhdaSolAGyT6436pQtbU99AZvelvbbwOu4JsT+LdvZYkCsMv7O+fWhiAZj1 whJtFBxfv+DEbkeKpSZAwqzt 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 05:02:07 -0800 IronPort-SDR: gduMTwTJXh/7gRf1HRoNOwBtD9zz60bPlmitPXWtXKomnYDwM0SVPBay0PipYYpPLm0Zp2vL8P jWedWCfcnx8Ybr3vGbj4ftvLBSfdbMlATjweq77V2s31EPQfsbYPzeaypigdl/CY7n+mgcTxcY asRSPf5Bpz9uZ3PhOpn0Ey/NMPuDfhCHRnmWDwcsQ/7b+KY3WCsjZJ7HEtUAnK7XFef+x/5Lq9 l1kiCAPNp9KNPJDZveb6YNHp5x6ZlbgF7bpN8ql5RSV8Jws0oG/NJpNT6Ty9YyZbUsh5wifg0z w6I= 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 05:30:29 -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 4JzwgS4bqkz1SVp2 for ; Thu, 17 Feb 2022 05:30:28 -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=1645104627; x=1647696628; bh=txSxucpW0RHNmphEKQ uGPgIQcMEiUrS1IVOyv7fFrMk=; b=Eea6wNRNw6jZC01G6e2jlq2cIpKEGgjfEQ e33xG2PZ2w3wGomlFkYrni6njoccrMbjheA7zn3PoRuvWTFINxM3kTdOcHgka3QE 8oxsiNc+aKh+6b+elrqUHR8D20g1c6Xg24kW7wT9W7JewtwQxEsWMHNyxl0NzQeI /0c9Y0M8IOuSMbIgPkcSZnho5IBDKnrUdMVr+SuDFk6y3Ps8FCWS/lDlwRj+x2lY 5ofCpfzkKJV2IXoemTHA8w7vGBY0zpe7ixHmWf8NKZtpNMn20JyU8eSw5thnVUd9 3CTvS1VCshDzI8PljLJyKtOpZL/XDwOid2L3TCTbY1qlCBqFhlmg== 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 YOnX0ROz5smH for ; Thu, 17 Feb 2022 05:30: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 4JzwgQ3hYpz1SVnx; Thu, 17 Feb 2022 05:30:26 -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 v4 20/31] scsi: pm8001: Fix tag values handling Date: Thu, 17 Feb 2022 22:29:45 +0900 Message-Id: <20220217132956.484818-21-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 a5a99d23cfbe..4419fdb0db78 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 Thu Feb 17 13:29:46 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: 12750065 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 29304C433EF for ; Thu, 17 Feb 2022 13:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240949AbiBQNbF (ORCPT ); Thu, 17 Feb 2022 08:31:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240950AbiBQNaw (ORCPT ); Thu, 17 Feb 2022 08:30:52 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B5EC2AED8F for ; Thu, 17 Feb 2022 05:30:30 -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=1645104630; x=1676640630; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q1XJZOgtboqh9FiddO0t3IN9iQ7iOxHQjbmGMCT7eDA=; b=PmJYPuWR8NF1kW8nmSYNEQH7wNC4VoneXZID8lWL8KzxzPz48vytU/i/ DQmgnOHFYtja+fdxxIPq+AbciUq5cO4mWjd9C2T5H/2jRkf3E/bU6jgQY TGKRZYG1cYQz8atSae6zVHFlh7RwMxfJD3rtRG/Yys5jnus4WMQoUoHO2 mDlkDXt6KlUlp+T8z6ivvmxGttpyBLbQEcFKmD1n+ytCe0IU89G5rJnKt QdPZEQilNurKYW9Dt7ni9rp41w60QXp3dqcYnST2ZtLK9FPNAVdlGKVma SHI4NjOgMuvbNP05L4YgNKPBvdHv7kewULkZi1Tg/NZiKSOVQZXVxO4og w==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303220" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:29 +0800 IronPort-SDR: H69YLGFWSfEYQQWyVLfESdMW9pgS/Jxt8NJnUb/GEJ+8fmCwr9HvyfXsMaTVeK57/RFx9dDuSA +3tFJcQctoTDNqWexyDSDSUD0al8EylePkuBgr3/8dwxxj8ebrDfpTmSBKPFqbpaqIrEfFnAP2 Z21FkTSrxe6lm82jOot9/YpROYXlDo46XhEpMI0FfzGVb97/K9uTQOq6HyW8oFFTBiib1lMMEE l3Fsoy95xsGRJ9BFKO2T5FFd9wuXVccSY4BkeeJzaEPKrVbfw4uGveh/3TFkdhqN/UwuV3XDib IbQjImUtK5fyrIMBi65kPwoT 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 05:02:08 -0800 IronPort-SDR: JWRnjmEilBMzF5bd/wft0x0dJqi22bu+YXWNvz+rIT/jV7hJPEjymIirlTuQ/k2mdEEKEfYM7W tYZMomasH4N0FUsOdiMMfqy+FJ7h9l4wPKgwWYepFN02DLto+o11cXl9G8JBkfsMWEEWhmJOK3 uSIEIKPV+sqb0KpEl2qkl4zBT9LdLM0umz1dJd/csSSHhdyIRayqEttgpAdlpxvDXmDQuNttaS WFEux1q8O7/hTjN6NKQldaNySYODF/KYsiPcZMdz9G5ThLwdyk+FRby2KibGvSYWDwWIAAV0vG vSY= 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 05:30:30 -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 4JzwgT4fkHz1SHwl for ; Thu, 17 Feb 2022 05:30:29 -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=1645104629; x=1647696630; bh=Q1XJZOgtboqh9FiddO 0t3IN9iQ7iOxHQjbmGMCT7eDA=; b=oJywAAOtVQtuvV73mLSFPHZVPOLp9a798q 6jqZn5hpsLLxR1NYoMwlYFhBGt7+OIssVDqPJ4195BoDeUfSJ6iy/D9Fah63DUqx cSCs9F/NywrKl/Y/OQzc0/0UDfach7ON063iCs6vd/6oFJE+lyaiKjqH/THfRxBg 3eLLPDCzWd9+zRcyANsSQ/wou2eXOQ6Sk9yV4TU/UYFO3WWCFHVIQ6etdBB9UBMY iFdxFCBauK49Bli+4WzX39j6xMSASOOFg5CcePgG4zuxqNEGt8oJADDiusMwAC6t GqzN1we3TAFvIHmB5WcBMJ8AHjnhx1Shd4PXpyUCg0BHxZ9u3+Zw== 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 jhFfvVNg96EL for ; Thu, 17 Feb 2022 05:30: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 4JzwgR6PvPz1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 21/31] scsi: pm8001: Fix task leak in pm8001_send_abort_all() Date: Thu, 17 Feb 2022 22:29:46 +0900 Message-Id: <20220217132956.484818-22-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29:47 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: 12750064 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 99D4AC433FE for ; Thu, 17 Feb 2022 13:30:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240931AbiBQNbD (ORCPT ); Thu, 17 Feb 2022 08:31:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240953AbiBQNax (ORCPT ); Thu, 17 Feb 2022 08:30:53 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC4712AF3C9 for ; Thu, 17 Feb 2022 05:30: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=1645104631; x=1676640631; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dH4sxA9AmlZnS/GYur+GQZPteUwIE//gjMPrygAXHE4=; b=ir1b2QH8XhvqAhjq3cHMYGSlkiNmFJN4qpA+hEwedHL+HFjciMpwSydJ A9+kKGwygEVnmNPpZ2oQQenTCDzQA63uR0KGi230QJUMcvaMS1yqWiFs9 Lj6a61AIYpODbW5KUMNi11jV3/raROK3grWwYaIki1wRT3a+hzUL+um3+ s4JG0rvZ0a90czgxPFAAhBCWzeSPFbByljolRDYFgRi8chCgEh8aPOig4 WCy2ysc6RVHTfu/4RqYowB8JkLdC7egjbB8dremFrA8d9Td1lPfZhQngF YWNeprUrnJcMYIaaRCVJxO9WH/WRUTEMWErRdgKVntFuXo1clCROhMss4 Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303221" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:31 +0800 IronPort-SDR: c0kraIp17BaaceelQccjjCeJTheEJUHQsPQfU/5Yoi1k/DfE0+2T0XihqIPgVKoYj9izyyOo+p pOT3NDezZlZYvtu18QChEIPR+6ODm4PI0PGvLi3X+eIe+GBM4IC4o6ED1Gn6KSL2shLu3RP38r Azbuj3qiQmtjqhnJlFOWW/SwIsDr0soO2XYG5bPKu3gEyyeWmiCYsejOMfAmc2wOQNFiWUt+hU WdTZrjVlKiTyU0omatI2KSYDoB5AXPFrW/EO9VTh81Q0fZT1esC07BYHOCizsCccXdZCmJbIIV KSCIYTyYzqY0umMKyKFcE6XW 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 05:02:10 -0800 IronPort-SDR: zesvOpAdR44Fw6U3wGeKJ8+j9ZzQVQOxnjj3YaVwB89+AD4UsIqSq918sl7gZeDcua9M6dlB3Y b5xgreWKVeZbEmj4njzcup8Ltg66649r1B9dFWdRmQh5acufBvBMPRSGij96fTOjhz9Yiz4ttb vZXT6hE29U3ZWYwAWj9wf3lzRYlWRj/skkKnTskD29XceUU2kRRMBM//+OYMSbXEsYqV3efwKI ekt4XyrB1Vc6TnKF7xze4BQYmdp/yXAQD3eQ3BT6xDfbUNsI+3iOWMyMQztcsZg+gL3Owlx7lp EQc= 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 05:30: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 4JzwgW1hDJz1SVp2 for ; Thu, 17 Feb 2022 05:30:31 -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=1645104630; x=1647696631; bh=dH4sxA9AmlZnS/GYur +GQZPteUwIE//gjMPrygAXHE4=; b=Zr/F/ACcpYr/Whkb7YKMciJR1BQ5mkgWb1 HuMioXDUPJ8UwHCGtJEle3ERuNU/tcWx3fqRCz/qafhzfINCgBRa5f8/8TMSlz8m 7514aaQkdYFBZSbKi7xbDOREqEIuGT+6MfodX2LWmUuaz9Yd/DTwwuoZn1oVW2px +wLeLyxZR8aRyTYmnaPokbuEnhkm7sLbaTX9puta7NjOV0W2atEZKq1/Z1mKcAU9 01uevxoBor/42qWdZb20jZPl9psaH5BU13RLRO4AJrJG5SvxxXpdSSSj7C4cbU1K CcJYVPNqe26NMCLZ51aUF0eradMqUvzaeEY5QJX2Tst5EsdBgX5Q== 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 4osQ7H2u9pKi for ; Thu, 17 Feb 2022 05:30:30 -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 4JzwgT3jt3z1SVnx; Thu, 17 Feb 2022 05:30: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 v4 22/31] scsi: pm8001: Fix tag leaks on error Date: Thu, 17 Feb 2022 22:29:47 +0900 Message-Id: <20220217132956.484818-23-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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() 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(). Also remove the useless ex_err label and use "break" instead of "goto" statements in the retry loop. Signed-off-by: Damien Le Moal Reviewed-by: John Garry --- drivers/scsi/pm8001/pm8001_hwi.c | 9 +++++++++ drivers/scsi/pm8001/pm8001_sas.c | 33 +++++++++++++++++--------------- 2 files changed, 27 insertions(+), 15 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..0440777a9135 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -834,7 +834,8 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, 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; @@ -843,36 +844,38 @@ 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"); - goto ex_err; + pm8001_dbg(pm8001_ha, FAIL, + "Executing internal task failed\n"); + pm8001_tag_free(pm8001_ha, ccb_tag); + 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 Thu Feb 17 13:29:48 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: 12750074 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 674AFC4332F for ; Thu, 17 Feb 2022 13:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240958AbiBQNbk (ORCPT ); Thu, 17 Feb 2022 08:31:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240961AbiBQNax (ORCPT ); Thu, 17 Feb 2022 08:30:53 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F21092AF3D4 for ; Thu, 17 Feb 2022 05:30:32 -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=1645104633; x=1676640633; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A2J9ZprGUDie40Y5laTVxgl2YHMqC17R0/oKPszFsYI=; b=BGf6X+sv2tbqp75EWuYmenjvKKvnrW9WmuYvMZ2SK+1hCv9aVck1B05B ZYXJ1TH81AbCcKIbzRAROJ3VWmcI8ns/9/MJFaO+wlv+JAv1o/5HLe2kv xlJ9yD7u97+f6BPXr/uZHUr2B1cHMFZ0zlBksYi6eE2V8F/pLQMRA6Npt 2zjnwvd83zrFfI51bYQE8rebqZuILPf8Ni1wZwzam3sgQrhMd2pKdwN5O jnOf5ATqN4XjqygveUO0g5PukMZIdgoFoTRpnHYIG2o4dXWuwV2Etk22r Eyhxidy2BlHaa85DOAe4212TCuNypBJx1KpyS1InTY/5FpapdjuG5Ri2k w==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303227" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:32 +0800 IronPort-SDR: mXy9w11N+BtB/B71sUD7PrWQAObUUIvP0Pbk+bkaSFB+L/FsMXEOQqrqFNa838Fz8e/+aU7AsY biuhvt2FZmGhsuAIPS1eGwMHh/PCZ1WzCNaDG8OCpvFTKj3ApATbAtKESvK3AnzdrCcxj1nLq1 hwxPiRTC+74XLVdx6us0M6YEOwoPcjcHtwoZYPwySU6P7B0ORUbBAeJLSZqZEUZGbfGrp+JgBm yqdgj658FT96i+gVMua5SEemcDvuIPfeEnLMBfqjhTQOgbo3QKr9jCMWSna2ANk7o5/S4DZiA+ U5Kwa1FGSatdO+dlU0C+5hrZ 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 05:02:11 -0800 IronPort-SDR: YvXsWhs+uogkJJswhBissEvrGr2JPhmXVM6PJ/HQ956feP0qCsU08VE1HoD84ENfmyXWwzsRXW VENokRNl6+si/R7ywWB+8mMcHfTepnYBIKHETlapeOouxYz0mqvS34Weg4vOBGl7h9RxN+fCyD SSmQcY/JwFgMt2od6HyhHyFbITeb0Usu8c2Vp+rynQ6oIjm+7sgQZYrWdoniQ7D1CW4wPBK2gc mmLiJ1HIQ5EtQbQiEifAsY+u3LQmQSUoRnYYKX6EIfo8GyDAukZLL54xGsIA3BBYhlNVwsK3RR tmI= 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 05:30:33 -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 4JzwgX2g5Yz1SVp2 for ; Thu, 17 Feb 2022 05:30: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=1645104631; x=1647696632; bh=A2J9ZprGUDie40Y5la TVxgl2YHMqC17R0/oKPszFsYI=; b=GWpNDtWn5Y27Prraz2woBHqj9qXNqQlvMb 2b9raK1n7Fg6aOiNZ04obdnJcgyzSrz92HNGr9p9ULm4eoOcMnhW2GpbSZhmegKV LyC72hEegjI1FF1M/R+28jWGnLpAx0Ub2SAOX0SMiHOgMhglKy8uLGCY+Qsw99Cc MY59DjrkFZsUiPbNjzQiaQuSigwSzZV7Icsa73JTgqMSiG4qfVZIdY1YCr6EMDXS YKwx5bwJbSPSTWVCWDXDnQB73BX2FCVWlboW1Ugi1Oahyrtud7WFs1H0wWeAYJAL 6IFAwWqATDqFXjQ1GA4U5wqeamqsiugYWAJ36dTuo9BmjJBq+aNA== 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 8qwZa_we13wQ for ; Thu, 17 Feb 2022 05:30: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 4JzwgV67qXz1Rwrw; Thu, 17 Feb 2022 05:30:30 -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 v4 23/31] scsi: pm8001: fix memory leak in pm8001_chip_fw_flash_update_req() Date: Thu, 17 Feb 2022 22:29:48 +0900 Message-Id: <20220217132956.484818-24-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29:49 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: 12750073 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 A23C5C433F5 for ; Thu, 17 Feb 2022 13:31:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240956AbiBQNbj (ORCPT ); Thu, 17 Feb 2022 08:31:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240963AbiBQNax (ORCPT ); Thu, 17 Feb 2022 08:30:53 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13F532AF3E7 for ; Thu, 17 Feb 2022 05:30: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=1645104634; x=1676640634; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G72px9zteVEyav9xzEEG21fzNpn0jSxqg6FF7e4Vh/0=; b=PijNtGS1TnI4HxOXijTzAynLmUuhX6tq3IRfA+808gXtJijzQgYZaCZr +VW5JviXY2r5oa+RZiqFTlBZKu0rq5a4kOp+PvBDOc1cZGnSr/02EsZ7W dbMSScBiLOlzBqhElJ6iKT9SY8eimfLHdql55YG4UgvavwnXS+cpnvQOB GztkpJymp7I2NnBEXDEum7daWcWKyjgNJhsE7fxRqs2X0W8ie9XQYlOSu F5hTruv0+6O+ArkquMdjc7ISCxNfTy2nYe3s2G39m6qui/SgZssEPNnXi EJPMFQrF0Pf8Q8PHzdoTR1WzRsqgpZ7udMqkt6OGrHX4vA6DyWEihmJO0 A==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303229" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:33 +0800 IronPort-SDR: a8XuJJkoGdypEo+QJTwdAAAXK/3Tz3H4oNRjLLdY/msLCJkCENf6hsO7ljMbrtRObafm2YaCjd L1Ym/r0YkCm4I5U9vqlwQUk/9FRpdPVaYfxeOt8fCAs0LUyg5El9sFO+GTvLsXB3HSAmREEEiT IWA0iI/5LZFBInL6JwuBR0hzmPc5cYU0taor7hc+8WoH+7iA7a3rJgzM3Xs2OseaTyzK6WwFGz YY//oDoB0i4lNsNBI4HIMzs4InKbUrFyYDT80dTOkhPxivNA2GVO7NmAs0VjASHOZOjX5DxJ7/ sYj420OM3gUtF/GKfB7IJ1jU 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 05:02:12 -0800 IronPort-SDR: c83Sd0li7szUKFHpwxX8q3knFqr9/H84oxL2QOnpjFRQhG0MSY/ax4VLEPTihEdMAmITIi01Oq v17CHvCIkFF7U4MePaiLLkOb2DHWMoDmdYGBST1RicptRFUy7hOZQS8pHQBjbHlSzXzizPsFPK lkEgCQxp+L90ktpyHQJfQgZv6YkIcXKlyayOhXJX1uyfu807w4TErttJ+LVVJeyR1EvsshPfrD Fnjn0/oz6ckEXqahezGXa1KUj0kFrSeeJzr2PNktBUnqbcIsYpYTBl6VOXHYqOiPVcE5q3GrW/ 3xo= 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 05:30: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 4JzwgY5Cyhz1SVp0 for ; Thu, 17 Feb 2022 05:30: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=1645104633; x=1647696634; bh=G72px9zteVEyav9xzE EG21fzNpn0jSxqg6FF7e4Vh/0=; b=NJFphoC0eNEXyR+V8aw4KpRake/Cdf7/cE Q24jyRVURAc4KLOSTDLYIOBfMnciilszf6EloHouoVuHjU9bSSMmkvvT9QXiQU7+ iFywcAzxFr720Mx96xuZsDyi6Qm7/7dRa6kOqsDBU1xdrennps8/PbEgIHUDHKzI yweleZOfV2Q7Mdk5Vwwndy2vKvQ0ax0C9DSDYRYBqavBO9O8RC2zOEkuFZ5VXys3 QS6ZW4JjcC69i5HTB7RbWOsJKH7FNQEXWA6CnawxNBkSrmoyeun4BW/dBexUjlUe rHnCoVfaa/EMIO7EGgFDyf+CBllefMEbEQ6qrGluDRrLZbeEJFiw== 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 TVN5D-EZKGlR for ; Thu, 17 Feb 2022 05:30: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 4JzwgX1gpKz1SHwl; Thu, 17 Feb 2022 05:30:32 -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 v4 24/31] scsi: libsas: Simplify sas_ata_qc_issue() detection of NCQ commands Date: Thu, 17 Feb 2022 22:29:49 +0900 Message-Id: <20220217132956.484818-25-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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: Jack Wang --- 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 Thu Feb 17 13:29:50 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: 12750075 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 6E6ADC433EF for ; Thu, 17 Feb 2022 13:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240961AbiBQNbm (ORCPT ); Thu, 17 Feb 2022 08:31:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240960AbiBQNax (ORCPT ); Thu, 17 Feb 2022 08:30:53 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAEF22AF904 for ; Thu, 17 Feb 2022 05:30: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=1645104635; x=1676640635; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lIlYnltmhjd3cKqECKtBTm2hPz1j+eWYgrjEBXycxZI=; b=A+u9MaZhxzNjMhtofvWBQmWCJhTylJW9wePltX3V5m8Pirw8jf/U67VP irDOCJ1D1HFMQ08maztM5wL8EIs2jAe3y7OSR/X2+t310joUEr8H3prsz 9Qat25Md6vGXWALy1Cm32dlzmpgl/AbyoETSLBZEXXXL4FSUoR094IgQB L3/vaXpiQL1Foo1dUgGjglgfbSkUq9CCPM9QR3CfGeyzBp/fucqRxIHAL B5zENHhcICjPp9guA0Bc2Gc3YIYtrV6bLhPe6zfM+QvRN1edkRC4NqoGQ 8ZYpGUgXE+PVwuWfV8u1hFivkVT7jQjPt8B0zJhdOoNWZ974K/lJzaDXL Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303233" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:35 +0800 IronPort-SDR: hb3TVuZbh78CWkViChvaz9ISQ5IQr8MLp4HE5Ai+kytldZn8RNIfkjx3RfrecVFhSFV4/uMCYm WGHLbp9OYq/7e4Oun7siDPoSNheIS/wb6vPKgOdCRa0ZeZw8bpRsQuaaalGarHhXPc9msSBSSx +0uwngf20VYskbqapnFHPCSrWR61MFPUlTR7PLlPLbjUxyiSl+GnMU7HqOuS/kTn7Dxh0gUbil dHSO+aMk+uKWHHMqgycJ1OhspoInWk58kTAPBTU5GG62sOByg8+uTmQz+Oip9kleG9iTE31hCL E+NbmcwmVaQzW268LZgqfY7S 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 05:02:14 -0800 IronPort-SDR: UrwdDVayj9BFi23zrTuFbwID9/0+mTN98hpAmI0O515+RvsMgbcWfSIOh0y5bSK0tanStKYJZ+ 8KUSf7fnFKZSxchKx1ZxKdK0+RE9uIQAbF43JFAl83Ud+Hqu+FLS4viBT6Mf3YJix6zsLVOgA+ GHBWT4tSe0I/7AYtojjMtpISG2dSW0Y6GBVBQd3w4q0wbZQkN9P1yo2LyUBX4AAQcuAYhq0XUG Y0X7mh12+AjHL4Yw/EBryyxSzJD4hmOPwRPgH9uGlCRp0FvoP9LPCPKpHnLnhzpHRO1qOe2ZE2 0l8= 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 05:30:36 -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 4Jzwgb1P5Cz1SVp0 for ; Thu, 17 Feb 2022 05:30:35 -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=1645104634; x=1647696635; bh=lIlYnltmhjd3cKqECK tBTm2hPz1j+eWYgrjEBXycxZI=; b=JJNCKpSW4GuF33/VgJ/5GrLYYFF6ZbHI/z lPZ0DVg03hJev85xzBV9CX/WX1SrB5dzJZZVoPKtocW/WmlS9fRSIiw9injtDVqm Z3QAT7hmE7H85XPwHsgk3AArnIeKHSb2eUSyXvd3VIUKyp5iFeTbacuGCSy60jtO To+h3axW8/izlK+7HfnU1qC5Cf0NFif703BSK+09NvdlPJemzWhw0Ru6LuIOKoSU hXgz+ilEl00esjDC/jo+eapHY/dg88jXJRGW76X4PkVVhMUWKbb42k2Cv8PWFT6s ANowTywHiOkZ+iugxyx8XNVWzWGxzJ+u3c6AUIFlBZJz+HSkz+qw== 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 1h_1ud4UivyG for ; Thu, 17 Feb 2022 05:30: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 4JzwgY4XShz1Rwrw; Thu, 17 Feb 2022 05:30: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 v4 25/31] scsi: pm8001: Simplify pm8001_get_ncq_tag() Date: Thu, 17 Feb 2022 22:29:50 +0900 Message-Id: <20220217132956.484818-26-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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. Reviewed-by: John Garry Signed-off-by: Damien Le Moal 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 0440777a9135..1e60ad82635e 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 Thu Feb 17 13:29:51 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: 12750068 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 C919EC433F5 for ; Thu, 17 Feb 2022 13:30:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240955AbiBQNbG (ORCPT ); Thu, 17 Feb 2022 08:31:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240972AbiBQNay (ORCPT ); Thu, 17 Feb 2022 08:30:54 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F41612AF916 for ; Thu, 17 Feb 2022 05:30:38 -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=1645104639; x=1676640639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4N3kx2KqIZ4/tLRNMbeQPxO9K7JJ50uyn9pU90NMflk=; b=XEoTMQdJk/WXwhvlCVlE/C7jgo5E9T9HYouMIbwp4ipGyAhYPRmdHa65 ooG9aVa4gv/RN/4Ncw557J4erAlsfFGK1DWNHVkcCg2Jk+w3ou8Rd+hUd 8S6vLWiXg9RV1BAk982kbPxzBofLq8y2mYd8888CyOkSCzpTw26CxvO9r fDhiGGreA0VKFn4d5Jj0gBql1qvFrqYNPjRp8cC5ujA607TDb+YvfIBlU BCbs80VfSujjvx4gufw5SMdTdr0xC5GnVAZ7REoDud/CiAWE6Aw7zysUI UMjW/rjWQOFg8Q5BVhmyFHZPZ6R35sz/KUd7bdEtE0/OgsQdlPBK73GVo g==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303238" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:38 +0800 IronPort-SDR: gKegA0AWI2lgfiKKniMWmOzkKYC+pu1Wepp9DhonKMJjYhU0Ld4g+fK4rVxSeXlDeAf+vpgOpT I3H+afvo/dMrAzscRBBPChKIOxEgodqpDEJsakvj8h+UIQO95hqccvw5zhX8Qh+twL6Tt4u+nw ITGp0hK100Mu/uWQXrLMLuN6YABILvljT5R23c5oNBVDtyw+xvP11KRbzgdgjCbvmV3la8kRAS F3DuGhyt70RGrDSq5coA2pMJx54ZtDDWUX9Z5xnye+fgEXDTlN6CNjNrF942MR0UPpx1l8FROl L4mjVJb1o0pGvLkKf5uM0BYg 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 05:02:17 -0800 IronPort-SDR: RiRKaLjEbteJ4ZI/aFS3hanDzRNXdsxYPHFg9D5Z/FvZryYe25u9m0Qz7OxZ8/pm9Y4f1f9J/u /4uvWu52E6XOnQ/HyUDPzWDHm4c3vrkTX2ysixgoGXPlpHB+H+5MNqiTGzOsAfEM8PXK8W5ngz gjt6gIZm6LX8eLZaQy963NQBv2pzS/es0MncM4Rrd6VEC2s7N2JEeBgDDfyMS/NOirVvGt0rD+ pG1qZJCpksqa5lprRhZGl66mV74asq6tbBzm8+atq8i97oy34wrANhaUfQgqGwxfeQciKs5m0L lYE= 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 05:30:39 -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 4Jzwgf1NJQz1SVp0 for ; Thu, 17 Feb 2022 05:30:38 -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=1645104636; x=1647696637; bh=4N3kx2KqIZ4/tLRNMb eQPxO9K7JJ50uyn9pU90NMflk=; b=cj/Tv4NHEvLpK+FUi7Mzd5ibT4J1upQSg4 bq+y7wb/bMbSODNcO5dV7NmTq2XWJZMa50EBH81TQbw17R0qJtiDaZQ6aKNAq9Lp 3eMTLtfM4L3333uAUItuIFT5KMcWwEek450lpwQISzg2lXEY5UuZnIKACqgYGITQ MX5ai6/qI2f1MA5PUsnseUPVZ+j7Ix0BI2k+MLGiCmWrbeg2SlNkHuco35EJKegc GsSpYnpLsxjEBw7MXnXwTfS9ppoYieC6UgJyZPYkpn1tD3hl+jXrpALM+T4fbG1D Muwgy4Vf64q5YD9yIjASuZuQjaIP9acvei3rNHTugxMJAh2mYO3w== 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 2SmowpFRBQuT for ; Thu, 17 Feb 2022 05:30:36 -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 4Jzwgb0LNhz1SHwl; Thu, 17 Feb 2022 05:30:34 -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 v4 26/31] scsi: pm8001: Introduce ccb alloc/free helpers Date: Thu, 17 Feb 2022 22:29:51 +0900 Message-Id: <20220217132956.484818-27-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 1e60ad82635e..52507bc8f963 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; @@ -828,23 +824,19 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, 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) + 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); + pm8001_dev, flag, 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 Thu Feb 17 13:29:52 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: 12750069 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 0EBAEC433FE for ; Thu, 17 Feb 2022 13:30:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240988AbiBQNbI (ORCPT ); Thu, 17 Feb 2022 08:31:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240985AbiBQNa6 (ORCPT ); Thu, 17 Feb 2022 08:30:58 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54B062782B3 for ; Thu, 17 Feb 2022 05:30:42 -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=1645104642; x=1676640642; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6DUpixmuLs2kdIQTDsWJDdIkGHqSljx6E5kBEaMoEec=; b=BP1PJJ5f3WxUiLf36YVksY0ATjosI+oqv44eAlfBQa9VFwREo8P22ZQP xOr5Jm8+FD4XIrxMXoefCYoJORF+ezNXLoSz78/PcxRCMMB9oSgr1GvZK adIytQFRHfrkUAH5hU9GvxqE6Oqc+HqXBkaw6ERmXl1oO1ZG1sF3hgdtO eOG3uEDIofalt+7Ufn92DsJCDnRZyuzgxgan10Pf25UftTYgVlLOzUJmt s6ho5t7VnPo72voqwmQyHZYFnPEAzlcu6dQBTVxoWCpTqOvfmadAZfbbT d4QTQJK4wp8tPg4hoxdT1VBZhXz8OI15i0Kad2ABaSURXNzJExprJ0Xd0 A==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303244" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:42 +0800 IronPort-SDR: ax+fAMTw9OE96vbB7rrBNTHFSmGJl33fn62TdIWaWAW+WcAab2rkxtst9K4DCWLc+By4iCwQ5b 2qSNzB8WwVa18sd4+nLc6jSN9ZcZDfqd55deoy52uLiDnvxWWo5muV44w2QG+g9rlNrjvD/OII 4+kud5jr1pQZHkoqwhWhp6T9L3bsJqyiualGSe/oojUbkRaBzxfmuTRuGtRxw24wDGAOZyx0QF Gd00qRG6Npf44ybXFEuVZwaMb7jcqyxP5apdWhB3wSoQjP2YxXZ1K802vf4Uem+jHepsKvGoK9 HTSszqKKF3G8k7PuehD5UnVd 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 05:02:20 -0800 IronPort-SDR: xIpuR/vgFZFx4rcOilXAErkBSIm86jJGMQ8Kq/diVh/4Xnihx8otrxG59QF5LutIB1QIugQyIG BZEMnCI0CMss4JRiVQETEPJld9yWU5RyLASyEwBsHl2wZb5ykvcABZIloB4LUmxthko2Yv+OMs Ar/mTdz/BcRnmN4izsXwNnw1Pu95Nwtp2r2XGZextpZCK59nwbFc7M+ERrw7eHsKgykbc3JVbB rFQPveYSyCQJuruRLz+chWnMfm7bjNUelVk8nGi+vYZ6pdceG7zs8wGklW6115gRamqszvNX0g waA= 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 05:30:42 -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 4Jzwgj3zSpz1SVp1 for ; Thu, 17 Feb 2022 05:30:41 -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=1645104638; x=1647696639; bh=6DUpixmuLs2kdIQTDs WJDdIkGHqSljx6E5kBEaMoEec=; b=q6IKmNuP8GDnzWukXQuq3bN3U+SV05FrJv CP7SOPEeZKPr6nAZoIR2VIat3gPer9iPS2GlbdPBnItlbMVekR/A6j4ROKPHajDs Pxd0VS9IIgvI73CYNMOxXSIdZpVVm8D3WXUDRE5oUqMUXQk+lQzA/Z7ogyv0qbFi cQIXcLYP9MnnvAXvQFulaBOFSnzgIJ0vuwIaQBlhyxbkT1KVT3hzsjTDRYiVQnQj 7kx43UBHd8Bhx+vtkzaY/+wg+VAXxXI2JgJn2sXgVhd13liO6JCxdebruYLt0QRF XqAeuAZCFkFGeg2Rz8TRNOzYvOHT3wuW+HL6/7glF2Wyx7oocUmg== 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 y2H-1DC-XvAO for ; Thu, 17 Feb 2022 05:30:38 -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 4Jzwgc5tVqz1Rwrw; Thu, 17 Feb 2022 05:30:36 -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 v4 27/31] scsi: pm8001: Simplify pm8001_mpi_build_cmd() interface Date: Thu, 17 Feb 2022 22:29:52 +0900 Message-Id: <20220217132956.484818-28-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29:53 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: 12750067 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 53783C433EF for ; Thu, 17 Feb 2022 13:30:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240986AbiBQNbI (ORCPT ); Thu, 17 Feb 2022 08:31:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240984AbiBQNa5 (ORCPT ); Thu, 17 Feb 2022 08:30:57 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29A362AE2BE for ; Thu, 17 Feb 2022 05:30:43 -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=1645104643; x=1676640643; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0maIJiiGjVKGfUJT7QT9WvAyoeH6Ycwg0+jbKTH7PS0=; b=aBtYPi9mgO2XotIQbB8kNKu+Xoo9fU9AH+RzlUgeiHjA2ndUP2vwOgxx NqPvYdJPk4k1ss75A4DlJcJ27I6VdN6ti7ontptYbBCNyxeICS8Ic8oxr 5XTlAxgJCKVM2hrERR6ICOJWEv7gj6x24M/WcuZg0NknYCLQYM6LXRpKE TAikK7fsrN0SO3gs3br4er+GxG5bP6C70O03dFrai7uKs35PNXKbhyqmJ 2GbZtlxMnzhpmpttzoveV1ti9F65bK9qk2f8TuMQ1H7rE7GNGgt+5tWvK 1GitPctWHPiZdchKyn8QiullgPbNWEnbyIYKDb5GnNZGQb02LksKLsN03 A==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303246" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:42 +0800 IronPort-SDR: Fc40swydzdMFv3sAHWLr82XPEz1ayyQeMgH9+gHZkB2QBKJcvz4KlYa49OOl8U9UJ7cJ1U+lst PzyrTRVufAj+D1KpCfeKhaLXrHW/EG8HGHfItKwu97RZXNjKC7JaHNfkT/2CpKo1f267tzg8zA xcJGf7ebpt/7zxPzbju4W9UGPGCBBS8HOjxf3c4yrbetBcYV07vz6kSwoyoL3ETElxY5Hhqf6j W7eF6BFVAz6aK6eTWgq3knIJ/WGhChBSPW8AbU0nblCnJFFfJ39k+zf8fdTl1eYFdNo4OEc2p+ Sgf/1yb3CtEKMa3l1FoJbHfO 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 05:02:21 -0800 IronPort-SDR: rYPPHgKJPeoJD1mt4OgDSNG7egGIBVCO3CSwMXW9IMkqQmOQFbT27b/ed0VwjHxbw5UhXBSaM7 XiWISaMX99fUgjfXbdIyJGlaEyzhsnf6f3ip8xWHOWAN4yybmXb1IieoWANnDtKAKT7uxAin5G OcsU8WqktEatPxcZ8AF9V9nKarV+lxgEJNQN6mKHmuVtBZV8Oa7WyRjssRY+xPBGNwCyHtC7Kl C5sftbzeHtWMabEvNl95d4iUC359cAiwBnCgxElhsU3onsY0K/sOUXT8Bsx0a1+kMHUqpr8NH/ SVw= 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 05:30:43 -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 4Jzwgk3Tz7z1SVp0 for ; Thu, 17 Feb 2022 05:30:42 -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=1645104641; x=1647696642; bh=0maIJiiGjVKGfUJT7Q T9WvAyoeH6Ycwg0+jbKTH7PS0=; b=boqJnBhSF1VC8POlkh7o5LTUrFewtPIO6N ERBXFWkL/qaBv50H67d1zquvafh2OpeZU2k9aw3VGlyYTbRGUpvj2qy81lU/yofM QrwnnA4mr5eBn/N6HROcJF5ajcJtyGdBgBNgvwmqou7/XbZuZbm9tGqyV4p2Bpul PApsA+FkAXXjVyXvH5MxXc3sABXojvjuuzqakqA2pIA68txDpmdDe8Gve/N07GlY +3su744SPMgnCXUe14Ke5zH5bqVQKeoRhZ/YhoudOOrQg7UTrvw54rcKja7NcZKn +10JGydOJDXCkifPosPFdjCiGqCzFPkb4UdGaaRvjaOPZ3xWItbg== 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 uFIZ25jorXG1 for ; Thu, 17 Feb 2022 05:30:41 -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 4Jzwgg253Wz1SHwl; Thu, 17 Feb 2022 05:30:39 -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 v4 28/31] scsi: pm8001: Simplify pm8001_task_exec() Date: Thu, 17 Feb 2022 22:29:53 +0900 Message-Id: <20220217132956.484818-29-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 52507bc8f963..37aba0335f18 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 Thu Feb 17 13:29:54 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: 12750070 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 892DDC433F5 for ; Thu, 17 Feb 2022 13:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239392AbiBQNbV (ORCPT ); Thu, 17 Feb 2022 08:31:21 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240799AbiBQNa7 (ORCPT ); Thu, 17 Feb 2022 08:30:59 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 283AE2AE709 for ; Thu, 17 Feb 2022 05:30:45 -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=1645104645; x=1676640645; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x95SKJI3W9h+6R/UxokAAG1G++/+nNTIjg/7mqgq6UA=; b=PynGgrBf6hAEIcuMVOdaDcaI9IoiMnK5Fk9JuI36ooqpu99jdWld5mVw ZC5uDySePMj/779l2Sfs/fnc12IKluKrP7K8mzYBuFDdT5rcWAMghsf9N 21MO9KlZsdFxKmq9ZJfKNjjMuEx+ZrAdd/6OwME6y96uh+laKSgroi6Rx uktnsthRLFEO9mh3i39Is+v3T0X6m4dLg7rth5jDlOBNhOv7D9Zs0EHrm dcw5EULl6DZDmxcweN8nqOLqe8SZeEmhcvH+/+btdt7TiutdHj0GEO6qW 5F8w1yXyJvekOtlZcJxjgr0uAQET95TPwjqPLTNNFWBKd2XLWh9AjCA7X Q==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303250" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:44 +0800 IronPort-SDR: rLBILFLXRokODPwTPhUR6KINm1M/0J9qT+qQGZw1kH/BW/Os97lRqf6gsXUDJUAUWIjP5ssJIA 38pUPRmP0ON8lpk3iC9RyB/9U8jPew81YY62CVb7fmor3VNib7kEpLqGZqjVcG/03XtqJ6lI/I 7n1lRqTcwJtmnd3hCZFSdFDdKEeLsbO+d3yPfAQa6m2bInAZnimGSo4TvfJcr1JLkPCePymRBm 5+e32JrSXBYPLQ/5ASO3yHm9sY2ORZLwXWKC1hkBfIV40r7gTlPwIqryEpXSCqRikWGMZmOQT8 7MqznyEb28CQ5Elfn17CfDpM 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 05:02:23 -0800 IronPort-SDR: MwzukD5/Sd3VzAu+P19QqQtHp4yqABUqMfxkdCMacXLT5JtbpMhEE9qswCghHYcpDSjfTids5Z hSuVLvTn5esuvH151wgAVN8EEPMdYE27XkJQV0fIdaG9d5Ur2ibQ6PGeEPfa4j42rnOljEr2He tPHusRWcBlfUxt5Dzpvd9OSX0B6h11ofZ0JnnMrYzpXI8QD6iDJoAeUbu98c4Xs566YBQHwBIN SeV4l3cj3AEOP+2OLvPe7BniZD57SCargOMqFhvtqLpmD0+4rRhkf1oY6OMrWbNkcPDtl6hcW0 C74= 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 05:30:45 -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 4Jzwgm46cHz1SVp1 for ; Thu, 17 Feb 2022 05:30:44 -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=1645104643; x=1647696644; bh=x95SKJI3W9h+6R/Uxo kAAG1G++/+nNTIjg/7mqgq6UA=; b=mUAMdqgF4whvqtddSsl4t40e2Y8hIZ1M57 cmfrx+8EB4DcI4e6egTYqQdfEfvvW07JYrmOFy02Avw3O9Bc+y2KfS5petzJTWBl wuIkP0bSAZnxJmyJ+yMZhb64a2EDZGI0SOvPpXtE41IZLdaahgMWq2eCu+Eqfwdo Oie4GyZWmsAfBiO8Df9x6vB2ofNf0h47GqydcfXBhaG/dZYi8MjROPn624uhj566 zbP8D+m1Ctw+tm5An8U3l73F7WyOe38ZfuUtP7Uf1oQGh9TRXt89SkIqYTxSEUwH MUi9ycIFjZgkCpDTF/0P0DR3ES/xAy5rZCidfyiURrpHsDPcKtVw== 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 6WEJGEJ-2bLW for ; Thu, 17 Feb 2022 05:30:43 -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 4Jzwgj4v7Hz1SVp3; Thu, 17 Feb 2022 05:30:41 -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 v4 29/31] scsi: pm8001: Simplify pm8001_ccb_task_free() Date: Thu, 17 Feb 2022 22:29:54 +0900 Message-Id: <20220217132956.484818-30-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 37aba0335f18..da8f39631fb5 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); } @@ -960,11 +959,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 Thu Feb 17 13:29:55 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: 12750071 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 C874DC433EF for ; Thu, 17 Feb 2022 13:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240995AbiBQNbY (ORCPT ); Thu, 17 Feb 2022 08:31:24 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240907AbiBQNbA (ORCPT ); Thu, 17 Feb 2022 08:31:00 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C1A2AE2BE for ; Thu, 17 Feb 2022 05:30:46 -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=1645104646; x=1676640646; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fo+u3tJIh0jVn7uMv+unetkdnajPsN0MoK2SbdL/JbE=; b=U9OUOLBzFjI2vwL4PmznrDzbPaxaFtOXpNExcW+CpNKXsEoLUnmSIgBZ TvOkgDYZ4oXzGz2lK+ZUVODA6lXlg29iXkATO37Wp7j99Guz29PeUQXMi pa9O0SgnYP8GC/uL38kJyf1T/9t3jr5b8j2s/cnhcM3krbhJ2onHr6dDL 528ni47NBmCjOAk0g7iDEYyUJv5WLEGgwHxf0BBQW1Atz10ylsnwkDtz4 L3CrzRzLdbAXCOzl7Aag6jdD8ongeY+rrxqd1OvoUIKCGzcpCl/2jUbWM TScoqRN+LVdVyhxVnNd6rvwGhLV+HR45kk6PS+QN+1ru0NP4njFDVy4sR w==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303253" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:45 +0800 IronPort-SDR: QjAyuL8dfKAS8R4M6JlPio9+ukvZimzEdXjyYy4VHCqQ4sm5r39Bn8WNsb3A+WLYj6of7vqnj/ itIivWCEy80N26qi1yAdleyTg97KTDlci6oYq5XgmsEm2BgpYw8IT8M3M+DGc3xQrOfaT0Lud1 NiJ2fJ9SSGe6ze+cq/fFLGw2JrUnT2gPVcN6JSUSPt07ZusOcu+6thXcCe6QTwDo4wFHxMO33B M8WxoKgL8M/jWctb7u4t+SWgAedJ1RMfYkuZXkQDRK47VMR3CqxWiNM2Fn8sfqBYWCP7ICS3Xp f6DyKBOU9zukjWSaLZsT3ls5 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 05:02:24 -0800 IronPort-SDR: OP/deS2KYuujFVXVFcNzyIvfR45ogYYOnmweE8sGvC79PIxhIQ0rYDoZaF29W88xi6bepQRa2S Ze944riK67u+FhTW6YWvn5r0EnRWXT2/unfwQ8wBbzZOzwIDGGWIuc6vzC59igoVfhw9z9Yzbg ae+f30RjS1E9Yq5eIhsK74kQI2vWFenTHV4h2Qe8VVrxT9G2ZafcsTtaNKB1S1SqbF8e/nNxKd v7cvZin5L1uEf0/E1t1gfmjRWHncWEgLTicCvPscykD4hyPsOGbMbdHeYkLxqp+iOEA3spnFB9 d1c= 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 05:30:46 -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 4Jzwgn4hgsz1SVp1 for ; Thu, 17 Feb 2022 05:30:45 -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=1645104645; x=1647696646; bh=Fo+u3tJIh0jVn7uMv+ unetkdnajPsN0MoK2SbdL/JbE=; b=kTkQ8+FzywHs5lVIoiiYejOuJh403YFfyr r4p1jDpqk3s2woM+kFtgZuLZx+VF+sbnQ8jEHR9EQ5Rp2Ly0LkyrZ/nkfe79M1K+ P5JCmJa+E4xAXOW4iIFGieWYEXX9f4Qc2aJ/ls5wMfpgf3UzK6opw5yOrIG808Ae Ltd9fDFMoVeiHO/1XfC3ZVMHBaM7KbHHyW3OuFT5/EXeiPHxwRhoddDzjEvE/R4N lGb/okgN3kDJmt4MKkn1twsw/B4Vet7PvNxgbJ11c0ipHKNIhxR6LYOnJG2YFfyq TW7YIdnToWnkGabx9BPDomrbUpw11CRwhKqtsGayh/XSILDOaOMg== 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 81AO1T90xNaF for ; Thu, 17 Feb 2022 05:30:45 -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 4Jzwgl459Kz1Rwrw; Thu, 17 Feb 2022 05:30:43 -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 v4 30/31] scsi: pm8001: improve pm80XX_send_abort_all() Date: Thu, 17 Feb 2022 22:29:55 +0900 Message-Id: <20220217132956.484818-31-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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 Thu Feb 17 13:29:56 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: 12750072 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 29493C433FE for ; Thu, 17 Feb 2022 13:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240996AbiBQNbZ (ORCPT ); Thu, 17 Feb 2022 08:31:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240927AbiBQNbC (ORCPT ); Thu, 17 Feb 2022 08:31:02 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B41FD2782B3 for ; Thu, 17 Feb 2022 05:30:47 -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=1645104647; x=1676640647; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Yb073H/xn2vfr5A6/39r8qdOpwiU1394jDeekoBnKmQ=; b=Ycwa5yIG/kLQXrngi45gCMC/6ef/JyIag2jJWjW1w0C8NnF45mrmR0Po GIuhjXZB4/97top8jaSkg4+gjbpStM2AY0NFW6CXTRrUbjVScLXghWVdk Aq6UaTQ5FlhHO6A0VA1TsLg9Q/Jr93hNLjOh0G14xxLwYtesjUhKtSOEf VVrpiYOUN12Tzbxt8PmHBfIEihup4clc/1FykFpWIpH/3Gefp6S1RUG0c UAs+Tvs4lP7z4emZolM0wliEHLc8lfQjAdww32QmO61XtY7JcyjJHfDdg scV7g5M6kd2sk3Zu8t6gSxhfHrWaDX7oJ08R2nEX5IZdroFf4NGmoT6U9 w==; X-IronPort-AV: E=Sophos;i="5.88,375,1635177600"; d="scan'208";a="297303254" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 17 Feb 2022 21:30:47 +0800 IronPort-SDR: NvGhJiprfgqNyCloW4buZrpDj68mijR3MchI8SEXY4L7wR4vTUr2z3FhhoFmghcA4zRGCtJbFd FuGpycfeLD9UGqhoEPWFczhFypEhu15eSQOj0hyRwx2Dm7zmop9JmNhvkzyStLYsfdJeWscCmx Cb3+a59qsH+tJEC4QPFT9jOTGdabBQfm/2DvXCcAqUTbIHqSbfaJm5DElSU8r2AuXE+5fS82BD vVDhIOd4Af3v5+118y9tfhZP9Zj+VEXJy4UeU2LN0K9iw7XmAWKQ+DB+mTveWVQJDq2Yvfwsl6 qctifPN1KY7UerCbXMLOadeq 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 05:02:26 -0800 IronPort-SDR: gB7VIVOLmf/Auv4H4RPHJ5I4usaVqAFESCP6rfRzuPmwfdXyDsj3/fUJ0Zs6p2+sF9kscyLiSo qkAJzsIOOiWQ4Jn1DFOkVFOZozKWD/KRSiq0wbKP0b0xI7pLM65F5YqVy592bqDD584nuN2acu IW5hkP/jemYHCYO9lebyd4skEGmDxsg32HiEoMW+OpQG7ey3niq0YpFao/HBRLCGU/KX8lOy6l 3AGENPpFWm2AQlm7vDoU9HgVd6hUFATqQMLRP8kkM72lHhZ7nw1J64yf6pmdtKLENVSCS4wh+f tFo= 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 05:30:47 -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 4Jzwgq0VXgz1SVnx for ; Thu, 17 Feb 2022 05:30:47 -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=1645104646; x=1647696647; bh=Yb073H/xn2vfr5A6/3 9r8qdOpwiU1394jDeekoBnKmQ=; b=Q/75K0RkZzBvJUSMBd2KG5ajgdYesTx9uC YuIJNz3wW9upHcQA9D7DEpbrbLnX3rfdTvGOAncPE/xGwDJVH7QBGKF7d/bryDPn wdQpOx8YJw8u71c0eXt8U6B52SnbQ2QnLp9whpLLha+WmVAkgH0qzci3PqJstWsG 2qkAOAonoRgQ2GDjVqQla34fcjICd6dWaOI7sfsoWi8v6E3BAnkKLJtu7dV5Q/+d ECdokV0U2/xkmTh/HikL4ActEGrM754lsx8dr+vyZ/w5GSp+nEiBzTsZapkoNf9t OGwnbIao9oubwjJNVqFPPQInM5M1R3mGPP8cR4N93XGwQGlxFqHA== 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 N-aZ7Z4HuHgM for ; Thu, 17 Feb 2022 05:30:46 -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 4Jzwgn3Xjsz1SHwl; Thu, 17 Feb 2022 05:30:45 -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 v4 31/31] scsi: pm8001: Fix pm8001_info() message format Date: Thu, 17 Feb 2022 22:29:56 +0900 Message-Id: <20220217132956.484818-32-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217132956.484818-1-damien.lemoal@opensource.wdc.com> References: <20220217132956.484818-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, ...) \