From patchwork Mon Feb 14 02:17:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 542733 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 3B1BDC433F5 for ; Mon, 14 Feb 2022 02:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239260AbiBNCTn (ORCPT ); Sun, 13 Feb 2022 21:19:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238144AbiBNCTm (ORCPT ); Sun, 13 Feb 2022 21:19:42 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 870E354BF3 for ; Sun, 13 Feb 2022 18:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805172; x=1676341172; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=SkJwsNHfA/V1wKHVsC8Ec66YD9n/n5yPSoHBwobqogA=; b=W6FGJSAWMKn+M/LB2OSC8WREcWtlfY8HzGnYeDTI7F5gJdpjZXLBMFkb Qd1SyAUqFsvdf8JjFh0egH75q3vFSzDZtsWuQYeqxREPKLjPHFcHarkwj PTguLd6+iaAWP4d0rZ6OJl7AwFNayG6IUziqQgw9zJw2NN5NCa3PbTyyb tPSliAh7uIj5T80j7CvCUvnp3OqIjhm2+8C006dyX0seCUnVgYRJ5r42B KOi28Zck2PTWbI15dpe0x093P8JvCWiuGHuaSE5lmI6aXCxx7bIhT2hDI 90X6ngxAFpkEX93R8ejhDn/K2VGn2LrDdJ1eZjNBmDUd5Uk8ohEJsg5h6 Q==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819747" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:31 +0800 IronPort-SDR: 1dPZZhQr+d9xaH4+VZa1gcRgXdsZRM/Q6rUoXEDKRu7cqfiB4uZXN2SsdeHoimHgGr2avkD/fc CWxvOWNgR8WF+InaF9sLYVDuSvOcEWlIligPLfMwIYL9FrvDtcfDyN1YaRw0NmOimwne7OVpdS R2us1LTaT3ga8SuAfJ/4l7rYZtk9IHlsizDpNrmoDHW+RFoOlpNcZ0SjVJkDuQ80zoIk9YyvpX 5RWGpgmNFjSazgna66tKfLCW3hUX9Mxr5aVDXghKP7SuqbXL2GQSkJQTjMlyd5AV0jy6mmACX7 pKvnG2bMXgAXKPgD8ykJkmoK Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:23 -0800 IronPort-SDR: WWGw9Wz8/7wZbZ/Uuf8tGFNMQfhLJlwjwWV0UXNhsdazogkvQCb1RymZJT62IQCi7P/BwIpyl6 63zCM9IkY+ZgJhUxoYOo4fpORpx11Z/ZbYW6r626t6a8KUKy1QQLf5yZCdaIYfb46cGYK5yfh6 C9144v8T2hLBxav8LK5lMxavhAxpnxDaP4HBYGwY8N8FGJushm9AR91Prafd7oYzSR/Ls51/VN ZdVFmpnB45lxACcGGsdZWtYhUOH7HkMqeHPCubgSKBHxlJ/Apf/V52Kl4+gfULQIO81Sdiwc/q o+Y= 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; 13 Feb 2022 18:19: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 4Jxnwh0zfKz1SVp3 for ; Sun, 13 Feb 2022 18:19: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=1644805171; x=1647397172; bh=SkJwsNHfA/V1wKHVsC 8Ec66YD9n/n5yPSoHBwobqogA=; b=W+MRUcRjW9xXlVifZyhJBahckpyrcY1swY 6KaFDU68Ih7efPgPd+oaaAzx8v0d3JAUwu0dp2tvcqt/Ygja26ummTyct6gqUogD bT6oAOg/N4y3lXNCXW4N6J9DCKndmY51/HFFFmRAkLMlbPETURPzAfhpkes5OG+v C4LvoqAllL02X8/AG/kl0H14DoK5/NVSd774I80nggCveSjP56p2b5Jqu4SxsFSp 2RY9qUQJw4o6qvGUE9fo8tBBfTmHRQsr8L5V87evCYLtgeUOfDaBtJER85Ji2ev1 kcYKR0L1w95lvk5BOtTEd6CZgqPb1tS2vgGVUWiBMKR8x/4GGZdg== 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 BCVQ-VhwwyOg for ; Sun, 13 Feb 2022 18:19: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 4Jxnwf514Rz1SHwl; Sun, 13 Feb 2022 18:19:30 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 01/31] scsi: libsas: Fix sas_ata_qc_issue() handling of NCQ NON DATA commands Date: Mon, 14 Feb 2022 11:17:17 +0900 Message-Id: <20220214021747.4976-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 Mon Feb 14 02:17:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 542980 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 C03C2C433EF for ; Mon, 14 Feb 2022 02:19:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239256AbiBNCTn (ORCPT ); Sun, 13 Feb 2022 21:19:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233848AbiBNCTm (ORCPT ); Sun, 13 Feb 2022 21:19:42 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2131454F9C for ; Sun, 13 Feb 2022 18:19: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=1644805172; x=1676341172; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=uXzLxgeccty7QOgadCe0iEfQD3Sy7wUCBB0p18oBuSI=; b=k1iX59Ffm3/FpI2RjtefAWiP0nhDa8D9B6dvdiQdm8Uvz74QgMNBBjU3 mbGomQGSvyKOb60BpaKARDmQM3bNa4wUdeOTfrJ9IspLwno1KFefMu6Or /kcp8zv5vtRq5AoueJAyf1TN+/poscLXmlkGVyhw1Mt5Gi59ulZAfwUX4 brhRvW1Ij67obkYWZ/UQM89lFTFA4eH1ShrwqFcMC4cMCGZOsmnNZdJkd t9UfcIIeIkHlbvaxsm3gQGxalm7JxrqAJVVUGZSDDZZowsRNpwdFa91OH i4qLjtJFMPxxZRSWcLwEJn9gc8JoU2q7J8znHTQRICGwoNuCZlyrgbDHN g==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819748" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:32 +0800 IronPort-SDR: UV3WYegQ+IyyJSwv1xQQM/CSTC/KyrzENJgizeoJ7s/grX0wpSO/4PbmarbPcGJoMo34znOkbM IdWT1HN9ivl2vqotvvXksu+qnYjA65QLdP4SAvOC+MzKCCm+vuH590VwhDy6RjvKA34n8GXG1C Kmn7wvNyTfRZEwNdn2QqLQSyrcbf/hYvUZ/MCuZHF+NroMActYI4erEPBEGDFDTB0iVDDfPfwY mVEy98PbDHB8g2wSpM31+Sm8RYCgbDh9iKs4pw4YVNdMA2vb/8cAJUm7GP18jMb90R3XpDX/is KBtw98uKOXwf3hkjUVWTiuFl Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:24 -0800 IronPort-SDR: NmbNsCimoRIBK3zmfEIWYXc5q0ef/+DXdY6tk6RfOuCPACY3yQGZJq2jw0FNNER7CGZI9kEk7I CxXXggkfsLkkLxqW8eq/BYKGXC8jvWjCLFXza6IwILG2DCjivZkIA+yrSGNa+6IWsJFX2FRePE DgBtzMABK0DkPRMPNRS4XbxqQNkcWJr+2TcJ3AlyMtnJFbGLKAAAMm09vVyHDeQ0MqASQjWjb7 /DTfLW+ly+FmnnhffNrx3kZochG9yX/J3FZOjLaxunU+pBcL0H6pzc6l7LhCNDBk2rJWTLw8+u yRs= 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; 13 Feb 2022 18:19: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 4Jxnwj396Dz1SVp3 for ; Sun, 13 Feb 2022 18:19: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=1644805172; x=1647397173; bh=uXzLxgeccty7QOgadC e0iEfQD3Sy7wUCBB0p18oBuSI=; b=EvTYF5+CYmquNZul12vbD0CJVz/AliNX9E x0b/maURuXMtilBQ8l3AvBrrKw45HvSnvX+LBLgEbwmkETnAnG+3ekpi+2iickUf +KNStM1aLvk6Po2i6gmf0fM2+mXMSpeBVaEN46fZX1r6TyLuBQfzm53IFMpuIOlf c9MNrU9Am2+YqHQF1jNJiCXXFr5ocgQnh0mC73ihlYBtqjVFwlRd1GPGO5ACTx0b /Ne1THPIAS4ZcI3M3KLrLbwo+Yhr1epFCsg9rjw0Xj1B9dw07BW3lBlUhuTuA5ZQ UfwRLc5KU6Bvm7Ih5lVi9PULgFB/Wp0gTiVwJP4FJ1DQTTg5dI3g== 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 4HqdDefkmBoO for ; Sun, 13 Feb 2022 18:19:32 -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 4Jxnwg6LzLz1Rwrw; Sun, 13 Feb 2022 18:19:31 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 02/31] scsi: pm8001: Fix __iomem pointer use in pm8001_phy_control() Date: Mon, 14 Feb 2022 11:17:18 +0900 Message-Id: <20220214021747.4976-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 b3530f53df25..6062664e8698 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 Mon Feb 14 02:17:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 542732 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 DE186C433F5 for ; Mon, 14 Feb 2022 02:19:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239277AbiBNCTp (ORCPT ); Sun, 13 Feb 2022 21:19:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234357AbiBNCTm (ORCPT ); Sun, 13 Feb 2022 21:19:42 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E340A54FA0 for ; Sun, 13 Feb 2022 18:19: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=1644805173; x=1676341173; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=MDPQos9blKV8Oo0LcYELhApb03Psw+soVXabs2uNE4Y=; b=pEPMHq4OK+ZipcB5ksJsf9YegJudkTeZzmGZRMuefiFGh+9eyC0EYssM 1x2RDRb6P1kwWTCvBSX3o9GDS9iZiLVX7iYWJ3/9TyaQlF9cVhgUUpKGa mtMg8qH/iMqNZ+m8eAP0wFn838h/piUyVOm6K3cay01j8X8/6Xz2JV66n oEa+EHgX1Vi42DXCRk1zyTpAg9QE5ZQfpQ3bbp+pMYUH5MU6/HACRlBXA zGT/6YAQqJg2kvb5Ix8Mm1l1gmi166sllgxObH4fwaOyf9xozwEEBa0xm 1Ov80OMmUT2QdX6Uf6NP/gvb0kuqnKIYx8YNStxDbq5ie0oH1iz8z/yaM g==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819751" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:33 +0800 IronPort-SDR: J1s3Ogd1MnbSpUggb5gewkMSgRa0fjBSwAsZX0oxe9S+5pvWGzJfvDE5IT2aVknsIvys4kHehh 69m8aGddkeYEbmJBqvHa6JU7MfuAkgQQo9oiP76tYnYVWdQz54HgSE/HCLFZPjD+jwprysYMDo A3p6q+fELB1rt/hgXcKjFD83N3e/OCyo8li1wJB7zXfXCgJIdQFi+woSkH41ojXchPsNyXNkbH toGmjZMLxJEW1hEwDjWpRYWPT9rUDtav0yW6xR644DOmsmSwVfVAy89qkl94xAsyXpWmipBcK5 1axb6GZeTo9TxTgHGMYiOcY0 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:26 -0800 IronPort-SDR: n9lUkqKu+LRmdzgaKT8Oj8VdbHfIgh6aa+mFJkrq+BQytJfgEJrjJFuOrLWJ1Wduvaeij88mIG 9ldUVi3D/9OQtCLC/zfFXyxNI4yFeYuu8RFzQIHzfGHKT1XeOAIwleFFSrciOqtOoDu/B0/Ewu P5mptvZkgxkCgbvo6m1QM+EldooShCzr9D5RBvPaZa7y92fk5ksgFy6/riHtU/s1a+6ZRRfMSK 56JmQnNkrXqJyU5iLOOkxmpq/VC8EUJnnjXipoWxwuiZhSBUtknGlNAZ9gWEnGBPKRTNH7WFbY Iqo= 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; 13 Feb 2022 18:19:35 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jxnwk3Rmdz1SVp0 for ; Sun, 13 Feb 2022 18:19:34 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644805174; x=1647397175; bh=MDPQos9blKV8Oo0LcY ELhApb03Psw+soVXabs2uNE4Y=; b=CcInFUB+txcTRSTpk/8t4HWZmqb0EM105Q cPyuU9oVYAGbLseSWDYCyQkwAZkbjKGeMkVOyV4QPbwPun3XB2oYXaX8KFUaE6SS KCnKhTA4p0KHhUdXbGUqxz+NpftIL1KPoKq43ICfapFMGOjClYggDKZjLkdVZ2Ed 2rC0y7zhqfl4Fys/18vUxS7MCA/6Q19YwCVm1+jZ8kmdCaFpbH2cTQzUi1qNIirZ 3XbF06ESS3FHqVvE/JRae2hVYLnZaBSEZzczFg5kxkT+tfNKx5iDvpc6mpsDRq9N w3wzbD47CO7SqfuFQSWP2Y5DleSAbRLPFiD6pDhrqPphKL/BtBWg== 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 M26dlUNN--Ie for ; Sun, 13 Feb 2022 18:19: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 4Jxnwj15Sqz1SHwl; Sun, 13 Feb 2022 18:19:33 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 03/31] scsi: pm8001: Fix pm8001_update_flash() local variable type Date: Mon, 14 Feb 2022 11:17:19 +0900 Message-Id: <20220214021747.4976-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 Mon Feb 14 02:17:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 542978 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 2F235C433EF for ; Mon, 14 Feb 2022 02:19:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239279AbiBNCTq (ORCPT ); Sun, 13 Feb 2022 21:19:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239227AbiBNCTm (ORCPT ); Sun, 13 Feb 2022 21:19:42 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2926054FBD for ; Sun, 13 Feb 2022 18:19:36 -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=1644805174; x=1676341174; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=5t74Tf5rpwUVmPI1L41m0OpXRpn+VClcyjp+ij7cEw8=; b=UOEIfPLUvHjL5r03OWBMtY2dz/lxM8vdrAU8QyWKk+Qn4ZHtq34QLfWh YRJHOFP+cELSfekaAPusGoDJ3+eNU5ERgZdwd6KQR8mE68h+sxp6f0vDa idN2nlssngVJEfEMowgRXJeBzkQiciG5iGL+mgm9zgvFlFqVLnJzQTqfR wV1RIJr4X4xiLA8fqomJY9P1zCnu3/5e6ROL0m54OaANvF5fYdllXJ76c 6cndZfBe0PMVRcFZJINxsaOPhyGkAVpCESJvO0U220qlmOYX5WkN2ukwR FmnJEclLtL+w7o+LeN8epJOeHVGtiLX+t5QpdQhquxvj9RejE5NJR+7l/ Q==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819752" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:34 +0800 IronPort-SDR: dbWIuRT4W159ElVQj0+R9c6+K8WnWsrbgesLez3e9F3Q+yPlysvqgPQHSwcD+vRE5CDtIALOO+ Ww1835xNXeGXevr/EE+hWsDfN8jFC+NO6+b+pjpWUTkZmHN/kuBJAVr5XR9w6nScefN8Qpzm16 gShqwgQff0WoTu/AhqG3HFGg5jkzmbnJy/zFOxpPsEDqOpdW2gsDTpR+Mx66VDKyJgSfqoCSEW BVXO97f1GHAHs2Jq1/XN7LH7wvtSm5Tdm2XVikZB90WqJzZRnX+0fZjwJHRRJ8rqe1Po/8InDD MtuXvYW/UvJQ6fQQzu72wA9E Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:27 -0800 IronPort-SDR: eBd+8ATK5Z4OxSBBzwYT6rSqHHKC3ct6RY5VjzNIIIHMCgiSQPE6lHOZ+xqHZpgfLv8csh/dbP +bZV1G/loVpQ8w/TM8XIu8cwRx6fh5QZXgoB8AaZJioVJbsZxGiN2voswOgoml5MPfSiDezyAd 8KhyWjOI297CTKifv4T4jKHQ8eJC4uLPvxrDVIVK5T1493FEEKQga/1xNZR6V64DWsg0d1A6d4 ZN4PQdHgXwNJP55Ev4wowYXrpwegQRVQy9jqzVLPh/xapW/vj7/2qi20uEx9d6ExPaW6ogu7AF +/s= 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; 13 Feb 2022 18:19: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 4Jxnwl5R5Yz1SVp1 for ; Sun, 13 Feb 2022 18:19: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=1644805175; x=1647397176; bh=5t74Tf5rpwUVmPI1L4 1m0OpXRpn+VClcyjp+ij7cEw8=; b=FtmM8gpBYxitzBlskD/5r4XdF+GzdLvF31 1esgkcjbBz4h71fy3eHkREcjoLPqoWu87cUI0INAChl+4mwLxF0uoUDqH6R6v0MP 74xM7/C992a+D+017Ud4zuu96RIBQ/8IZVt8Mk/9pPqE07ytHVAA6/8flV5DbjiR NFD2+zw+p+PF5jOZrajgcb77yXNdJQAV8NvZcaOojRLF1uwrcvDYHAjk8BMYuQTq qSgNW09/qFO4PPzITCl3pUZTaX+eQX99x0Nv8DgaAkawxFzsd+K750z89b7u0cQ5 /FylRjte/u6eeG/9GKl1I5OpSU3NqrwaGL7YMvQjkk8tfsErxMpg== 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 j2ctVKfZz-yN for ; Sun, 13 Feb 2022 18:19:35 -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 4Jxnwk2Xtbz1Rwrw; Sun, 13 Feb 2022 18:19:34 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 04/31] scsi: pm8001: Fix command initialization in pm80XX_send_read_log() Date: Mon, 14 Feb 2022 11:17:20 +0900 Message-Id: <20220214021747.4976-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 a9decac0b5cc..dff859bc5501 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 26b64524e327..aa0c4566db4f 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 Mon Feb 14 02:17:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 542731 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 C2D82C433EF for ; Mon, 14 Feb 2022 02:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239285AbiBNCTw (ORCPT ); Sun, 13 Feb 2022 21:19:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238144AbiBNCTn (ORCPT ); Sun, 13 Feb 2022 21:19:43 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A602254BF2 for ; Sun, 13 Feb 2022 18:19:37 -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=1644805176; x=1676341176; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=jMxdxrU0dqTbaKqxZXzj06nBG69eVj9OnhNN0zbXqww=; b=m2irhwEf3/6n1MWF6O5W7qeXVGfWCLpVw1io37pDEHGHzOQKNACw82Uj SGLnWc0HcL1NF8PlaluBZ+kOFQOMdxIxd2M7t0Rt4kUogpVDb2Zap58VC HRUNLpdfp8339iViIX7d29LVIYsmQoPcvWpaxKyQWV/jOpxuVb8nftvOU LofRBTLqZeLR8J2sMJi0l+BeUPyw++w0Et9UM6ovs3NcC8E4ZjZg8VrXK jEvRnqcwjbzzCxnSkZ6HnTa0EGCKlYHCKBPRhSKT5a/p/aksJVAIK3tyf b8iJQTGMXvmhMttc8dFrCUMXy834+iQy01svQa7MLjeuCWvbQr4XK3+lA Q==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819757" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:36 +0800 IronPort-SDR: GLm1LchmgD2oOXTRsavrGmIMqFnxLaxDaFO5hzlHAijcS8KHQQ4pAwJ+cEt6lXcjPBMI0M4jtA h/cn30uIETKBJDVKKs9nOpArNi5Ickmh7jiBJ4sdTiwSbJd0qvjEFXNRvMzSbDrngPWsOuxGP4 HMesw+crcu0unuYOdZtPJCD62kAAtBb0ocn6hWACP7tSB0oEHYPMdb7iiiyrJPkAntM6Q71Yyo Mz6NRWZl2oKJcuF+t/dlXiSufhUE/T8NYR05rknTaEnNmlLH8uCojjeCX/YcUTk4n/ZOabWaco p6wjmnVwDe6eCtUUe3oLcrgi Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:28 -0800 IronPort-SDR: QzqvXqNCoemb2/bvLSFjr8T/qHVr0UvW+Utq5Wdtj2z9Fi6yQ+eSY/+lG6n1b0aVpmZqwSir/T tQHQeDWLU2UYQI4vew6010PAlQmfZhLXl9+WdQapl4+oFCn4u9u7/CMH2YgqNR4vT/vDeerVyv AZpzzgH40fUHixr838oXkUO7f4g6pumqP2KReoXyFuFRigqumB2JaUbj3py08zkBcZNJXzPCzT rL0aJoCIuEbDybNhih3mMdz8XEaN4AtfqIUD8F6K6PBxDjnLbZ/SfaPv0TjlHoev4zSSIzvifH c7A= 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; 13 Feb 2022 18:19:37 -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 4Jxnwn01T8z1SVp4 for ; Sun, 13 Feb 2022 18:19:36 -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=1644805176; x=1647397177; bh=jMxdxrU0dqTbaKqxZX zj06nBG69eVj9OnhNN0zbXqww=; b=iSV6XSLwDuR9B2Jl5k2yqwX5940i0+e4CG JEhtNAgd+ngJngCU9ys9CkNJ3K6+sGmlOxDAjNomCwMitIMDiJ/jMV/5o9aw/aif +dWKNDEZhvJeFp//G31eDNCrT98rIDJmWU+vdoqSwWoMo2vZitfTFV4TFYgbYhV2 nAzcJA4GbEXewUYsUHtJ8c9FtinO3E2RmJ89kO94wb3Vjxd1ITDngXP1qTZH+zrD ZWH6gksyZRgEKz0pMnMPW3ApIna3ILiEN7JgxIMZoOCmnSUJHsubcBy7hYh94e1L 4ZRL4gu5xdevYyiMcnJ9JZY8q+NyVqT4bYJvBJ6WHS97dhgzbGQg== 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 2g5f3d1sgLdg for ; Sun, 13 Feb 2022 18:19: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 4Jxnwl3qTVz1SHwl; Sun, 13 Feb 2022 18:19:35 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 05/31] scsi: pm8001: Fix pm80xx_pci_mem_copy() interface Date: Mon, 14 Feb 2022 11:17:21 +0900 Message-Id: <20220214021747.4976-6-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 aa0c4566db4f..8a2d4087d405 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 Mon Feb 14 02:17:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 542977 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 90799C433F5 for ; Mon, 14 Feb 2022 02:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239287AbiBNCTw (ORCPT ); Sun, 13 Feb 2022 21:19:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239276AbiBNCTp (ORCPT ); Sun, 13 Feb 2022 21:19:45 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A23EE54BF3 for ; Sun, 13 Feb 2022 18:19: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=1644805177; x=1676341177; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=lPlJ1jpntsbW3qJvt9DWbYFxrXX/dwT/B8+c/OeYbws=; b=VwUjRWqZwqtdmH9JMqwxjV2wEF1uWDflf9VtB/P06wDgx0E9EDA/x13T Tg+mzEvJHHZ03sQnxT2bFUwY+n5s6iiM8lFk5TRS9MU1wGJpILGV4J0Qd 34jqfoqGPQU/gQct10fzHXfOM7bAGRg8kEQ/NdlCxsY3GbUzIPh4CjnPw bQ/G84X89hLcNq33NlzJ1Axz7HjkPp2Y8f5TdOgfyYc2VjmVRUdwvd4VN MmGkagSeSyD+3NA6yZDmmydElkcUImwKrLD0MzGuGzj4krz0avgNMYLRT pOhp6e5OBnD2cdS7n+tw2MiJgMf5uT4IZjUQjS/53hXlaMZiVH8ZhYcTt g==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819763" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:37 +0800 IronPort-SDR: VOkFkZ4hPzFBSBhyv6JlUqWYllAV0imugAuQnt7K+b2jOBvF1CSIW3xvcuzXWC84nuHM38d/We YoANoEqGzjPhDn8PDgPJ/FPPsk0Wc0MlrAB0+pGhwVgNSolka+csfsWJ83dNuETJcrUQTR1XdT faGrje5TEekIMjPyTxw7PwETL5qAQWjCpU/xfh8t95ufEdw6cJkm065AAHzw+5d7MJ7BicvLF4 ES+4qhLuWj6uDAWS3MrTVdlGq5g3L9QHpzv8mAxk76bppEQKYQVx3wBpv5uy2CJSSIeRFucArc NLwVZdHntH3BtEKIpovlMoSX Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:29 -0800 IronPort-SDR: 8krEBpmF2N1EaMibRJ9ybqJkIueFIqQ4cuehKEo/HD3s0w4pZJ8xS0LiQFv8VMp0hSUg0Bvs8Z YCWLmbCmf0mwv9C6gtWi97S7dja4UL+7BWSQrkiIKJKpMPKpX0uV2fVxyyqoCNUCMiXH9fMH45 jB1YZNn58ykc6UjBsaB/Kz1neitM7fOGDBRdu65UhIbMYJebysu+iORqvlOS2Yv09PJudstGlW 1Yqj/gXRXfU9c6WesQFGMkwvXnxzy87xQ9cVhxn7Y3e/44C+WpjxsZR3hTg0tiTfpqh/kWql/G ujM= 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; 13 Feb 2022 18:19:38 -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 4Jxnwp16GFz1SVp4 for ; Sun, 13 Feb 2022 18:19: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=1644805177; x=1647397178; bh=lPlJ1jpntsbW3qJvt9 DWbYFxrXX/dwT/B8+c/OeYbws=; b=B4ML4AiZVuAQU09ZJ2GHBhv9yUhAsxJoSW NpA+q7lD/z/SWo9L8eZyWrh+/M+BL3ClfGwyFpIAX6N8bAQsHK0q676sifeDlze2 ep2zQvPLmITAJAYCpLTK13rqIW80nHjhgZBh3794L+4m2SvI7BwuASqg4mrZVcEX jzlKCF0U4ekLhrH1GA5jluiIWHutvf7M1qoT6MDbomb3uVK6nla8vY8G5KGIafqg 7xXeQrD1HAIIr7FixawYObZ9+Zg/aTEzyFlfXtOlYQDu9Ik5xlxtEPmVlJdpitrd wcLS03Y2nm/XFFFu6FLSqnJJI1VVmbl9qBARqxZfIso2L6wmzO/g== 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 EBOBEfoeX2MW for ; Sun, 13 Feb 2022 18:19:37 -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 4Jxnwm5QCYz1Rwrw; Sun, 13 Feb 2022 18:19:36 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 06/31] scsi: pm8001: Fix command initialization in pm8001_chip_ssp_tm_req() Date: Mon, 14 Feb 2022 11:17:22 +0900 Message-Id: <20220214021747.4976-7-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 dff859bc5501..3893bd470bcc 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4636,7 +4636,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 Mon Feb 14 02:17:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 542975 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 A1833C433EF for ; Mon, 14 Feb 2022 02:19:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239288AbiBNCT7 (ORCPT ); Sun, 13 Feb 2022 21:19:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239278AbiBNCTq (ORCPT ); Sun, 13 Feb 2022 21:19:46 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6B0754F9C for ; Sun, 13 Feb 2022 18:19:39 -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=1644805178; x=1676341178; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=iJwXDMeNXdwiuQiNAJCJFMRv0jlB2dyc+Scv5z3ZPjg=; b=kpGNZLz4lFZuMDB53ougvSWEamjl/Pzbo1WqarjfpX5A3thwZyxijUHg apCZTuIfZ2huK4eTjKhTRodQCOrLzT6Cb7ATaFoSqTTveBRCNXhVdYok1 2GegvJ+CcvVsUFVQe5eZ6zTFSS52YTm49KeOfifcBOIXDk3gMzFkvTImp q8Inb1vPJUa1i4H8+j7//Gx8sqEMHtuEZw9VhIcB5ZGSswKSHq8H63fiE AimXAiR5Oar+jORcrfu1n0yUnGcllDUax2moiKkMav4DDw9wySHU2UctR OY1Q6gWnQ5zx0gfTmdaPXaxfvXkzccDozFRiMZMl9nnMbcdJiJOFfF8cY A==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819766" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:38 +0800 IronPort-SDR: ht8pVfiS533d/b9wXgB4XQhhuownmROTm9i/rqAXcTBklQ1SMz2nNRnObrDmPl+BfNpQmV+Qz+ BmRgs1IcuKXhTR/D9u7K7sLwrJksaEr74rx7cziDc3R/Jb4vLlRVE1jDo38oBMaZFDkBy+0a1q rz1kW6ykfk/mn5rmw+e9eRc8EpVWIXk0ZR/YxJYtDiefIUJM6c17UfdKjJ/oJZANGfDM+xkje8 JP8ubV00Y8lnlIo4aPxtZEY4ZF2MAdoHDQdnl/tOx8p1GmEjmiLTGASMSKtCWnhoGXqtHUKUMB tyD70LS/oAyr/virUCjb9tRL Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:30 -0800 IronPort-SDR: Wdj+pK/MxQcE41PdE+ntoDSzNFK+F0rFvAMcoVu9lQAEIiByYeZAW8pcP7sbN1dIfT6SphnRV7 3ZQiKFZFoJ/V1T55uZjvH930je5kOVcE+uDzmxKgEXQjdwsBaMbbriUJgx6xoEd5JSILfBgd3n vTz/ZafXJpkD0XMBxVHArXDMa+CubLF8qj9G+4GPgREAZOHx0VCKqT7pV7AIhz94re6xxsOITN n8++e0YWuFueR9952wxHcUD8nqUeSbDiNSy4SVY9Wz6hmhizW7eqBfMkItv8ecOhfn1I3Zavyb zhg= 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; 13 Feb 2022 18:19: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 4Jxnwq340Bz1SVp3 for ; Sun, 13 Feb 2022 18:19:39 -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=1644805178; x=1647397179; bh=iJwXDMeNXdwiuQiNAJ CJFMRv0jlB2dyc+Scv5z3ZPjg=; b=tEMlG14Qg9I1ZoPxioqvNNO3Ma695CsU9g LAYW8E2hWlfYO2zc1Iz0hB4+W5czaCkXakn/j5HeBgeqWj3Fw5CAgHKMZTq7xlTh wvja1FVs+iv2K1rVxmAmq482OzqyuF7n7gFJQYd7SsgE5z78dWlBns8tsOZ5aWB6 ipkgEkWpzOv7n5RrLf8MzzsGStaWtq+221bnKzkSqzCPTGqoTaD0DhtEXHIz6sKS L8C+JxUIpv9eZmskGVVkdhLpgPTqrOp8kEx0/Wutr0o4OHM81c05Tul4RqIl4sZ5 8z5toZ9EUJZHX/MH6x7JiQJ9Tg4TzN7RXCXS0vQI9nDkY7ic+V5g== 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 5LYIz-aH8hlx for ; Sun, 13 Feb 2022 18:19: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 4Jxnwn6lZqz1SHwl; Sun, 13 Feb 2022 18:19:37 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 07/31] scsi: pm8001: Fix payload initialization in pm80xx_set_thermal_config() Date: Mon, 14 Feb 2022 11:17:23 +0900 Message-Id: <20220214021747.4976-8-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 8a2d4087d405..f9c4cec514fb 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 Mon Feb 14 02:17:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 542729 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 B6B70C433EF for ; Mon, 14 Feb 2022 02:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239296AbiBNCT6 (ORCPT ); Sun, 13 Feb 2022 21:19:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239227AbiBNCTr (ORCPT ); Sun, 13 Feb 2022 21:19:47 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38C5454FA0 for ; Sun, 13 Feb 2022 18:19:41 -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=1644805179; x=1676341179; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=KDIZnht9JbMO/oQkD5bZFpkpgjYcz/UzkAqRFrp1J34=; b=ckF+IvNGYL3OjbS0mKLetdW8gwxasJOqm83d906LEB3CbjvBWWm+/fPR 3I2xtuDF6VDGZHZP+muujbirPr6BIi23yuewNs6XnRsT453Fze9viNx96 EBSSZP+NsLDhZGF49B73cyBRAj53Xi35iE3o+MsnXw62MLg57nAUC6ZVa Bc1dYxobN6X6zehkoi5tG+JVazKbh1wd/el1NKlyV4bW5egsxSgoBPahj vDfBH6Uea9j71tlNGpprlz+ToUq/D4IKsFLgI3JP+r5M5gNsZW8E3Z37J DwC9c+kCTuP5myTwRqEXbYSrsQUKEuFPWPDxNM/v27JBjunl+AhUyTlAC w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819769" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:39 +0800 IronPort-SDR: rmZK6s+vIj5nK7vxUcPywlkjm1fkJJAUD8eg0yJ5lXLe2PNZ1aIf1JYmbSuGjdZLXj4qqUdKO6 5Q2BRBD/hmmTAhmhl0JNjKp5ZgozUhelVpfIwjgQb8fMfNAPTQF009uNxU9azoLkd6pmeJUj7t tog79IAquIQBqlexNzmAXhhnqCml0J8xYu/fyjGlWNqDs/KJrltbppzxcqRbbs4KpEJUaDnKQI gqPezsTkCKN1ifNX5t8XsxLPdxnETsHHF+Cmu04nlyYFGIkeUURg0JaOwXLytxH6cDNepyzyPi B2tlu/ELaxOabh5U4K0sp6i5 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:32 -0800 IronPort-SDR: qM7agTZAKKn6/kb16U1oBGBZ7xZAKePpaW3GgMvp6UFYVNLQpdNxSU8l3LAhQLTcQu7HrUd2Ix 4SnbJlGOlMPeIAkkTMLt4GSxi5C2ezP0MuF/7TgZwKQfKOSGv8Rzzb98gmEPhcDCUj2HDNA9Yp ELQ+BdFn74rCMfiGcu9d1NUR9Vu3PmUW+e5k2xc0O3xvcvWEdCxj6ATmeCaweufi/BiqlZrGuW diMmcebQq7Wf6R13f+BEzQvM66P0RCRPBwVZlk2TtXbhEuc3+EF73CpOF8dfZVkylYiqOYkmCp FP4= 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; 13 Feb 2022 18:19:41 -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 4Jxnwr5ZBTz1SVnx for ; Sun, 13 Feb 2022 18:19:40 -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=1644805180; x=1647397181; bh=KDIZnht9JbMO/oQkD5 bZFpkpgjYcz/UzkAqRFrp1J34=; b=c8n7YRbwukAgKmKv4ouBv2jC37YZyDwdrO nnI+R/IrFFAi90sT1EcuSdvkCxbcKk18PUC05j59yw9nWeTqC4O57/FCM5t5zX8f OWhAydCkECzT3m0d99Q0ExtQrQp2z5POdWhPY9Itu+jhVCf2Y15Ga/sbxYigkS2Q UQHehqfK5gRG/UHhcM8fGW7WXqLYKN9EsZCL3rq1lNiMDW6rv5aGEr5hB+eU4kU4 M3kmZdPDi9I23PMQPwvOINy3cGqKWF4xpj7lcERWkK1ETS2JVEhNwlJepyuux4TU YTma/M4CJ09t5A8OIYQIgG46ELV9xefaEFEJCPt+r9rwfEa6WYpg== 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 Jpqxaw8C7AHL for ; Sun, 13 Feb 2022 18:19:40 -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 4Jxnwq1dd6z1Rwrw; Sun, 13 Feb 2022 18:19:39 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 08/31] scsi: pm8001: Fix le32 values handling in pm80xx_set_sas_protocol_timer_config() Date: Mon, 14 Feb 2022 11:17:24 +0900 Message-Id: <20220214021747.4976-9-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 f9c4cec514fb..108e4743fe81 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 Mon Feb 14 02:17:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 542730 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 B2EEFC433FE for ; Mon, 14 Feb 2022 02:19:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239293AbiBNCTy (ORCPT ); Sun, 13 Feb 2022 21:19:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239282AbiBNCTs (ORCPT ); Sun, 13 Feb 2022 21:19:48 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 497BB54FBD for ; Sun, 13 Feb 2022 18:19: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=1644805180; x=1676341180; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=NED7TbeMhfuFfImpTHjjdM3/ALr1ocTrAkJX4NcdYvQ=; b=ORz/BNYvYRtelvFUqB24f73eIKIJNbhYNnRLVii8yTn85NwDjznUCa5y c2JMhPAvcXQ7/09qnVtPz7O+8jisVmadXvF5nEfyWWOw3mCnFj/ubcvSj i0S5G4yJ+/lNLpuWEDytuQwzw5p2MB15cLr/QJHfpWT1d2vVXYbiA4EqL y47YZzOHZ/Fm9H1SQuRzzRzfDX/WudAmdDLd0EW+XOtuxtORsgK1tFoqK Y673z8jqqt7T24jI5U9Y2kdzswZ/8r/LDjhDkTl2+OH/96QcHE/SCFn15 9U8Ut2tSfzfYJSjJIVbNgq4LqaocZAoGvtI4+cqzs7hk0H/AzGF8AqJlF A==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819773" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:40 +0800 IronPort-SDR: uG6yx7W3pcUFTklRtaUebzgPMHdmBRSSHvLIJxgBE0UowYmmLh8z0B1jEv2s6WlnadSi5V5RJz IcqBb5uk4mZvD1LynkpSZaiO6FKMx7Hdx5m7NFTflwz6hMG8B66uZPQ44THl6EDTCB6moln/+A 3SlpVgTw59AfQw7M1MUSoCVQWnHlvqlQkzFgX24ydBT0oNa3KdyYrix7lAEIpg1wHjvRtV6TKP igy84Jx6RMFJUjJSXvHu+FOIyGIjVHzpja8T4/0TLjk0PVgWPARaomZO+nUQEHXvwpDMRrpCXQ 7mo0VHv0hkqNAsWbRi9ISIgY Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:33 -0800 IronPort-SDR: luUdkZcgsEYLczcJ1V7fn07ZFGMn17Y3af8xrJGiob+7bSH4/4jkarGsqgwX5mKdhER6yyMJKz PLtPoATM7qDvUxe5MmGF7POupC8hsOtqul4LXkaWexEXCrHflDmtvyQnhHlc3VDcjxbX7j5p7w vVKhBrFWUD8ghiXXdj9wBMVAjdkPtkfTebFaL81DPMSGWWYqPShgn6M8CFKb9/MVpXXwFdeE0r Ywq2V7OsXKK0/yDLJFs2h0oUFLn0yXPwqs4yEqwdt6jNcUxaJpKOXlyJv21UuPvA87GcNQ0sKL EwI= 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; 13 Feb 2022 18:19: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 4Jxnws6WgLz1SVp3 for ; Sun, 13 Feb 2022 18:19: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=1644805181; x=1647397182; bh=NED7TbeMhfuFfImpTH jjdM3/ALr1ocTrAkJX4NcdYvQ=; b=DHym5d1P38n1A7IjCOpmBy+rcnv/okWif9 6FBSlVE774DNiIkQHrKhtzGi/aCNVBNLmFyOBVWGIVvR2lrqZNE3gWBNEzSMQdel 3oVVOy+oaAV5C8vEhFA/0qYQT/CCcdaBZEjdrPLMc6nrJgNDdOEbdU1ds8IGL+NJ KCbEG0nXLXd0TSMwhN8tCwWXwLWA1UxiguB4BBLqen4H9Bj6C1/1tAhb5GvN2dDy V9ZVjEboFW6G7KPJim4b46eZKt/W637pCCVgjHGEhba2jc0v9URKxpNudMWFv+tt 2IEfe5gHzusBcFqxurZitzoG0ZsEr6BFy+II6vsuP+u0KbsrhgBg== 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 ytC-AyBDA657 for ; Sun, 13 Feb 2022 18:19: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 4Jxnwr3T1hz1SHwl; Sun, 13 Feb 2022 18:19:40 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 09/31] scsi: pm8001: Fix payload initialization in pm80xx_encrypt_update() Date: Mon, 14 Feb 2022 11:17:25 +0900 Message-Id: <20220214021747.4976-10-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 108e4743fe81..8e4c515f54f4 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 Mon Feb 14 02:17: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: 542976 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 3D14EC433F5 for ; Mon, 14 Feb 2022 02:19:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239295AbiBNCT4 (ORCPT ); Sun, 13 Feb 2022 21:19:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239283AbiBNCTv (ORCPT ); Sun, 13 Feb 2022 21:19:51 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22ED855480 for ; Sun, 13 Feb 2022 18:19:44 -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=1644805182; x=1676341182; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=0btjr1vrPsbMAw6lPRCbCwzcLKrnll0azm1uZIVf4Fg=; b=lnG2R6JIpTM2dS+EpcjjexPOS2iM1SYgnQfIUzaAYp5N+y/pGfcZlbPG o70obSKHZIAS5yFn/y337I95YgkXOxARSF/Vmdb3/gt9XneSGz+aU+YmC TAYxJm6AMC5dlfkYPgVXptVck/itbEm/VPS0HjGlVjOxL7MO5kJljPQrX 4iecQJAE86blWzZsJMKKEpFOxcZQdCtcK9nUuRFc3BAFk58ZcQsV1bn2a prBt5PtTN2mJKbocQ6KOKCQi0f12Btpis913ha3KVrZw6RH283CyfZ91G zwzDVtHAW89ctEQksfQTJf/UiH/fJGGj3Fz8WNA72hjfUMLQcFqdXMiOZ w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819774" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:42 +0800 IronPort-SDR: tlQlv6t/ZhB46DTlWoFa6PkZB92T+0YKHALzPSTZjMG/pfxV224SvcSZXtqepXESGvQYk/f2uZ Ppha3ohownaVTZkfpwlOms2qDJaz1nc5OnKRcrPbSVtOfI6Hg3yVz0ixEEWnhroj9fqhkR3XVF aup4d4EejVdBDLfAlnBSiXFkITJAdZVQLBiywES7YUSr4uxFrL5vrSu/MdNnV2rTkcByOdpklm oNF0Q8AY7RnGhdyt4COmwslbsf7M/nij2W/I0nHoIKeuEFTjd0xhbseh4dkN8BSxb2DgTQ5tv4 93VOr1ZahHcNPtfl4EXB+2ec Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:35 -0800 IronPort-SDR: ZoqHF3jfGTDmfXO3lkpHzj5ETjAHRJPfHtUawdznyOkD97v4HharXl1Jah7Ycxp0HGm2+hfpCV 3LrwGhi+yxoBMj1xWrQ3uzQDBJpgQvpjNdtcKLf5Nb2jqDsoPWksZ3D4fLFEn0oaZxuF5nn5C7 EXqTswalcpT1FrrjHwlhg3/nLBrPfjCf++pRT+WPzMnh7YyXHsPIsIshsaDRzZRyhu7V5jo5QC 8xfo+s5e8ms1qLk7CX1k5WmfSm6lZCcu4kIiBB/eoVN8UsZAMWTiGo27tWnoTTpgCER5MrcEDa 8Qo= 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; 13 Feb 2022 18:19:44 -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 4Jxnwv3Hb1z1SVp5 for ; Sun, 13 Feb 2022 18:19:43 -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=1644805182; x=1647397183; bh=0btjr1vrPsbMAw6lPR CbCwzcLKrnll0azm1uZIVf4Fg=; b=s2x8ou/WJfu1wk0wU7bc4SUahmWPxYl3yN 0G+OCfesIXZd+uQ+dY5lq0pp1fBnz1HJOZB2XvyE+/QV+Wd2DohUYXiERCFwTjEb gpXNefkkly/Q9LP+QTWWyjw6FjIXH2833RwAwt2T1t1bN30MtKvquuuM8jOZxcMU 6kt9EhlubrCWUqxZRipOsIF9BNQEGzhvpdh+aeAYM14hYvb54ggVhM7hwQ2A1kax uEG6sAxK19XarkQSMpJwzSa6KhU09FxYzh1c+BqCOJqFeTtzbWp3OhZYcUts0NxV mGuOUoR0BgTyW32KZPYHIwtRNVNjsZUF2ZvCzbcoIYUDwVS1Xf1w== 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 cxhLL7H6ztGj for ; Sun, 13 Feb 2022 18:19:42 -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 4Jxnws5Q5yz1Rwrw; Sun, 13 Feb 2022 18:19:41 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 10/31] scsi: pm8001: Fix le32 values handling in pm80xx_chip_ssp_io_req() Date: Mon, 14 Feb 2022 11:17:26 +0900 Message-Id: <20220214021747.4976-11-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 8e4c515f54f4..0ed4bc114e5e 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4386,13 +4386,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 @@ -4403,7 +4405,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, @@ -4435,21 +4437,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); @@ -4458,7 +4463,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; @@ -4466,8 +4471,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) | @@ -4489,20 +4496,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 Mon Feb 14 02:17: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: 542728 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 6AEAAC433FE for ; Mon, 14 Feb 2022 02:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239302AbiBNCUA (ORCPT ); Sun, 13 Feb 2022 21:20:00 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239286AbiBNCTw (ORCPT ); Sun, 13 Feb 2022 21:19:52 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 853BB5548A for ; Sun, 13 Feb 2022 18:19: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=1644805184; x=1676341184; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=pLMCxajGv9sYN0ENqVZLvNwK6KVenET90GZjTnlRS8M=; b=QhxHEmWY7iULY8ho+72Y2Hp3S6KyGk4dzDMmbLES0g7FcK3upCRh0d/6 2pQPXfrvoklTo3qPHOT/+DydHgPTMr7DY1wg5g4E9aM6KPbxJRQV97kTJ QXMlrIjbxh5XiKyTOhg0H317h5s0yRKN8UeuKI9k2gD0dWIkGfjqsYtSN u6BR7TiFIx68oPxD4oW60+5DSKpp+UTtcGL139eqaspJNub8HVhV1K38P QjjkzGej+l9jo41DssFihM+Jf2AnHzqe6EcjihYKCGZSksmeW9dktBP5b d9gda+6wF28UzHZwOdTEFF2Q2jkezWZLPkzubkuAR7osyWB5rOBX2SN1B Q==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819775" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:43 +0800 IronPort-SDR: 7zX4/0V2T/171/UCr3BrWcrDOFePIyXZWCkEASHwlbniBBgQ2FC+ZXID1Uu+GB05d/WsfzXGPt I1Vgb5sYX7Dvj6T3kOTazPKFOdVAdohsmANOvuOZZXWyZn+UlTZwFwjrH7e31o3Yd1lBIPOCl+ 7FHio/2luWsNe2dbU+KDVEVQzktk/AfTp6cHpWNMrrdpPtr6f7oW6B1IUjxcx7EFCXP18aNrLL /gqfDtG9UjeDsn0gOBFg0dc+st5meWSV/rDyE+/XKs6uC/UO6OAC/+t3fPnrvy5O03YRwoN7hi 3+QGeCjwubJvUsweUTr4a2en Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:36 -0800 IronPort-SDR: iCOICaoA/a+MUhFNPX3ClOWhbvgfLPsH6T2Ycan4V/VJPF8gXITl597K8Jrduj+25C5Q4WDfsu hEhX9BgyZj/apNhdkkYKiZAAWgUeZZurRz613gMx+RlFEgJjQgvINHkzTKroVPfzVFcxrwRMJ5 jtLDeUU14+HryxYW8EZQpJ5fMiVkiVwauvCrsM1dFN1wzX6tqX7NLA9d9e0Cyo0V6+8feuEXNu ErDpyLjA6VtyJ25OzSTKXfoj4IKS4RIkYFbhrnMd04Pqrw6pkUEl7bEjO68xb0EyfugQZl3XnZ Up4= 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; 13 Feb 2022 18:19: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 4Jxnww5Pbmz1SVp2 for ; Sun, 13 Feb 2022 18:19: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=1644805184; x=1647397185; bh=pLMCxajGv9sYN0ENqV ZLvNwK6KVenET90GZjTnlRS8M=; b=pAT3d4WjfV47VRFYYx26VrDeUbXlYbeXCW krq5E7jvaFA33t7hLcDNcrTF65bVTl/RY4qApXTLVaXzFfUa48Lrlp2a30wtD2Q4 P3DVsRjPz0Q0yikKi0m1jQBskYZyaxso/OqmiWFktd+l+GKcWdqd2TdD3pPs8HbN lgt50c3hTnrOUeLKsr3H9SyTX4QMg9a2WaVPmNDq+1qbkQSWmqotQsHUgzVluHE/ LCU75rblwdCd9Z9CT03wd/OjVrT734fLSTiYMXYB+jE7LcQGOrlLjqbvKXoNtp4N fNkgz+CEBOJ9tJosEM3q3s/D+iLYREzd8eVe/xsw1azRkc6TWm8g== 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 jM8d9HiUKyNd for ; Sun, 13 Feb 2022 18:19:44 -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 4Jxnwv03cZz1SHwl; Sun, 13 Feb 2022 18:19:42 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 11/31] scsi: pm8001: Fix le32 values handling in pm80xx_chip_sata_req() Date: Mon, 14 Feb 2022 11:17:27 +0900 Message-Id: <20220214021747.4976-12-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 0ed4bc114e5e..8ebefdb18c85 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4546,7 +4546,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; @@ -4607,32 +4607,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); } @@ -4643,7 +4649,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) | @@ -4669,31 +4676,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; @@ -4701,27 +4708,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 Mon Feb 14 02:17: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: 542974 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 B4602C433F5 for ; Mon, 14 Feb 2022 02:19:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239307AbiBNCUB (ORCPT ); Sun, 13 Feb 2022 21:20:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239289AbiBNCTw (ORCPT ); Sun, 13 Feb 2022 21:19:52 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 758A654BF2 for ; Sun, 13 Feb 2022 18:19: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=1644805185; x=1676341185; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=bHQOfB2LDNW6/HN86h9WS/6qfZKtSpm7HW83n+JZIm0=; b=HbsRFJ+U5/ovRXTJYQ4DPNsVyQloIyWtsiOkMmjgSGFgxxDU2Ws2HMIO oIExxYy95sDVAVF41NS1VhWR0u235ZYKAOKVMOB+vROx0ZU6NiT4MBZrI yzdycREa2mHaIoxvOlRBeW6St8YHRCmkq2js7StEVns/sXvkttWRGd4Ko 64qscUAQyyjriPZBDP188r1TFPSeSdbv/GbEPFIzabXcPpNLCKDhkfCLB XfomA7OzWwdm21zqD5TPjUIFxla+g0J2KZOQRNtoXkTv7fT5fVVpdlzSt kt8zptX968o22KZ1tbyVey1C/czCLjcdi3PfY7dONCo3hYj99LaHgw19Q A==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819778" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:44 +0800 IronPort-SDR: 938wwIiKLbLmzFooRQwhKvidshubN8elfZVKYEAMGTkfisNaYjZtD0mcvYOxSjXIUweMHkg8KU WrZs0mpK+J2UGnYCuLF3tirPwflnfw/A9FeNIoOpYeVt88Bquh7gf7hWnRvVW95RDPgGuqG5KK IOexcrGkF5kt/R1zAWOgdSi3PogUzzxs8BKB4Gs55URLmbkwjq+NGwSbPtdJZexCPLyCTVirjl 4kBvoaKzKjCbCSq/eYfn+vOZkgu2tq4rq8FFfBJPEpuofvNx3GsFU2lZD85gG9de58H5n5r1Ri aME1YRVrx9eWT5r9wzX2CeSH Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:37 -0800 IronPort-SDR: EVV1B6W4CM3dWD3G3AMC+WOuQ61OXJ4jPvI4/Gt733ny5AH5GpbDBGXEwlyDKeY35WIK3mixJA hblXHoJrpa9fr0Y+YbH56durWgDBz+qFGKuV7hBE5VJyeXfYW3maTVLJ1OlYnV7eJ7LKqmMCXB kDT9qryoYIknYDyMjgCARDP5AclQ3aALZgCUjQLKdXfhI8QU53Dr/2eGCEO2q7RPiFnHUWxmWE FubH1AcIE29IcXMDset6v2uoEfIi9heYW+cWj2XZs2DdXGR4W+JRknk0w0sYuELMFylFu/+XZl LC8= 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; 13 Feb 2022 18:19: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 4Jxnwy02sQz1SVp0 for ; Sun, 13 Feb 2022 18:19:46 -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=1644805185; x=1647397186; bh=bHQOfB2LDNW6/HN86h 9WS/6qfZKtSpm7HW83n+JZIm0=; b=lk/8OAibGlN2EDaDWl+k1SnvNcUXy2QB/4 Joh/ddozIiTZu2l5PURoJMS6cvEUnU0aV0wKyC9Kd3OcOWumpbEHC7HrTvwjXksl H9fDvvEr7XL3eFA0kwK6HqaW1AVjRf98TEseU8z7lPPI3QNfVurEdeBOL6EYxs79 Wl6CY4JvrkrhIP+Jv6nGqNxzHAGQhe5hH9Ymi8jwfI0pov2nHFbeq/ibW71sTk6i qBP7YTed9WPEeu1QAhTKHnCeCQCONtstyjv1XIFntcl2m+RVdLTDyshNRLNoGLCh q8E+sAumieoQTRBaH8NenfdWLyvTfdFyRkoUt2tQgNN4w8njQBlA== 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 XPOVH_KkN_yv for ; Sun, 13 Feb 2022 18:19: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 4Jxnww3gp7z1SVnx; Sun, 13 Feb 2022 18:19:44 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 12/31] scsi: pm8001: Fix use of struct set_phy_profile_req fields Date: Mon, 14 Feb 2022 11:17:28 +0900 Message-Id: <20220214021747.4976-13-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 8ebefdb18c85..ad2e40425fbf 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4982,12 +4982,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, @@ -5027,8 +5028,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 c7e5d93bea92..7cb59e38e67a 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 Mon Feb 14 02:17: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: 542727 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 5AA06C433EF for ; Mon, 14 Feb 2022 02:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239312AbiBNCUD (ORCPT ); Sun, 13 Feb 2022 21:20:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239297AbiBNCT6 (ORCPT ); Sun, 13 Feb 2022 21:19:58 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 822E655480 for ; Sun, 13 Feb 2022 18:19: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=1644805186; x=1676341186; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=xiP1M0lFxhMkb2FeSA/f5haQvFI94F08NJluHNNUbzw=; b=jZunM9E1qJ7oXEHMKClzEjeJRRg/NxlN0AUOxtFXSFIF6y5TdCdZU4kt rKtLtVwgUuzDF6orfnD+jf6k5mzIYeaJlDcRzesWG/j9muNdTWm1Pz9MT l4Mx0q11pEc2/qmEBoGYY+40XNSWrzjjI/Gr932RE1Pae933DOVrRKlEC timUMRYxE0d/S9H4XqC8JOZmVq0SKAHTO9PKHqU9oBZfUK5nnYx2bUujZ e47tN5B0KL9+fTiSpbSizaXpNG/Q6741eCengPNtjykGNZeRcttDtH45o l7RkZe/yp+l4hE7YQjJVv1dl/MKA3fdOPu7Gdw3BVRkxRcmtwF8mN6+om Q==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819780" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:46 +0800 IronPort-SDR: l7GmQVf4qCp9QKiZ3qVPoQRGQBEqDoaVXsJe16bOXVWmDIfjvcwKSEaTlo5Q/yihnvJ4pKw1QC T+djppzKr1elC3BOnJqzSmMGEZlE7PGNA87vtr85g6IgScdCAwBGs5buHN+puXTVeP7FZwZ3kQ F1ABakDUxlGjju/TXUAH/IwsjHSjM6kk2qATGRGdHkWJNkkSX7DyNR6kI9fe4T8iBfKpDDJGgP 9PLSAQk+BD9Sw6dybtzw8VN4uepOSmp5h78XkJSPAuYABh7OjYpdGKIlfCDntB81fcgr9JtLWi HwbG1i5g016olHf4GbYW07nV Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:38 -0800 IronPort-SDR: CcbBA68pE+rX0n2B8h21aYSRzbmWQWD6YLuAfn/RGB9a0S1vdBAf5OcDQmNSYpfq+KEObdqceg zmXKFnj4s7I8wZtqL4dnoyki8Xx/ScYs3YYmZlnd0f41H7bm6pNx8PnrQ40vZVl1URftTGNidV ZChnvUYbqKPoK4Dylqx2qRppLAmRxCz40KyqCq3EQfmFO1S/D7+3jPTvkqUPXHCixSGnIBpi98 K7RqzYSnPkSv2jL+Hjj5WCe69VYBZ1vG9u7UimjDpOSh5Z49/D0/hbKOFSCvhl5c5cUlXBfJMT zVc= 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; 13 Feb 2022 18:19: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 4Jxnwz0kHhz1SVp2 for ; Sun, 13 Feb 2022 18:19: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=1644805186; x=1647397187; bh=xiP1M0lFxhMkb2FeSA /f5haQvFI94F08NJluHNNUbzw=; b=Y7veT0ZMUrar4MxF+mgKYc7wqdu/oNLTS5 YdfH46J5Q7WlECNqwNdBagI0zOE6LFwl33NhbWlO7iA31bZcsdzCwfyGPpCQ8a8I UyFEXAWsGlvXFrjhdrhe4SdEcnYE6cjldBPNEFKDKcgcxgPij0nGIVbD/ZIALpeZ hRsX5xFsx4Hdme2HmuY1EojtZ7PSSXKOUfln2QnGA/CojW2CIMxs90x1+VZqSHcg vjB/aPb4aJq8vP1zyJ+57t9CrJUWpPqy6vq/f23G5+drg1QC750mhYeL2u5hmClo BT27ncA1Q+Hzn5vSx+L2Eg63GNJQ2eNGUEzCxREcvxzuMq2F1Alw== 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 lGtx1RwlC4NL for ; Sun, 13 Feb 2022 18:19: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 4Jxnwx5Lgfz1Rwrw; Sun, 13 Feb 2022 18:19:45 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 13/31] scsi: pm8001: Remove local variable in pm8001_pci_resume() Date: Mon, 14 Feb 2022 11:17:29 +0900 Message-Id: <20220214021747.4976-14-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 Mon Feb 14 02:17: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: 542972 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 625CCC433FE for ; Mon, 14 Feb 2022 02:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239338AbiBNCUJ (ORCPT ); Sun, 13 Feb 2022 21:20:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239300AbiBNCT6 (ORCPT ); Sun, 13 Feb 2022 21:19:58 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0942F5548A for ; Sun, 13 Feb 2022 18:19:49 -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=1644805187; x=1676341187; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=t/WNZKYeyLBwFXhlFGTVtK2Melx7SSJT0u5Enyjx12E=; b=pWIALOa/F0Zjdj/bLZONzZRZAlPpSKSY2C+Sr/fa9QfPP4CL2yoRrT1y 1pN6iVQcUJ8eZv1v8sb/I2gj3w2gG8tZLlSDjCkjKBWCOp6MasGN1WjJS SVmr3Mp/RGikcgzdB/49IsoB6qXWupFNZaD5Zv6BTJBsB4Gqmk6sKQFH4 QvcDYxF2geyOry54zzXL3hhlCtLf5oyMyVLqXxvHZpqw1ZdvAvraXolQ3 0t+vGxydExfzvob3OGXPt6PPAuftae6mS6Z3DxuAR/C+Mad9thisV+3Do Dj6+ELN7hN2Jd+w17VkVIdrxOJhZ/d0TTqQSXy3pky1WunysSlAgknXTn A==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819781" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:47 +0800 IronPort-SDR: II0ObshelsijRI4kSpu3qH1F8bGt7CavQbFV2QLP1c0zHzIznfrCn+VjHMo7BS2LmQbdRtEA4J 0unFsyUReQlZJKkHFACKPKPv1WXk+AbNCJ62aQ8DTnDJun2mgsKM/RrmfFocBQyQcN4jUKwiNL L9rrY8hK9kuVnrYc7mdhjPYwQRWkB+q1rVuSgnz1reeceUQr23bqG8IpSLL92s4Or5yokV7X/K +/OWtAo6h11FC9abiLk+1xmTFDHH9KaJSHDVL2/HCu+XbT61i+CaVVlob1+peEEhWh3ojwhWLr zsJc0UyjB8UfeVnJH7NyM2hz Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:40 -0800 IronPort-SDR: qIRdADW0JfPdjro2iHr7FG/jOe4SIdF2e3kTo0kKmWqkPVBE1DQL07lWrvgYLfG1FAK12My5VT j5BYxGrfgIUebmppZk3CSgbKuuVACAZztrNyPJLbMpIIcly6bRxmanMy7yHmALT4CCuAHyEyai SmZsTVi3bc2SS4bMCOp1QM/rY3FRH1G74kvNrii76iAFlosAfWeWd3AQXaprP4mc0KxbzL+kpp 43xyVzlIb5AOu20+EBvJ09LpcA46Dp5PcdPnOkjDB097EDPpRgHpSk6992WMM3vDijVbEjtY0E md0= 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; 13 Feb 2022 18:19:49 -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 4Jxnx04L50z1SVp6 for ; Sun, 13 Feb 2022 18:19:48 -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=1644805188; x=1647397189; bh=t/WNZKYeyLBwFXhlFG TVtK2Melx7SSJT0u5Enyjx12E=; b=X7Ov9HkqEy+odnptvgxtR8M3KkwFBRrlfT jha3I+umrMNhsSuZ15/eUtNsqSPmMnDhLOVBkXrYOh2ls09i6YNiTqDp1p7NnUc7 MSc6sJzCchK2B3O5uU+pJ3FXoMGs0aRnhDPMK/1wG4Npqxp5TaU4YBlHofT+R4L1 nyQ/ZHbvk0jvNgpXI7lb/nD0cMKq4ohJrM5qVQskCBia9jr9UDyk1RfJR/jROzWA Zjb76SM5oCsu3M+J3f6cizIKp5C/XO0Z0n2qvwzz8/kEiBbPzJZILaSqT1fH2+yu FZkrCyr6d4F/uaCssxnUWyvntYYJoRDf0UrrV9HDyr/OVg1aJvIw== 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 d3dacjywPhOh for ; Sun, 13 Feb 2022 18:19:48 -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 4Jxnwz0P2Cz1SVp0; Sun, 13 Feb 2022 18:19:46 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 14/31] scsi: pm8001: Fix NCQ NON DATA command task initialization Date: Mon, 14 Feb 2022 11:17:30 +0900 Message-Id: <20220214021747.4976-15-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 3893bd470bcc..3c667e67cd2e 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4282,22 +4282,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 ad2e40425fbf..e3b03ddc26f8 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4558,22 +4558,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 Mon Feb 14 02:17: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: 542724 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 D635BC433EF for ; Mon, 14 Feb 2022 02:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239345AbiBNCUO (ORCPT ); Sun, 13 Feb 2022 21:20:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239304AbiBNCUA (ORCPT ); Sun, 13 Feb 2022 21:20:00 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30C1255493 for ; Sun, 13 Feb 2022 18:19:50 -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=1644805188; x=1676341188; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=mAjreO3fKTJBiy5H8LkeQRjqGGc5QjmbGOA3kmDk7eQ=; b=L/YIi3l8V+pH+WIk2i9pIorgAcAyPxoNclcX8QbtTB/1uUsYG8GOP81C E6I8ITDGsq2PZUbCk8ElnVix7lWQImZPghknIZ9BikxzduSTwe2RUb4dW H0yJTU8PvqSFNnZvqneXM733HpXg+iOg0T9NR/xnyU5Lppx+YiklEvBOb dPabEvnhpKSvDylE4QKw2U2hSVMOSMw4hmGM/c6Pc4aLE2CLYegP5gTIu LKEG7X6x783YvL3TVZBjCZv4kVCO5/uAC+8dT/Bl1H5FXRK1510g3jQ8d tuqfCKYo0+bqDUh49+TPgPlJ3PU6PEiE8757WkWYVty+o0aBsA9H6Fnj5 w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819783" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:48 +0800 IronPort-SDR: DnS9ZeKV63XXSMqy8fv1URBtxXb+n50UXB/cUWcEnXgi9ZBhV+RHpCOcumb3Bqs005J1L1AdX9 EU3N+vUjQvqcqDkTLMs5n/0fI8lkq6pugG65vOXQ5SdKL2ZIhQPG8jFReFRs31UuBKNSfG9lmV nCINzfuVfF9xuzXnSEvRyP/FfFD93B9ZdCyz1V2zNPEB8hwFNOJx9UF5sU6OhpB+nlC83YOP9M ie0oVFBuzKZ0hIpTx1hq9Y4ABUYJEquyjP+OZkhBANWyqhSoXIFjxhvdSImVDSfQ3GoOrHfPPv f1eI+ELvbise6hDmqrrbVI/u Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:41 -0800 IronPort-SDR: Bi9sBDjvomsvMPWt+2Zoql8pa6V6bP168awXD2/asu+iVovfzqVBjye5wPqM8RKOLOTjHvJgpj xJNnmksKhQyA0vbR93wyPByEDjXs3DF8CHNTQZa3NunWDh+T22AGs2JhTxjkVqt1hHdPUa+rBN do4U815RsCQthb+dbgEeNgcYlctWEM48/3S8se9aRVXv1wQzgfF+7w9S71BfEzXcIrscrzvZWo 1Q9esOfR61dWTc6oW89mlw8G+xJuHLbWWIbw2yNRgxEBuh2o8o/fIQ35pS2J+LVUW1QCTSaxhV hZ4= 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; 13 Feb 2022 18:19:50 -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 4Jxnx15ZNHz1SVnx for ; Sun, 13 Feb 2022 18:19:49 -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=1644805189; x=1647397190; bh=mAjreO3fKTJBiy5H8L keQRjqGGc5QjmbGOA3kmDk7eQ=; b=GNZ/73MbkcMaC8rjAwSYiij1hbLEuYLyAd 7FKG4zY7LgtfvqyvUqhYoU3jYwarMYyt25JnX1qmEElfj2jXNALKJhLV85gmLa6e /9OYGSvwG/w6G5S2vK8qZV5ge4nmwTbD0fje4ZE9tk0kp7EBIeIusqoRZOragQIV /dnW13BhnrWhpZF481th+/o7+B5OTSqBSyZVXgYHUYm8nWCN9R+V44fKHjAC6JAn gRuz31ay3qlhw0BNgTp0ef7+t7EUBhDIYltGbsXrKdSSTSt6rPfikfr0U5qCtM5S qIOe3Z2BjfRdzAq3tuF7cif14GZUajJ8VfDe8a2EpGPfK0xnlerg== 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 04gAz_sRElFZ for ; Sun, 13 Feb 2022 18:19:49 -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 4Jxnx02snLz1Rwrw; Sun, 13 Feb 2022 18:19:48 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 15/31] scsi: pm8001: Fix NCQ NON DATA command completion handling Date: Mon, 14 Feb 2022 11:17:31 +0900 Message-Id: <20220214021747.4976-16-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 3c667e67cd2e..10a78312fbaf 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 e3b03ddc26f8..082b6353d3fb 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 Mon Feb 14 02:17: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: 542725 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 9E92DC433FE for ; Mon, 14 Feb 2022 02:20:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239340AbiBNCUL (ORCPT ); Sun, 13 Feb 2022 21:20:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239305AbiBNCUB (ORCPT ); Sun, 13 Feb 2022 21:20:01 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7C0055495 for ; Sun, 13 Feb 2022 18:19:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805190; x=1676341190; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=LkPJ4W2YDFbhkOm8t/qvikdEfXZGFmtab+qbd8cEAyM=; b=eq6aXI3sIVvlvY5Hbhxt4cJ/8/TSwcQAppnYfLaJrdaoHO6M3M0h5E75 mcFFOWWstW+d05SPs//sOIBCfH9w0s2YbflHlZBvPKqfBV/21jkKa1swu DThXQRCGSW/yVzaDRzk4BoPYYp4krDDLC7ihTLKupEQGCl69iW1HBr9fr 7De0mvU9J/haUznpZDYF4UnwIN6Rlgp5I+99wG8h93MREY6mPwrbPOsVX 2Mt7e9CEDi+FHvIK5gOQCG9YtIZxDOAwHZO2RTjKA4tixGa7Z30DthRur tmPU/AJsyYqbd7c9q9+Xxu+NoZ4tWQYD+f5FdY7Vd89A0MhJmpxiDwHX/ A==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819785" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:49 +0800 IronPort-SDR: nX9whnBVPdWapRwF+3NPeHAr8LTKq+n8S2/7YJq52AeMoWcCFz/bh8s2QIePcNr2jVQykd1XF8 HeaFI7haBZvLrH0sNRVnN8bTMwa0yKqzmpQE11xSBy3cpTNJIO+TIiiuPXlYYqrUJNe/RLaiJd 5oMstJ9NyhvA3LQaAEoBsBqz+kg1afF11pmym6DByoXLudE5YG285aeVCOdC4dmrJZYGZcqNPl kLp47cS0Li999iCgDPx8ZzhZqhmWP6bNtnhj9lxVXVOAPxDSpZDSi1e56GZNqfBw3jJ3E9+BOZ DyPue6tkqVKtP+1DVmSXoINM Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:42 -0800 IronPort-SDR: JrT9BQqdu5GM5oTJRWcXm6w+5WK67l6hrTr5mA4WuokZnnlTZSsVu/5mqDMEagvnX9iPBO5P5b mIAuI24UNhIPxw2AoQX4zdZx4R9AxGFH+o1MhLXTYqu3NRGcD6l0A99rL2a4ee67R9uv/SCWGz cIgsBJnaHvPSq4+iJpFzTv6EGUzxoEpJVnH8Fz0+qMai0iggmgboIGdN22o8vrJ01zckM8lQeS H57Yd8lydLpSpLc7a27J1DHT8P02oKKIkA7hZIBKIMJUS7s5mmIgBfbUqY6fvraP6lC/pgpIVB A2E= 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; 13 Feb 2022 18:19:51 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jxnx30Mrvz1SVp0 for ; Sun, 13 Feb 2022 18:19:51 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644805190; x=1647397191; bh=LkPJ4W2YDFbhkOm8t/ qvikdEfXZGFmtab+qbd8cEAyM=; b=FwfX7cHn0hCpN8HXDDSnB/OBZxGGScxsuF L3nEAwQzX35NZv/3hW/3Y986cJOHrAlwRu+rOdpFsPYIvjhnjrfr2kaYN0o+/uIE jrXv67kB2Jlp8p+Z2ex5OLAfYhaxUiKoqyYmgMhBPjwDDBJOEpf6Pgsjf8iOURjo dsNBJob2DYu3X2TnSrFYpJfg5b/uL7l7tZQ7R6lfpPBGd8h3+Ph9rHCorPvQWazh PCpHZvvnD9BDFSWRiA5Y2pr9NOoOjichD7avWbK8TSkpFEhA9z2DT101Q2o5cifn BR5pzROVXXm7IDU7tAQZzwTdqEF8ARkgdVgSPaIcPpLGNA+xhHYQ== 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 mctRJa1zljwV for ; Sun, 13 Feb 2022 18:19:50 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jxnx14Gyvz1SHwl; Sun, 13 Feb 2022 18:19:49 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 16/31] scsi: pm8001: Fix abort all task initialization Date: Mon, 14 Feb 2022 11:17:32 +0900 Message-Id: <20220214021747.4976-17-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 10a78312fbaf..e801d4b64d09 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 082b6353d3fb..413b01cc2a84 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 Mon Feb 14 02:17: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: 542973 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 115B4C433EF for ; Mon, 14 Feb 2022 02:20:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239297AbiBNCUH (ORCPT ); Sun, 13 Feb 2022 21:20:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239291AbiBNCUB (ORCPT ); Sun, 13 Feb 2022 21:20:01 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3B0B54BF2 for ; Sun, 13 Feb 2022 18:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805191; x=1676341191; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=5md3sK84QuUpHn35PdxcI4RezoMmvUN8R0P8iTKh5C4=; b=fTOGtJ/zh7MSkH26FYCcwxRSpdDcXU7IjLIyUdcJI0LckR+voiSqI7B3 8mhTk7XhkktNfEu5i3cOGPYXa3Syj/kzHAa3+WPfE+QAXjbYr8e6zT7Of pOy0ILn5HmtMTlH+CPaTIaKh1wjNdbH5LYzVTyVNnwiNo735HV0Q1Oh/w sDJh8tQ9V6SpEKmBmyz2PypBOmRPuKPfOTA+3mO1X7bMjNG8phrfmkBnS x6Rpr1Mn56YuCR1Ydm4B+BXqq+/UkLEjaZDo3VE74Xvxi+Rs77SwAiP4Z KZXaCFKuqnjTPAf/kIyiisOwC4Q/0wh5u4p5RSZ6NYGF3Zybe1mzZ1NYZ Q==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819786" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:51 +0800 IronPort-SDR: NKL1fDq+KkK2xbFocl2hsWBAOotzoveyLsTMAf8dCau9IUHLtrNI2jW4sPUH2hHec1m8aXVP2t phLyneQ5ucG2VyIheM+JcWovXmZ3SR6ybEGhU8P0qB8kAcmQuBeEGxtylJ63qhKZGrHEU7Mp/H TawG1+AJFfhlxVg5EPIem0eHjJQXhnrQNpo70PhEhyc4gQ4ZG7/+G3yCDiCLnMOSIhbCYE+2B0 QcF5A2d7n+0JvrtX/60Fj+kRYB8OpzxQbwSe/gleM7de5upsVu7ivMesZ7wqCVK/rxVEupE5Yn 1pYyByZuUFHVm7AiTqGm5yhK Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:43 -0800 IronPort-SDR: 5ox+C6Ax63qhPzbuSvzSSOFRt3Cbjk5ckT48PavqQlWjmVa27D/H51qnp78wTZn5JqLVMHsJFs 4a/XSKy9j2RbbkzhqMOAOq25hjAxRUqI0iK55iFILzvscW5BP+aOllMJn2kyFWDnlP56dAJu7X ABOXjgSHTsRGYx1Oe7kpvJgvrSZ1+MrxbkvQam86kLZbwXJ18VnGJGYkpzZDyM64xdLYQhBvnG qHVwF3iZ/wbxQE/YtGP+0i4qz1/XbYDZdZjZEG+E0+jn23ndFGcJYes2vUymMkiTzyyuVwm425 okY= 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; 13 Feb 2022 18:19:53 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jxnx42t4vz1SVp2 for ; Sun, 13 Feb 2022 18:19:52 -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=1644805191; x=1647397192; bh=5md3sK84QuUpHn35Pd xcI4RezoMmvUN8R0P8iTKh5C4=; b=dvehZ2Fn0c29Bc7wxQIyBgb+gfkzpBtR01 3xYzNdquCKzHZnqpT/nK526yeN9wQGdpVXz20X8PUu+OQjp95Me3nzi6OLrVbFCB 9OhpU8Jl/KlDaGzI9A0Uiqsq3pEAgniF4/NYdFxoQ+cv4DALlS14lbQwICi6tst0 qEFC9ostEGRS0kzZiHY4CXJZWQELQ9NFZ7q0n3xsjTHlvFETbzrVdmN39Q/hcjf4 Swf4Rin/eN7/8x8rNEN6Z4vKs4FNqrv8/CJFpGrOiT9RKpO6FozAkV920JdbDVT0 f3ZXAREZHfcLx1H/wA9Q+hK/6758MaA4l90I7yNK8hhpK2SbAKdw== 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 rL2rNw19BX6k for ; Sun, 13 Feb 2022 18:19:51 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jxnx26RqBz1Rwrw; Sun, 13 Feb 2022 18:19:50 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 17/31] scsi: pm8001: Fix pm8001_tag_alloc() failures handling Date: Mon, 14 Feb 2022 11:17:33 +0900 Message-Id: <20220214021747.4976-18-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 413b01cc2a84..b0b6dc643916 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); @@ -4979,8 +4979,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 = @@ -5022,8 +5025,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 Mon Feb 14 02:17: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: 542726 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 2C193C4332F for ; Mon, 14 Feb 2022 02:20:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239329AbiBNCUI (ORCPT ); Sun, 13 Feb 2022 21:20:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239292AbiBNCUB (ORCPT ); Sun, 13 Feb 2022 21:20:01 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72AD055499 for ; Sun, 13 Feb 2022 18:19:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805193; x=1676341193; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=T4zz8y6S9du7ZdDPwmWWGhl2Ku/KHArNURVQc3Boojg=; b=bXPNw++6JdxlKXmXouk+ek5BA5w6qOzqULUjlHhhH8m73rFYiT0ysOH2 1g6St/tjuSx5Zjp/eDQNWemqOedpkqeLTS4eeLgZIlBv27Zm67ZN6uXUv BIn9rlPODlbvVma36NlgHsrpZLYm0mRjMUvikQfvcFBfZ03X9Mffa+80v B8LX2yxorsAN4rvVDUOOLg+NvqITHVVK1zRw+04hL1rgF2YP4QXf+F6n1 TIMRpReuZKS1NEYgsNLXqLVADspJf/12dWuYSy7G5xpCSWFPXf5p870VI eR8ZkEg3ECPuuy93YUMncFxcub0Ze+bopPY6LKkXL0C662ELdcb1tdJ/U w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819790" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:53 +0800 IronPort-SDR: /oHIHqnGMwRgcvOMNgORH2fkpS7EG1wHL4vXVWOuY3WUKKsMbQJ76TXz+uSL2wO9EKMQ/UApjM V3qUektvta0cnlmmP0zwGdtIEmIAS18Wl1O16oK52VulBhiGEhOdGiLN8nsftFNvwDUKdqeI1r JoJJFHdm05LOUkrToXt9nVyGX3CxWrdV71hW6eDsjhJcbSGoKZi4YC+rT3QNDbUmnGd7SHXfIa sx+C5G5Z5nIGet7terImGVpXaDovapqgaSci3/4LI06z+/2BnjQ70GQLUyHCOHFJibwe4VVPA2 rAJy8NYB1vH36MLC7BmsAVmD Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:45 -0800 IronPort-SDR: 5jQszL8cAcADI4fGooPEMfKTM5xDJO0lm+cQaFfXhJVC4aqVLKvTUTpiEVFzSiPJieRkEGw8t3 DsmBxuWzvFMU+MGYq2X+PnsiIlrbJ5S7CyxTj5wXd4kJ6tIQ6xzh6MBfTPKY3epq9ZPjPCnF41 G4bUGFlwN49kRXXyITWZPsDS1hC9bUvD3WDA+3u9r9sjK7B36d2FdmH2OcpOcZQ9H1/XizKWJQ Nm7+8N/MCZnUrK9w2o/X+DG3m2fHjIFnDWLxVKgjT3sm8TKkvK0DRp/McP4xGCmVBfIlhSt9LU 7CI= 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; 13 Feb 2022 18:19:54 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jxnx54Xfnz1SVp5 for ; Sun, 13 Feb 2022 18:19:53 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644805193; x=1647397194; bh=T4zz8y6S9du7ZdDPwm WWGhl2Ku/KHArNURVQc3Boojg=; b=lCK0nilzMLXPH94Lz/gtFQn3j4ckOq19JH kGk5yIAtZ+bZKbPELEmbvCoWBO7je8/A275MpDnHaE6GfHeOdTIr+W2KnpH2ogoc SHFYrqtHbjlovbDN0qF2dqUiDUDzsHd5fKYvln9o6qQ8Le/awV2S+bF10d+hPahw bVKPJK6wYso44OFmRjhYpLqAv1VNx1BV2H3kz3SNXix80uxliZuXJgr1DCN3DFPX Kq4dBetrW29vErrBgYDsN1fbI7vGVsUN9MZ5dMBpm5hqfL8n8MRweJXQ0R6mYCA4 XyyQaN841KBWxIwdcg5KU9mw0+jazCbcg4aWcWUQKjnhaIW/KqIQ== 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 KGHzqHr9aNtU for ; Sun, 13 Feb 2022 18:19:53 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jxnx41qnxz1SHwl; Sun, 13 Feb 2022 18:19:52 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 18/31] scsi: pm8001: Fix pm80xx_chip_phy_ctl_req() Date: Mon, 14 Feb 2022 11:17:34 +0900 Message-Id: <20220214021747.4976-19-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 b0b6dc643916..73e9379ab09a 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4932,8 +4932,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 Mon Feb 14 02:17: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: 542971 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 817F2C433F5 for ; Mon, 14 Feb 2022 02:20:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239315AbiBNCUM (ORCPT ); Sun, 13 Feb 2022 21:20:12 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239308AbiBNCUB (ORCPT ); Sun, 13 Feb 2022 21:20:01 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4134954BF3 for ; Sun, 13 Feb 2022 18:19:55 -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=1644805193; x=1676341193; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=zGX4y/uzAyw7+WbJOHkm4YfSHUmwMGfVLw4Pra+fZ9Q=; b=FlLHr0pFo09kUz1k2ZTrwodnaSFwD6KAv9gXH2TJOmqc3epNQK5Wjc1q 7fQEzUVrL5bjJ7KfsKX/DyNmAtQoF1Kac70hc2G9nNIB0t1JG9FVZjuUS A4EmGpSFm0g8CEB9pNip+9QIwzbxaiyYUkn1YLrWOwxwGnJetUQ6bXD70 NSlyVwUjtBQZQizp2DNNuYOM9LtRsC0oBsGGNeUVr435Y05vaEQxIgtAl /j/IogjF6+iZylETpwmU8jM82eRiAnfqYpBtsb37v4vLcKqIoqrb9zUjk 16cz3Nz7cv3iwxJ1S27Ir/jkRKyPwojnnhS+ZtcPBHzUMqyYz9Tj3XEIN A==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819792" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:53 +0800 IronPort-SDR: XXqzhkSiPGztZHUdebgCjnGxaj9RvOUnFK3nfNSf39DFxsQYSndnUnk6OGB2rmcigVJWowZX/m hXa5A3axak4gP9vLw4whw2diTXTcQoCHzPHcC5zlrA8ys567myytIBSHp/RnJTbcQIbrqYAoAG RERaHYe34kQ/8cMt8goW2bK+igye/oJ+HSwN615kB0zqBAAz2igzVfk8oRCPXZBC7CZzWQ3Hat 2vG9Cffzwj9T2dkHrsPM8gAo+OJyMuCNU3vm6kAz4GQaATsfJs6VnkbS+5RmEFC+hbG+OQcTMO IxHdmB4Ieew84EjiPwrLcoY3 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:46 -0800 IronPort-SDR: 8E1QdNOWU6XFdbJFavIGPJMEwE/v399FIxNuo9rPjNzkIcMx2bUnRWk1gNL9nWiU5y7xgKyWpf UtO0zupmRQ6yoePhTTMSVm4n3wm3dYEeDL0s8BgG/ASp07P7PRX2M3/vAo6Bzm0xHRjunX4eDk io6uLhKcth03i6D4PcpAEpLFpxoKzL6pcjQ3h/zo3A4i6ArIYAprZlbAwWXIxxw+wfiGbPPga0 Qa3JL0DzF1C6HwzxLcxWwhmy11Fl1f3AJOHKwGnrz5ubBqKijF2khPga2Al/ynFkn7Ta3euWXH ZyM= 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; 13 Feb 2022 18:19:55 -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 4Jxnx663c4z1SVp2 for ; Sun, 13 Feb 2022 18:19:54 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644805194; x=1647397195; bh=zGX4y/uzAyw7+WbJOH km4YfSHUmwMGfVLw4Pra+fZ9Q=; b=ThOM/IWA5SNx4vfop/2nHVFj/dFXa+WThh sjRdJXhTTKhuEQ8+R3v5cMvIpq0WTaOJRzqB2lo2pXXPpu7oXmH1gDuik8mmNUvx ik7ms8DWZV7OoB1MFpCTMqIlbi9ncdRbffUG6wdTqOLffQpMWzYYQ2B24W8pAJLa OYJtVVC53kK8lSBYeOQlf3gnly8cH6bbx1vZ5wnkl4h45Njn4U017kV7+SE3AGl5 4Sgnaa4e/2/qxyFioGziNUqo0DdGoINCeTzVCqjgeW8rDRktBAB7GQ2Z5v/pPBDt l0gkcoXc4YoTTKaAIFqSuJQUbA6QI3fQjMslAfk7TylIg0czWZ5w== 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 7krUDkQF47US for ; Sun, 13 Feb 2022 18:19:54 -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 4Jxnx53Swcz1Rwrw; Sun, 13 Feb 2022 18:19:53 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 19/31] scsi: pm8001: Fix pm8001_mpi_task_abort_resp() Date: Mon, 14 Feb 2022 11:17:35 +0900 Message-Id: <20220214021747.4976-20-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 e801d4b64d09..64a87c5bd66b 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -3717,12 +3717,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 Mon Feb 14 02:17: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: 542970 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 0DFE8C433F5 for ; Mon, 14 Feb 2022 02:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239320AbiBNCUP (ORCPT ); Sun, 13 Feb 2022 21:20:15 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239299AbiBNCUG (ORCPT ); Sun, 13 Feb 2022 21:20:06 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20E1B5549F for ; Sun, 13 Feb 2022 18:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805195; x=1676341195; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=6QHf1qP6038Cw0rY/NPU+F4/hLexMcQAxinGpC5RN4k=; b=Uy3sYDh870LCYYA1nHb/eNO2u/KXfur8P/oeOprTqMvXNhl8yib2OsCi M94JB5DO9SvCJT3CUMihsnTUvzwkKPwO+8PzQDn66G551XEX5OuIQY4fM ULsjNH7RwiTaz3kiArzIC9fLuvRVtxl3MhpOmDgtWjtoJU5F3UW4x8S0o mZyDWOVhO1AQJ2BbMpfPWA8ly2z45ijNCGLgCnBTTnZywlHc7dbUvqIjW vjC/pUMr3HRdpU5u0L/UAOqnDHburo27c9C5TAYoiXniHk29ZB8RYbfKn X1Pn6Yd0vz4/cBqC4JXH1I5+j5KmewnFCuT0ALhvRW+uv4QVIHu6Dj4WN w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819794" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:55 +0800 IronPort-SDR: 9PwKAnNALFh7N2bMMq/djgSGppqfH2+n1RWTyHnaBMKUMNh4QAgQ476h16RlJ9FGmjV4Cwnsd5 Pu3zLOW7nq9FKtw7dNGt8eBFea1V2/Gbc0dTE/TZ57rMfZYRlJjIDbjy1eni/Oag0vuaA4VQjR Xjtd/G2OvJPTOPj9ZHNjwQv+ENNIfn6JUdhtW/dNByF/cKqIIy02sQJ+KmCI0RHrFyBKxaDm20 P5+FPmClzz1ABCLEWD/YOckadvutdYL7pm/zZF7Fg0gUoqDGJZABg3WrZSf9TGy8JLbJ5FXZ80 xp7yYkd7xrotQmK5D8zPcJHV Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:48 -0800 IronPort-SDR: gW0hT59ervIu72if/FitIlH1uj3nstYXkzR/Ss7s7ktoIF/6DzKqCjjGCQf2vz321pnDJE2Ej+ peLhUzZWEeBI05ttZywiSL+xR3T3nUGY7sT3fbFtw41pQsb/jidRh+yGe6WGUhjUgXpJhw7rz7 iRgSRlUA8debLJkWiG5AV5BzoYwW97SXqcoKGCcHuo3MnkM2Cva1ROBwz/pck0iw9uGjRZKMcA 6pwPL/VCmx2cbh4Ix/65dl8SaZvS3a+kvstKYszd5qQFINEMjAZvwp5/9zejQ8Mpfqy7PN8nVX eis= 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; 13 Feb 2022 18:19:57 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jxnx84qypz1SVp4 for ; Sun, 13 Feb 2022 18:19:56 -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=1644805195; x=1647397196; bh=6QHf1qP6038Cw0rY/N PU+F4/hLexMcQAxinGpC5RN4k=; b=QdohYIp15WzeWF7mnyzfojL5VVeXX/v8Ia QpHCl6H29E8s1z9NuPzz81fs3fxK+nhZGsym0/6ylwwycbRkO+4JcLrHq5xO31Z5 QFL5NbRoYyhkLDiq4Fo5cdapvitHCGLMDlObOLrR0YFH3ssQiTVO2tXjyPWlaRuC 14LAdX9/lbj2fjynhaRTzez9sKgeXL3mvJi5u/OpSnQp6croMD3zwxWhOyoQrDWm 7GtVBpEeqFakPsYb9Dli8CcdHYJin/ri+s1nzUipmmOumocJ7TwPbsszLYzINfge EXadJY5BWeyTxUcC9+pVOnjfq4N/wELbCpH3YtXPuf3jd8HHFZdA== 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 9stmgqle0Lkw for ; Sun, 13 Feb 2022 18:19:55 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jxnx651gsz1SHwl; Sun, 13 Feb 2022 18:19:54 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 20/31] scsi: pm8001: Fix tag values handling Date: Mon, 14 Feb 2022 11:17:36 +0900 Message-Id: <20220214021747.4976-21-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 64a87c5bd66b..640e8473ce06 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; @@ -3068,7 +3056,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); } @@ -3086,7 +3074,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); } @@ -3113,7 +3101,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; } @@ -3159,7 +3147,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); } @@ -3572,7 +3560,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; } @@ -3644,7 +3632,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; @@ -3680,10 +3668,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 6062664e8698..d9b8d61b7578 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); } @@ -943,9 +943,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; @@ -957,9 +959,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; @@ -979,11 +978,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 73e9379ab09a..9cea0a27f1a1 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 Mon Feb 14 02:17: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: 542722 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 B0173C433EF for ; Mon, 14 Feb 2022 02:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239359AbiBNCUT (ORCPT ); Sun, 13 Feb 2022 21:20:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239325AbiBNCUG (ORCPT ); Sun, 13 Feb 2022 21:20:06 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21EC3554A7 for ; Sun, 13 Feb 2022 18:19:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805196; x=1676341196; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Fmm9tQdadAc/BhpzhkDgviV9BX5k3UMAUui9NnnnwY4=; b=mzqhPtAEVnGsaE9ZsxO9d9/DIDhZkGBitHerLC/hNqBO5rs/mhKa7hGV PUAQv0M+r/2KTP1tY5jTXx/PmiGi8KA8H41hdCGpg3kkK9azUHfqhRbaU cqxbpEP11+YTCehPnrX9A2UtPluu+agnXMbiLPzUik/2LDV1H0ca0TSBD mra9HvFEnYbvGcxzTvv9I0S7GQkwk8CGo3A654hwqv5iTjBgY646SBQU4 Hv1IEm1OGO6SXHMmGD0fsCr+bce3K0YzEKQRJQhcNAU/ij7Vj9VgU/abz LeCegXQu2+FljnB2TGw/IT7wOZtLpWJefhhKg17ZIhsNWC4P5BcY2nkOG Q==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819802" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:56 +0800 IronPort-SDR: 5kzX8w3wFXb3/zjg3vSgK1yJuvkrMmZMKwj5V5OyXmL/9S/eq7NMq8GDuoomtNjo8NN5/jYlne smYSimxgLmUrdFZ2zlwNsisTGkludrD3wa2COnxQEvjoNJJbhMZ6moTedlXl7tyOGxfivZr8mO B24MSyOYxIZzo5NMaSnBJVjrtP6evoABW+e5KwuNPZycrLXEJm2YX5aLJdpb55OrxjnAhZj+ox Heh/tKFN0/G68wj7WhtTYbEvg9gnqhu0Zy5tAAdHa4M14b/dqBeHS2wX402l9WDV9XEaZM8fNq JDuW9tBWRDItOvZhpMk47t9M Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:49 -0800 IronPort-SDR: s5o7YgGKs4yPKE4BSdYQdClBIprDJhmL0hBAXwlNqAojdNckksIp7cvm3xN3YPpIHlHBNvZqKw IsDAIxcWakhaAXPqd9WVVNpC8NB4qtzM0pZjhwogqHZh4YbPI4h+WbANCVCcM/BbYplna38uIB Cu2SkNuExIcMWxlsmss89n8y62NAKR6M93Un2udXO+YWsMxmBh0BJvPk6MCOXv7iyE8d76EqD3 7t3pcf4H8Ic5D1sEP6tCnkvk2baexs7j7gLdAJlHIMqZ7YMc1e1AHEFl7UpRPP5JbX0FiSR1QZ FqI= 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; 13 Feb 2022 18:19:58 -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 4Jxnx93R41z1SVp2 for ; Sun, 13 Feb 2022 18:19:57 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644805197; x=1647397198; bh=Fmm9tQdadAc/Bhpzhk DgviV9BX5k3UMAUui9NnnnwY4=; b=lLSHcwPi2qvzUy6pqqzOsKlmVZHS+FteD5 dvZvQXn19b08583LMQEEZPrPwv2ygEWvItTat7qJXF3rWLjlt7eI3NnSxpcEj7GW ZWc36zhiuzPOWtE7r+lDwUWFL+czCwgxNzF4TA+oe/VP6fHp9mGF4wyIS9et2n2e 4uRPGmJ6zZ0lPR1/BIbeqSzqU0U1wILhJnp1gh5oWJWO9BoAqkrYaaC0R+peL8Nx TOe6n7rhWSNQtyLSPPu6XTSLgZ7T2FbWAOv+vQh6lxCDzJDMp0rTaURu3qVTnv9H NVPC07rvDKLJg81a8lXBjysTIDwdNk4FywAHS9m+xunCrFszmqZQ== 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 h1QSB-clmBZz for ; Sun, 13 Feb 2022 18:19:57 -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 4Jxnx773lQz1Rwrw; Sun, 13 Feb 2022 18:19:55 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 21/31] scsi: pm8001: Fix task leak in pm8001_send_abort_all() Date: Mon, 14 Feb 2022 11:17:37 +0900 Message-Id: <20220214021747.4976-22-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 640e8473ce06..5886c7a83238 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 Mon Feb 14 02:17: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: 542969 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 E5722C433F5 for ; Mon, 14 Feb 2022 02:20:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239355AbiBNCUR (ORCPT ); Sun, 13 Feb 2022 21:20:17 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239322AbiBNCUG (ORCPT ); Sun, 13 Feb 2022 21:20:06 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4115355BC0 for ; Sun, 13 Feb 2022 18:19:59 -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=1644805197; x=1676341197; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=vWpTHLH/qDB7R7jOtg82y/gQrcakEeDhri5rs8gln9c=; b=SbOHybQeM3mpeqMbJE5A7QbUlTMBFVGAbY5MjBV0r+mzWWnLJntpHZBi DTMMqIZGjIGak40cNdfQ0wKu+IhcvUfJzbwXIciPqKsIM1VuGz7NwSw3G j6HG84lPmWvsvC0qZddKwbtHGpqPgp3UicEGsXQKuwvQEynvHgdPNyskL KhRcEukf9/q3/zKiEPpLuMEtIoZChsppq/uYDdsDolhqykER4mT5AGaD1 zSkvQ4F9JjYTeEnOnB579hD8Vj2Z4YvWdksAFRFsas5+dH31SXvU5Dvrl HOdbicxXL8mJXVKhMIhRQT8abI8F+EAfbLWiJsEhwDum/qeO/PlP2MFCh A==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819804" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:57 +0800 IronPort-SDR: pr4/SVgxOwcrDnVlJ6ouj/fNpjQdCjy3nxI+NjxsmnCzVB2zRT5w8UImhxlbbRK2W12sZrFvTW 24Xl54uwui+z/1E6gkoy88pJuq0Bh6Grp5/vYQDBF1ym6uXjpPFcH8Tl+TEGjyQ65sDTRkrsED u6wKpCNr4pksTopKx0Y+JQNpMT3ma2fU62NUtk1X1503s3j5RAGSPxdVXmQ7VTZ2acTZQ6LcHd kKX4Nh9MPa3AXINbcQjBgqOH96Ungx//7wLBb13fQ/Oujg8ORKCzYIDoHT8LVo3ShMdGnJgSIb iDdyE4Eh1RR4u3pRGGBTg4pL Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:50 -0800 IronPort-SDR: S707ojhYtLy5yFoQkK+SDa1JmdOtJEiCVrjV8MWHwARXAyiiGoCM4upbjUfNGz76H8GIeBaVZW KEc+qP03cwLliZxWD2u+tjsdhQTCsOtWga1unBmnrAsmdyO6UqgEMb3rDOepZSmMuXHFevsyB4 /2g2kx0Ee3h1dr20wrx49+NxXpAOCQP3tMYvlcPmyE0PqHKOwM9aWfgSMFHn8WyqqGhEVHyTB1 MJnNquOTx50KHtwIQewMCusPnuY3BoDa8delgQRclLE7z/Mued2z3Dd0LrFZifYNspU231Lm9q NG4= 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; 13 Feb 2022 18:19:59 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4JxnxB5sYPz1SVnx for ; Sun, 13 Feb 2022 18:19:58 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644805198; x=1647397199; bh=vWpTHLH/qDB7R7jOtg 82y/gQrcakEeDhri5rs8gln9c=; b=PUwBH76xk8J5rGDx3clyUYCv4WRtFHbi9D S3yPGoQpKsgLE1s+Iv35PIlOlOT/F09mg6Kq9DibXC2gOYnyukpsfF8VEu34jtXt 29/mkhljOAb6CPs+zfhRI34pAKA6qxvfdoJKGPOqBJkoCKaevgI1K81tukwjW7eT nFfK/a5G/dzgd2bP84KnvRJK4f5xs0+sCNF6DCRyVCZR4M+rjs4iLTVzqEBWsO7q mCpu4z8DQOCqsUSQ7MrWxCI06MncL6cNWbVwtMnLjLSvSLxFRKC8Gqqx4aA+eIAZ Eh8Nz+ejHZCPtOTn5y5XhkaY9Lzg/26mzIDxnxuKpbyEeoLL9C7w== 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 tdJw6A1vY1HH for ; Sun, 13 Feb 2022 18:19:58 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jxnx92tKKz1SHwl; Sun, 13 Feb 2022 18:19:57 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 22/31] scsi: pm8001: Fix tag leaks on error Date: Mon, 14 Feb 2022 11:17:38 +0900 Message-Id: <20220214021747.4976-23-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 5886c7a83238..2eff6e2f6cf9 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4475,6 +4475,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; } @@ -4887,6 +4890,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; } @@ -4991,6 +4997,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 d9b8d61b7578..1e7031400294 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -829,7 +829,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; @@ -838,36 +839,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 Mon Feb 14 02:17: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: 542723 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 DDC86C433FE for ; Mon, 14 Feb 2022 02:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239303AbiBNCUQ (ORCPT ); Sun, 13 Feb 2022 21:20:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239306AbiBNCUH (ORCPT ); Sun, 13 Feb 2022 21:20:07 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C5AF54FA0 for ; Sun, 13 Feb 2022 18:20:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805199; x=1676341199; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=/y3raaEYqVXYgjRW12cIVzd6Yqgw6SYmQ8gCxfOl3Us=; b=ZaKa4vWIyGPYlIm6q700Eqp2vKMR7kIZ2Ayu8pOl9k+dNRWG9q+OGimX nsxem2CIeHs5d4T06D/z/Lb5XsvZimu9lSTTdVb/T7c8UJo4d0scZtnG6 AKzUbebZw0Kz1pxnuIkRvpPgmTC8jWsMUkf59xKyDq76p1ssC55cYOKN5 FGuHdt9ZYTvRSipteoAxsTU2Iov+FS+XtEWfse1zVyfiQJmcom3+NVh3r Y7O1rp6y3RXa57R0AdKo3ZVctXdcovSODGIiL7TNGru65gj54GYzqQXTZ qjSXc+qEPu+Uuy0SeUgXgKRa4ermtA6REFEX0nKsvs9aNjgzQgofXnbaZ A==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819809" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:19:58 +0800 IronPort-SDR: JIZSlp/ChvD1ZIBTK9crvVEaPQyzDRKVuCE0efaCZKFsqsTxhrpopnu19OICqb1HBZrgDMxDjS djSRFeNy7VjdK8/quKkO+yuWqLNrZCJs95KXzei58yV+PxojJlLywR9f6JFNBV/QS0bDk0C/8h dCT/u0j4LxP0pP0/af70e0YEEchF/5dWyXdAhYonfm8e1OJsQIIvQKC1fRR38MG+/73taauX8i yCxp7w3AVDqiOh/d54P+5b7NlepXudPD9/XbBfTH0IGz/4kJ7HH9GFylXOmzqTk8DWHKkTYp7p oKMza6zasjuP6vVsYKzqdqKD Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:51 -0800 IronPort-SDR: goEhiIabWMu5iOOA9sdnGpLWAjuzF9X8XVu4XzIytPlx87MxXTWUojc5JfBiUFEG1rSOOrKBKN H6EU3z1gIZLN5I8ZHoP6ej5SqbEephfaIvY1r1Vv+NQfPlj7HzH0ToQI6STVrcsaLLRL/LYZdK dG/cllZOwweQIATEpiEzLJadvktgqZEtG8tcIZYmPw0xmQMEyYaaU4JWDBkFYYU91VeWoyFejY dSmlYrOV7JprCztnvRjEjECv+N3sFtI5mjgFRBHH7Z2+EjjNq7M2nedZPmXrVJbYJN12sAxUcL u/g= 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; 13 Feb 2022 18:20:00 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4JxnxD0XFFz1SVp2 for ; Sun, 13 Feb 2022 18:20: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=1644805199; x=1647397200; bh=/y3raaEYqVXYgjRW12 cIVzd6Yqgw6SYmQ8gCxfOl3Us=; b=fykqWdPTYGC89c+x43OR1+a8o8/V3twBx3 2njBgdnGw4mqOatdgZ8f4Qd6JMcrSklTZ3Mdvloey6Z8lVj3n+zUyj8oRIt0RHIj ZeIXh/cLZOCfuunyIUzHzF4MH3/0J4d+VRjB2zKcZJ4zTAXRFCyViwD+Db1zm/+0 gUmWuTaOgnHMW1a46a489k4BROx/tLIincyyHiMIgvvPTvQFZJI+vjVr1+HqKodw TGLJzcBQw/nWD8RrdEXevmTRkR6GoeaH+luoo9B0/KvY436aK+a2x/iVxWQEpeDv GryNS7ITXIOfm0jYu3FYUx0zmE2OyimItY+NRCp3scc4yMB8oMgg== 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 r2__3bZLkO2x for ; Sun, 13 Feb 2022 18:19:59 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4JxnxB5jVMz1Rwrw; Sun, 13 Feb 2022 18:19:58 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 23/31] scsi: pm8001: fix memory leak in pm8001_chip_fw_flash_update_req() Date: Mon, 14 Feb 2022 11:17:39 +0900 Message-Id: <20220214021747.4976-24-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 2eff6e2f6cf9..978b1bd60334 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4890,8 +4890,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 Mon Feb 14 02:17: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: 542968 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 4DA4CC433EF for ; Mon, 14 Feb 2022 02:20:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239300AbiBNCUl (ORCPT ); Sun, 13 Feb 2022 21:20:41 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239328AbiBNCUI (ORCPT ); Sun, 13 Feb 2022 21:20:08 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF64254BF2 for ; Sun, 13 Feb 2022 18:20: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=1644805200; x=1676341200; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=PIfDTjlErIm0Ykd9p/VcCUrV6cd20fMAmosk0+slmG4=; b=A90trD039MHc0lRk2vJv6T25dXiJT2etQiGGgUm1F8UIgKoHmdj3DGWN PTnWgiIJa3HNKMimI59mnmRpxNiprD++wGIj9yz10oHTd9N24/ssBLn/b 72xT9t9pZ0mdE7SDnDWDtQqTN06RmoScB6S4QlGnCU72Ky4mLrKdaAyQU NWVW4iNk4NEe6rF7dY5/XVYEz7welxPI1CYONAgq8zLZ57Amk7kfB6YKC CV5FitcqvBIRyKg9VACukEXH1D+/aUGTx+j5YnJebM1UypI7JFUAiKcuf 9e72TkQn+wShNu+AC7dLO8DeGjyz86GgeYnCM/UhUeJqkugovd+6Cmwd/ w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819814" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:20:00 +0800 IronPort-SDR: QXquiZvWXe4N77r/+GGjKu0oCZDxoWuSRymoAn0FSU8ER9PLotGNTNj8nf66mJpwCYnr8QC6v4 UIaCnOYIgZlnFqirqDnA4vW+IPfBFfM2xr85/rU6anhIONnMHJef1hsiixuGIzDTk9gPjarGZn zLUE3uukmh3Bd4FYI0Feq3OlvfW+deXRP9RugCvTbJcjoi/km4gAjeZcqQE6gN1hC42BFqQXiN AfE8qOXPTJ/mOcsxCkIme86OEIU8pWtqVhVVD3EigIUnDZorQuOmlXTEhDu2jjMMR1izQmPF0v YKXSF7K52oqLKk/k1kce4Ubj Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:53 -0800 IronPort-SDR: tDOVQyF/VzWUfOvFBnfOOOQkkdXeUKHiQfQQQz91iHCWL3FwknObErS28yXwWgye+Ino46SAaA USO/ymaQr+LxNR/lohbFpm/i6L8ZL2cTCY4dRNGMClQMfGUDb1JGVyLEpCiTTf7zIp0+5PTfwY slUoaV6Xafbrr3H1yfq8lzR25X8TJ3W1jj3vtwWtILElPbw/SVjOv2JnEl/fCfsfd5iFjv624a kG7czFhPcPRKWhXTvW0rjg6hv9HSdVhla9JmYH94dSUj/aE4kbxACyZIi12IEHe+oRL3WJA/sv q74= 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; 13 Feb 2022 18:20:02 -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 4JxnxF2t5dz1SVp3 for ; Sun, 13 Feb 2022 18:20:01 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644805201; x=1647397202; bh=PIfDTjlErIm0Ykd9p/ VcCUrV6cd20fMAmosk0+slmG4=; b=WreBekZ9p8RAOLpSqShNbP5N9MtqBGF60l voWvKAskDlbvPzQnMTRPZbciAGbbI/Qsd/2pfCV2KRhF8G0J0zhSGJkAaG0glgjb CDDVluUWQvSSGRsJDJXPFzaWygoXozJL6hfgTCsGqNqLV8W4r05Nq8Q8uCvv73Xz H+PAZxTAoShLm61ElAnQkLEdOjO+SqUSHTcwbmAWjjps+epBSt304pbLWCwjsZL5 aocF5Nit8QQlcd2n56lrwGKr2r9aqwYja/7a8LRYNg3KoqOgOYGEHRZqLbT+KV34 sY0jsMoZgbpxlHilydpO2ZAEOq9o3WJaWI/tXlK37q6cMJq6/m+g== 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 Q38e71KWmN4C for ; Sun, 13 Feb 2022 18:20: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 4JxnxD0661z1SVnx; Sun, 13 Feb 2022 18:19:59 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 24/31] scsi: pm8001: Fix process_one_iomb() kdoc comment Date: Mon, 14 Feb 2022 11:17:40 +0900 Message-Id: <20220214021747.4976-25-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add missing description of the circularQ argument. Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm80xx_hwi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 9cea0a27f1a1..e74cd02a5c08 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -3922,6 +3922,7 @@ static int ssp_coalesced_comp_resp(struct pm8001_hba_info *pm8001_ha, /** * process_one_iomb - process one outbound Queue memory block * @pm8001_ha: our hba card information + * @circularQ: the outbound queue table. * @piomb: IO message buffer */ static void process_one_iomb(struct pm8001_hba_info *pm8001_ha, From patchwork Mon Feb 14 02:17: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: 542720 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 AE3AAC433EF for ; Mon, 14 Feb 2022 02:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239361AbiBNCUp (ORCPT ); Sun, 13 Feb 2022 21:20:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239335AbiBNCUJ (ORCPT ); Sun, 13 Feb 2022 21:20:09 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2872D54F9C for ; Sun, 13 Feb 2022 18:20:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805201; x=1676341201; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=G72px9zteVEyav9xzEEG21fzNpn0jSxqg6FF7e4Vh/0=; b=hPvfotPh3JEU/u0kfU/NE2e2+hwhiY3KWqYZObQ3ZLOf/eLoEATVBd0X iz3cAlr8UGjy4uNsMYK8q/mo4bEHOhrydhXifhUfZlQsdNLg2EnzTVIJn xys4/9dptuUgofLmBNY3moDndUQhqAmeXkWJuWR+A1F0yCBbPJ63DiM7E A6S/QgpTYDxE1Zx+VpV6covxEhGOkaiUBqoyBkht1wZ8KcHjRzS3KBZAp 9SlZa24icBETSfpEQMIB7JuIiDvrYdQpsdMX5PWtq7LNKIGHRfxdxEZMU gX5/xF2F8Q34rJjIaOXzWIO7iAPRy/0S2iYyDV5+iXPreV12F1WIx3AAq w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819818" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:20:01 +0800 IronPort-SDR: q4jpOBZZKkFsk4YnIKC5GOLVfs1JSO7Tpefz/X+9bKJOXoJ+EZhuR2/Ip233hDsF5VZhffQvyo 5+NAckfYlrXpptR5QUaY1IVeBw13e2MPHD657PZFnBy/pY1Z6ydWV7pvnX3VgbJQaSvap64ZbS h2gm7l1v0wzGNP2l9Q89AzWPhN/5K699/N0qGHK5IwG/aXLpPUhILX6vqqmxuTVF++dAQC/Pmo 5YV3A7B/PNktjaedFaCKZ3gl/jXkqCRDK388ciBS4/TvJeBr30MsZyUNR4/gMTgsn2LTKBeDwG ZcEPwtdG+VfCqj0UHqQtQO9A Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:54 -0800 IronPort-SDR: 7K0mQDzqWMJfroTqcn3+bL2JqI1DaxRGd6F7f/IepQjZ7pWc1sWZBm7uxLoyNuRzqx6ImvcHFE VI0c9omzTMT34j8XeecemM9fZSgdaIL4HAE1C5wqkYVXvCoXIni5fz5NsfFsSWpy7QcEWfGKKs tPQ/IZlPccTen9RtA/SubPGf2RjkWP3MBwxQ9tdGWk+ZcCmQtO8L+xJdPeSCpnq05jwXUC2s6z hy6MMzL+7iE+94H1IYh+Gc+c3mYfgc3ELGCeUrNgWUG57barx+yCXQftySxKEtXjCe1sklzk+i /9c= 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; 13 Feb 2022 18:20: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 4JxnxG51Qlz1SVp5 for ; Sun, 13 Feb 2022 18:20: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=1644805202; x=1647397203; bh=G72px9zteVEyav9xzE EG21fzNpn0jSxqg6FF7e4Vh/0=; b=CxOcdHUfFZnHQmFA2muZZ09m4qvY1ltsTp TMnQuDLvf0r+3svcERZJHmQhSy4lQ3RbthxrEWYOJ8fjzN+FCvzCnt/6ZlbCmgls 7GadkiKJE+cmkZKSY/FKMG3Hy9CIxHE/FnRUNwNKGV/APqwjW9uJ7sMpkMYoaPAn oHUxp7CtWS/QUT6sKgb2moLuOnT2AFL4CvvIEt1UZzIak+jtnUvjrKxzdXvaDLe2 No6BJra0Ly0erfw6HN+P9xUD3M9rBncIAtzOJUaRRLNAItXOWmMlIT+UH7INDn/W b+qYHqZjLjPeZ6p2yctXmuS2iFzS6+C7cFJax8D00jDEnZLw+7oQ== 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 6Y2QTFpuYmsK for ; Sun, 13 Feb 2022 18:20:02 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4JxnxF2LTdz1Rwrw; Sun, 13 Feb 2022 18:20:01 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 25/31] scsi: libsas: Simplify sas_ata_qc_issue() detection of NCQ commands Date: Mon, 14 Feb 2022 11:17:41 +0900 Message-Id: <20220214021747.4976-26-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect if a command is NCQ, there is no need to test all possible NCQ command codes. Instead, use ata_is_ncq() to test the command protocol. Signed-off-by: Damien Le Moal --- drivers/scsi/libsas/sas_ata.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 50f779088b6e..fcfc8fd4b14f 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -181,14 +181,9 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) task->task_proto = SAS_PROTOCOL_STP; task->task_done = sas_ata_task_done; - if (qc->tf.command == ATA_CMD_FPDMA_WRITE || - qc->tf.command == ATA_CMD_FPDMA_READ || - qc->tf.command == ATA_CMD_FPDMA_RECV || - qc->tf.command == ATA_CMD_FPDMA_SEND || - qc->tf.command == ATA_CMD_NCQ_NON_DATA) { - /* Need to zero out the tag libata assigned us */ + /* For NCQ commands, zero out the tag libata assigned us */ + if (ata_is_ncq(qc->tf.protocol)) qc->tf.nsect = 0; - } ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, (u8 *)&task->ata_task.fis); task->uldd_task = qc; From patchwork Mon Feb 14 02:17: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: 542967 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 F20AEC433FE for ; Mon, 14 Feb 2022 02:20:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239357AbiBNCUo (ORCPT ); Sun, 13 Feb 2022 21:20:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239339AbiBNCUL (ORCPT ); Sun, 13 Feb 2022 21:20:11 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3080854FBF for ; Sun, 13 Feb 2022 18:20: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=1644805202; x=1676341202; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=iRh5CGn4AxAnjVSvzjlfGKllQH5klDLzFx5AieHDi/U=; b=Kqj77OGQjOlpEq9riM/8WLJgjlDdt3kuXrKJhTMi69ra8V6uRiMSpA2n Kcpzi9MTir8mhu2XMiu/t9A2U0rGEIl0FnOfIHPPylIvUHm4sGEDPp0rG uuvT2mOhjlReguvcuscb0SI0AsHkI+fZN6qrbDfnAwQyMCjlyHirQ1tsP Tq6dbCb4KjDqOE0WE+4q+LIKn0BJadVwV1iBN4ue4anr1hinUUdGBWCxQ nVu0c9MfPo5svz6Dsd6nG5gwDqa9fYY34+nT+HD8otMff40rIXyQhGRq3 gbNxWgx+fHHsLSh4WoFFQHE05GSk+gj55qVNxvqd22I/d4EonEKhPp2IY g==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819821" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:20:02 +0800 IronPort-SDR: MjhJyQza39Q8EppzBW7AtBLPbAoovpaor/RwxjjvNA0JXgtFV0BHOrFQ+sxIKjullrSXqm5ld7 Belxb16+y3jVEa5IbdQ0T92IclTuC7WQC2UcH3XWE/GN3/6GXf6fGnQOb9wHIhcykZz0b6MVfk 3EPDN6LjbIm494JZKmK4daEvprR3XQSp0BoynGDEyGDRSfJf4II/haTJTiRerU9IuudmZ9iXlB CmZ15zu3XLbmU6Z18EjEuBYH4cZHyG0XjllhGkLv3WstiVtf7xsPkZAIIStVHAXJNkyp7TaA5k 1fSc9jeuuxcRd+Xw4t5TlG+d Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:55 -0800 IronPort-SDR: CsnaXVFhnIIK114zvhtgLUPAi1q00xeT5gsoXv7dRNrDFR+CDX80dol1AguI6Za0Kb2lGjMmXm wZRPa2PrbG+8rScIwNDih8ueofbQApXYRegGwuMdf62rdwJBrBJxHTp9SKMooCj0sA7f87s7kO v5//FPMKUxSQBiJ/Fhf0F35mOSEAHytD5zUssZAmbHuEFzMQZn5Oafefgd7b1Pcc/SglMu8ZXS nYduojXEd7hUXLJJpZ2WR9sCfH0FOBhhXazT5vzg4KJZcAsP9Etd3kVhV40ufjKkK+cftKd62c FY4= 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; 13 Feb 2022 18:20: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 4JxnxH5ml0z1SVp2 for ; Sun, 13 Feb 2022 18:20: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=1644805203; x=1647397204; bh=iRh5CGn4AxAnjVSvzj lfGKllQH5klDLzFx5AieHDi/U=; b=Wh88EpKHJpG60smkFG/zgz1EyJim+QxoiL 50NJckVLyzCAZeXOuf8oSQmaSx5OFoa/OORDFmAgbDy0rkl0HggG/oJzvhx9UBmB MvDX9giOTftfa+Ce3TeqomFekpYg5P2+lZH+BYAYDxQhocGaHwgckQ3EBwJiVmju QaUpuX9mgeh0VJDC3XPtHCU7wi24vvgC1VQYeQg26IdzRhOGsMKSircwo8fPI+Di bjeoCb0c7TrbVhnb559A/KtC7ixa/uy4Fk/pjOzmk+tQQCpOkbZXd9TxPM5wri/m mrOAwgINEn1JmAgOh7l4BbStWW4efYNVEgnIzNgnRuUCPXM4rFTA== 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 qGSQFcsEXdpr for ; Sun, 13 Feb 2022 18:20: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 4JxnxG3j0Hz1SHwl; Sun, 13 Feb 2022 18:20:02 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 26/31] scsi: pm8001: Simplify pm8001_get_ncq_tag() Date: Mon, 14 Feb 2022 11:17:42 +0900 Message-Id: <20220214021747.4976-27-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 1e7031400294..cbcb56b56a2f 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 Mon Feb 14 02:17: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: 542721 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 44938C433EF for ; Mon, 14 Feb 2022 02:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239306AbiBNCUm (ORCPT ); Sun, 13 Feb 2022 21:20:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239341AbiBNCUM (ORCPT ); Sun, 13 Feb 2022 21:20:12 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A258F55489 for ; Sun, 13 Feb 2022 18:20: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=1644805204; x=1676341204; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=pb3Ko9QU691TbENd5ll2DCHRdG0rUb90DZqsx6AsgzE=; b=WWLhjTcNj+hf0oXRs7kMlD0lEsrDjNRNvFMhPFYX0/u2qK9IJhU8deb1 jDZqM/5fYGOpl4AWmzJN9DknZlzymu5XK0FuHCWl6Dn7YerxjyLI1svEo c1dtFW1xcl0TH9sze7uw5okjN5iBOTiaGSd451gGX26fkeXO06vkTnBgm yxqIlWrvYBRwMvCsglINMoNW94MyhGwz0VUhVeMPDARIAF1ofHz94sPPL oj5+m1Vvb52vBSv/P5sgxAQcs62l3YB4dycKqFGHnckzufY0eTRaX0sIu OdWLQAZ8dUW6Iv+MdlI+wXDpj8NuXcTO5z0sDdACq2obobrfajFAB6Y6K g==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819825" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:20:04 +0800 IronPort-SDR: nK/nlQdorh4pEc5ODmKRQEgfY7h7zEC8UW0F0N1R14Leb+cE2UA435WVNyZoqZiK2lb4TmJ/Cm Klxnu/2aDAYNYa+Y2SHioR/mTp2vNuISUduBAyNBNRAEdiB4TlZRUauHLQNe49diAKGFzzmg1n F/riOUWFyXEhBuqx+3gV5Je1qAZPt34HLvMr0swopn6SuWyAeSBtpi25hQA+ukQJ33vHTS/p2Q PHK21VlBYemDrGk2CmlrLDdA2ahhtBZkafi8qOq+mGM3kwBatqH3dq0WUG+xQsxhu/5nUJ3DBk Ni9H3KYzIbpy7O73Gqqn4NzW Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:56 -0800 IronPort-SDR: YH/5cGqRLZ0B9pkS1p4mlZ+HVVjOmo3OuVRhEB6EvqvPiBSqy4lpfAAMjTl9EgabFpMd/tGPoO 19yHqAplxdyteQM7QWu9/+cYSfpoThu+EYtGavagKqBiKSO+4ICBnNyaPxaf+vnxLBsAvKDQTD wmvGGhLAawObFpt0Dekpc95jWD6U+PImjZV7YY0e8kloYof0u4aaR6QDd3osU1V38cinrXw0D8 tLPRsF5/cY/QSWgsePxOze4mP+9DM2p0NShRcdQ2WwuGV9pKUL3T7vpCXO8UYjA55eWV7aXf/z 4ww= 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; 13 Feb 2022 18:20: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 4JxnxK1QcSz1SVp3 for ; Sun, 13 Feb 2022 18:20: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=1644805204; x=1647397205; bh=pb3Ko9QU691TbENd5l l2DCHRdG0rUb90DZqsx6AsgzE=; b=uwr9Q7TwBBtSYn65k0OLKSWTPqVp6XYnQ2 g71fCt0k8RKKCh0nJHa9XgsiHQPW2gjoluvKzV4Loo3cNJXzU4lnDdFZZVYMGSHC TDkI+D3tuAtQeaLWPV0xbmjX4Ajmz/aZee3r6EU3fZFiMXF9joK95b/xiAqmc6yU LQdb4/C6+hTH5KotyZ0NQuPalooQU+hZicRQ0NmCQGkVoJVIXSbGy278NPk/2ZE+ 8/YN6Xeo4XuBSZ5v+7fddhD2PWJjj/liO7MOnvEvuTKvDAhZApfvj5hmZQuSI8u8 lsHGYAIAhehYi9qTirTynSv0kcgUFEaWH37a+OU4GmII/CE5qLiA== 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 VvbS02cXfSyz for ; Sun, 13 Feb 2022 18:20: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 4JxnxH4tVnz1Rwrw; Sun, 13 Feb 2022 18:20:03 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 27/31] scsi: pm8001: Cleanup pm8001_queue_command() Date: Mon, 14 Feb 2022 11:17:43 +0900 Message-Id: <20220214021747.4976-28-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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. Reviewed-by: John Garry Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_sas.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index cbcb56b56a2f..d08cbf3ef879 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -381,54 +381,53 @@ static int pm8001_task_exec(struct sas_task *task, struct pm8001_device *pm8001_dev; struct pm8001_port *port = NULL; struct sas_task *t = task; + struct task_status_struct *ts = &t->task_status; struct pm8001_ccb_info *ccb; u32 tag = 0xdeadbeef, rc = 0, n_elem = 0; unsigned long flags = 0; enum sas_protocol task_proto = t->task_proto; 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); 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; - ts->resp = SAS_TASK_UNDELIVERED; t->task_done(t); 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) { + ts->resp = SAS_TASK_UNDELIVERED; + ts->stat = SAS_PHY_DOWN; 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; } + continue; } + rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) goto err_out; + ccb = &pm8001_ha->ccb_info[tag]; if (!sas_protocol_ata(task_proto)) { From patchwork Mon Feb 14 02:17: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: 542719 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 C4025C433FE for ; Mon, 14 Feb 2022 02:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235646AbiBNCUs (ORCPT ); Sun, 13 Feb 2022 21:20:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239346AbiBNCUQ (ORCPT ); Sun, 13 Feb 2022 21:20:16 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D191255495 for ; Sun, 13 Feb 2022 18:20: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=1644805207; x=1676341207; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=t9qPCaa20T6CIEHiLBSdWbFKExv42WWUehPIp8FvbDk=; b=ULDkHnLaalw4+YQur/dMz7KjFpAmcWM8bjIYxvfCPfTXCRPz+Xfy4E+R uw+1Osoro+xMaRHgrIl/myzIuZygXotmyv4OtmXWeWkaqhRxna4ll39uo ji3K1kTBsQcZ9qxGf5k0zvMPgDVNZGo8I2qE5NBFCgIAxkhwLrV5xN++h dHXxaAcQKtZGy6FehCv7rlCELa3kPeCIktGuN2bkQc6mTfLyseXelGV1H 6qgEgMHHtsaxQ3EZDW7bgbwot8OhKlHEZKqIW9Nllh8xUwaYF+nT0829E c8LyLcT5IXoMSOV7t9E8HtiB9XZB+JwbKrAS6FJ+CYsLmoTPRXNqdHdSQ Q==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819835" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:20:07 +0800 IronPort-SDR: UNDZLD3sDq5m7AuVsJEo2800EoLJohvjxE7TFpWm+KF9K2RO191ltP6ShYnc8uvHkE/HWnQBdG YJ+WXAAyDcRD6N4ktvP5PuiHiVrEwCEnPEsJW/Iik8bsPIbLXsOigu+9SOzAuyvFv80hRETrzp qAJYSFP/nj75+02FPerkcHlyKg1uhkhvHXaUboUCAt+tSCqrnVy+5qLSi7KR9X+XNU0LWwzzlH mU7t/LYum9gKx35F0k4rKh/Ld/cY+N60NkKuWSQvFehFLZxe3nLIrgjor4YzTLBmEZI2atApRJ xKEf9QqjlHF+QLzIk7XTKe5n Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:52:59 -0800 IronPort-SDR: ekcuiDFWVjLxLpy9rHjpY5szqVqEeBd7DN3rm4InxwyEWnN/B4fDRV1HhVFDHiz8zAerR/yGUz 3O/SH186ggIHCFlDBINtxlIabl8Qp4CrYM6d84ZdnLHtqQloCcw0vS4NhvAX6lO/nqhmF68Si+ JvwS/L4I9D3BVW0YZBc9hP7wdm4LsC/6TifzUFfZC1HeFz5jvhlr7V6cHtz6hZwH41FHVWdNdM /1+3UwQlXnF5SOO5A7DJawso+2PEZN0VAZtAhNmCn4CUroK971kYsOJbESqXMAFlDcPDQZvcsC w+E= 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; 13 Feb 2022 18:20:08 -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 4JxnxM69Lsz1SVnx for ; Sun, 13 Feb 2022 18:20: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=1644805206; x=1647397207; bh=t9qPCaa20T6CIEHiLB SdWbFKExv42WWUehPIp8FvbDk=; b=k15E7B/Ja8Na2/qHWDDqiwXC+KXSSkH5Ea HTWbZlfIeO11LLVV8x0TBm8VMBMXGKFrO6aVMQn7JXGBCdVIyc3dhQjl2+WMcNOT EUcbHZT45CbQbhh1AFDx4B58GfD70eqvHJDJ/cktQqGssZkZbfp5Q6/sQBUIQCe1 AhCEpQEhbWm0ZrBJquqRoNq29xm7ApeBgIfOsqh8eZil2hkIPjrOdhJZkOCOZF3B 1YXf6RItEMqPk7NVtZTAhz2fMomwzRw34qDjsY3Gqy4MeH5CbdvIkPM132Yu5OtZ IJ6YUEStLhHDKxzBLVVcA3HkJnX2mEr+2hy9IIudD+yrd9oAo7nw== 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 LzkDYzzDYOq2 for ; Sun, 13 Feb 2022 18:20: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 4JxnxJ6jMMz1SHwl; Sun, 13 Feb 2022 18:20:04 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 28/31] scsi: pm8001: Introduce ccb alloc/free helpers Date: Mon, 14 Feb 2022 11:17:44 +0900 Message-Id: <20220214021747.4976-29-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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;A 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 --- 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, 165 insertions(+), 172 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 978b1bd60334..9018c7140d71 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); } } @@ -3055,12 +3040,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) @@ -3070,15 +3055,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 @@ -3103,9 +3087,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) { @@ -3149,9 +3131,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) @@ -3562,9 +3542,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; } @@ -3597,6 +3575,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: @@ -3634,9 +3613,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; } @@ -4429,7 +4406,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; @@ -4440,13 +4417,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 { @@ -4476,7 +4451,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; } @@ -4641,7 +4616,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; @@ -4656,15 +4630,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: { @@ -4725,7 +4699,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; } @@ -4736,7 +4710,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; @@ -4752,15 +4725,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; @@ -4810,7 +4783,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; } @@ -4856,7 +4829,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; @@ -4880,19 +4852,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; @@ -4984,26 +4956,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 @@ -5013,25 +4984,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 d08cbf3ef879..6c4aa04c9144 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; @@ -383,7 +383,7 @@ static int pm8001_task_exec(struct sas_task *task, struct sas_task *t = task; struct task_status_struct *ts = &t->task_status; 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; @@ -424,11 +424,11 @@ 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) { @@ -438,7 +438,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 { @@ -447,9 +447,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); @@ -478,15 +476,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)) @@ -557,10 +555,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); } /** @@ -806,7 +801,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; @@ -822,23 +816,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 e74cd02a5c08..5a65d4406c94 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); } } @@ -4847,7 +4833,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; @@ -4858,13 +4844,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 */ @@ -4901,7 +4885,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 Mon Feb 14 02:17: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: 542965 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 37CADC433EF for ; Mon, 14 Feb 2022 02:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239343AbiBNCUt (ORCPT ); Sun, 13 Feb 2022 21:20:49 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231336AbiBNCUS (ORCPT ); Sun, 13 Feb 2022 21:20:18 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B32715549F for ; Sun, 13 Feb 2022 18:20:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805209; x=1676341209; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=qwDTp6rN52yV/KIse7C9lh1flvowDd5YOIYkfLFbqdc=; b=BoWRFG+FihcrDpZ0htI5AJu7pfQKQwX4nhLF/AR6mkv+yJr3alxLJvm1 /kyBDSod3MLVigWuXyTuXzEtT+a7WWhVLNf34Dy/489Iwe1FQ14IJwCjo N0AzYNINu+CiC9Fsl0GHxGzyZtOuejel/iTquQZl1mrJzT7dTMLdTBSkd 46bDL7FIHK3wPkZiSZsg/kZAkN3Ks23GoH/5Xca96qxPlwvVbg//T+vhh YylK3ppwY1MU3lpPi1oPxR3gNm65yrSONB+YUANQHPnNEY7YFS3HW7pvJ MK27e7WxGbW/0QZ3ONoxuhoTF2hkLuu2Jc0d3/Oe/1rl/sddhMRCxTapm w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819839" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:20:09 +0800 IronPort-SDR: DYOYmdQln4EgNV8p45KHw9eGUm8mMQLEJZEIWAxLfnybQaCBXKdDdbMrZgvlbli0sIL7ZPOj9s e9mKT32V3nbSg0U8TUO2b2th50qLm1XntCs6pdo9YieZNTNsCMDMgyCCWxU/mnUgTGh1mmIuRr DFcqZ6LqHW95eztCI5KydT8lN+Idg82R3EsRUTmUhbOl4V78cxIs9GRZziMVrLoJ4NXONFK7jJ 4i5mBYqShV0oaHeciAMrzp+4/ROqjecbn8pN3awDxfMsiP+BARWYgw0pgu3B/uRdAUcs7oxmGJ MpzwxnM19MIj308BYpxTynDq Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:53:01 -0800 IronPort-SDR: o5fGVf9rr2cY6ewVMGijS6j43HSmS3GXoD0Li/0Gghwa3mHOLpj4FIiO+nmV8BzUkeC4Htcnbo XfX5eM7j6FAq+9WQfT+wJY8FwrAZj0xCO3hqDCI9zI+QTwWgk+Zs2nxsEmiLOHkEHexAGhO8ny XF5OyFJ0poRcqDMQhabH3uEtJJ8Ib3n9XUnRuzBXXHA7I2g1ENJsxYx3kadJaUzZjkRhHmp0v7 saQuK329ZrO+HXzplKbX6rybl6mk8UazOZrzcWRDjMcPxaGNQiN8q3rH7TAxb/bIzmw+71g15n VKQ= 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; 13 Feb 2022 18:20: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 4JxnxP5LnQz1SVnx for ; Sun, 13 Feb 2022 18:20: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=1644805207; x=1647397208; bh=qwDTp6rN52yV/KIse7 C9lh1flvowDd5YOIYkfLFbqdc=; b=KA8nqhBl0TB7bG4TyIpSmxF84Cn81wrKEI BYJ16hSVXOylyn2hTjnzy3+aHt/fWcrSifNq4w5Xli9hwm0MqukYxaouNK9aW0uQ mt/TAxATyp3XWIpAQAmwcAWIwk0wBrYs4wj67vZ1cw5bIWjwXxI/d+cfddKY4ROf HauhEq6qxRJkAxQlP7668xPDZFSNR+FMHd3Qg9PCtEHe6O2I7AN5g4VKcnaV3zHM /kWELGksi8eJBq/l2+8/Tc8n3YcIZmJmKVt2kG6Vvi4Pzs+rZGv0E1HDJk3XAVY9 zl0A8531nDomHiRUG/EzN1YHgIB1Y/UZ4eO1jHozl8ppgQ56PbGw== 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 M3oWylkTyJGx for ; Sun, 13 Feb 2022 18:20: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 4JxnxL21zRz1Rwrw; Sun, 13 Feb 2022 18:20:06 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 29/31] scsi: pm8001: Simplify pm8001_mpi_build_cmd() interface Date: Mon, 14 Feb 2022 11:17:45 +0900 Message-Id: <20220214021747.4976-30-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- 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 9018c7140d71..726421311543 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); @@ -3278,17 +3270,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, @@ -4120,7 +4109,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)); /* @@ -4146,7 +4134,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)); @@ -4157,8 +4144,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; @@ -4186,9 +4173,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); @@ -4204,7 +4189,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) { @@ -4225,9 +4209,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, @@ -4237,17 +4221,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*/ @@ -4333,9 +4315,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); } /** @@ -4347,11 +4328,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); /* @@ -4368,9 +4347,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); } /** @@ -4382,17 +4361,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); } /* @@ -4404,7 +4381,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; @@ -4414,7 +4390,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); @@ -4448,8 +4423,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); @@ -4464,18 +4440,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); } /** @@ -4488,17 +4461,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) @@ -4536,9 +4507,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; @@ -4550,9 +4519,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); } /* @@ -4592,9 +4561,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); @@ -4604,10 +4571,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, @@ -4617,7 +4583,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; @@ -4628,7 +4593,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); @@ -4695,8 +4659,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); @@ -4711,7 +4676,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; @@ -4720,7 +4684,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); @@ -4779,7 +4743,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); @@ -4800,12 +4765,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); @@ -4816,9 +4778,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 @@ -4953,7 +4915,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; @@ -4964,13 +4925,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); @@ -4981,7 +4941,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; @@ -4992,14 +4951,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 5a65d4406c94..c25d2c435f6a 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); @@ -3234,17 +3221,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, @@ -4211,7 +4196,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; @@ -4240,7 +4224,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; @@ -4308,8 +4291,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; @@ -4369,10 +4352,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; @@ -4396,7 +4377,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 && @@ -4513,9 +4493,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, @@ -4526,7 +4506,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; @@ -4534,13 +4513,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*/ @@ -4755,9 +4732,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); } /** @@ -4769,11 +4745,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); @@ -4795,9 +4769,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); } /** @@ -4809,17 +4783,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); } /* @@ -4831,7 +4803,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; @@ -4841,7 +4812,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); @@ -4882,7 +4852,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); @@ -4902,18 +4872,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); @@ -4959,7 +4929,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)); @@ -4969,7 +4938,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)); @@ -4980,8 +4948,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); } @@ -5005,7 +4973,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)); @@ -5015,7 +4982,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); @@ -5026,7 +4992,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 Mon Feb 14 02:17: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: 542966 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 DC634C433EF for ; Mon, 14 Feb 2022 02:20:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239334AbiBNCUq (ORCPT ); Sun, 13 Feb 2022 21:20:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239354AbiBNCUR (ORCPT ); Sun, 13 Feb 2022 21:20:17 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D8EF554AB for ; Sun, 13 Feb 2022 18:20: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=1644805209; x=1676341209; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=M+uhkGOTtdbTkw7P+LJeHPogOfLwgpAmXahG5AqeDIY=; b=LCzcy2Ep2gop6EIhssZgHLhK0AUFl+WcZsRWQ685KhDW05+cueXiFq1q x8IxkTlz1QHZ9Ol38LzXvEv5STwQv60WqEFGinyHv3eEdnyMHOg+FhlGW zOi/0/X2NeT5iuSw9eT/g0y3Pmxm6zsakmO7igKUKIJKky3B45dcx7x7c 3un85WdMC8lUw+YJQsJCF0cxOwqdQVgDnLamO+QbCu5vJ+jOVa4X20QxF 8EfX12Jad0T0r3QGXnnw1yHNA5GHNGYF5hYNC6Ps6HTkitcqLCgcZkWVO EoR0iiT/h1aqz6M2Ubo24ypt8hlPlrgQyZCKf8cq3CFf7uX8Xe+fTtsa2 w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819841" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:20:09 +0800 IronPort-SDR: V/rHF51vL3f5dmAxrjJC9ujdyQYf9rI0qw/ggygmS+9KbFv6MMyRF5LtXSv2heQDqc3qVA9FSF HGfkKC+TqPdFyr4aLbli3wFDD8Xn8p2kJuWt5BOHONKRpaFZuTT6mGHvkOyMW1HZlTZ+rmnW1p qPfMpxJTCCVuofKGLXUXpI8PcBK9QZcoqYUVbd/0RB9OX86TPBAnY7Kjq7KyAZfKoSsh/Wtz/n 0usV76UCo50pDCL3S0+PJsgIi+m/R4uI5xsWwCD5Ehcfsbmjoxn/EQpxC0Tdn1qedLEkvO06py 8KwplxUEP1w0wX521+7IEKlK Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:53:02 -0800 IronPort-SDR: rInl9mFtitOXIdj6ZURHu7ax+FBZi0U6GpPIgHKIvWCDt/KGgQoAD5pyJMSWTopM3VF1MXJwMN UHleSBFy35pP8r6RbFDldFZhbzNyZHYDMIkvTUj3/8GAgof7u3xDEsonjZaqHusdqgWb8zdqiT Z0fsuAz7RIXhGuootQO0T9sqoTdOIoe2JDK6Bn2Kl1ccJxhjn0C4fpB6J9FpjNHgk6aMX76Zby jPvRNkleto36YGRlQXBEpinQNcHens2ECxY+kAc4sXH2hrlhPJ0v+Nj9im/SzfF8zO7kJRH94u q1U= 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; 13 Feb 2022 18:20: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 4JxnxQ6H0Qz1Rwrw for ; Sun, 13 Feb 2022 18:20: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=1644805209; x=1647397210; bh=M+uhkGOTtdbTkw7P+L JeHPogOfLwgpAmXahG5AqeDIY=; b=jM6Gi1hwBjDRlMef5+rgCoQPf4cjlcDahe WEu7O2GOePAU5tZJPnTjKfb4uVCoa2AR/9itglnCDHQkP/hXjyqtaCrSgOGxbt1H YCDQjrBfjeZNJsIrItFISbA2u0ZhfzJMrO09Q3fs9l3RPss5dotx3lC221WVyHXN LVaYRgny5h6JWgHfWPV1u6DFu3NMI9qWgiqd2bADK88dWhlUVwaqms7ka2MdLSJN oCW3rPwsMZmwH5PRPddxSNLc3QKvwqStSf8Jlmq3x1fRpYrCMbJlCIXiIdn+Uwuw N/3wTJNg9RbHGfvYI9w+EjkkutCr0Z+VnXge/FKBn//KVaGQIoBQ== 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 ZRIm3_lGa3jv for ; Sun, 13 Feb 2022 18:20:09 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4JxnxN0ZW0z1SVp5; Sun, 13 Feb 2022 18:20:07 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 30/31] scsi: pm8001: Simplify pm8001_task_exec() Date: Mon, 14 Feb 2022 11:17:46 +0900 Message-Id: <20220214021747.4976-31-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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. Also, the unnecessary local variable t is removed. Additionnally, 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 --- drivers/scsi/pm8001/pm8001_sas.c | 160 ++++++++++++++----------------- 1 file changed, 73 insertions(+), 87 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 6c4aa04c9144..980afde2a0ab 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -373,32 +373,32 @@ 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 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 task_status_struct *ts = &t->task_status; + struct task_status_struct *ts = &task->task_status; + enum sas_protocol task_proto = task->task_proto; 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) { 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); + 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; } @@ -406,92 +406,78 @@ static int pm8001_task_exec(struct sas_task *task, 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)]; + pm8001_dev = dev->lldd_dev; + port = &pm8001_ha->port[sas_find_local_port_id(dev)]; - 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); - t->task_done(t); - spin_lock_irqsave(&pm8001_ha->lock, flags); - } else { - t->task_done(t); - } - continue; + 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); } + goto unlock; + } - ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, t); - if (!ccb) { - rc = -SAS_QUEUE_FULL; - goto err_out; - } + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, task); + if (!ccb) { + rc = -SAS_QUEUE_FULL; + goto unlock; + } - 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; - } + 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 ccb_free; } - } 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; + } -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)) - if (n_elem) - dma_unmap_sg(pm8001_ha->dev, t->scatter, t->num_scatter, - t->data_dir); -out_done: + 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); +ccb_free: + pm8001_ccb_free(pm8001_ha, ccb); + dev_err(pm8001_ha->dev, "pm8001 exec failed[%d]!\n", rc); + } + +unlock: spin_unlock_irqrestore(&pm8001_ha->lock, flags); return rc; } From patchwork Mon Feb 14 02:17: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: 542718 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 23DF0C4332F for ; Mon, 14 Feb 2022 02:20:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239346AbiBNCUv (ORCPT ); Sun, 13 Feb 2022 21:20:51 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235569AbiBNCUU (ORCPT ); Sun, 13 Feb 2022 21:20:20 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 361D755BC7 for ; Sun, 13 Feb 2022 18:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644805212; x=1676341212; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=ZZNXcE6N18y2HX8pZrWvNEXQPDGP7fWL/LzC29vZopo=; b=g/EjXGtvVanGaaVfTYk8kIlXPblW5NrIGNhgO1YN2pO/eEEqL2uKTZrY jBOxNz8A05om5lxzsRPKX1B51dEx9CxZ1W4n4cl+pNOt5Onh3CA3iOKHb rs3vGkeIO0mc13CZhIWTzd4OdKAW0zfCwseOMomBDawvQGZO4ICWOzG8L Eu8mikuo8OI92Ld65SMWU9qMbMVAJTv3/ui+J1KrQGnAw05LRnzt2bUbZ 5OA/TkFilFEG8qzHDig41P5uVkuKLPQ27Pk4eSj6qZ/veyZ3XSqOHpuxJ 2ouLidsbk0zjjtjskYXIMna0d1aTUECxkcsTFYYgmUQuB3cOEau2A3h4G w==; X-IronPort-AV: E=Sophos;i="5.88,366,1635177600"; d="scan'208";a="192819845" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2022 10:20:12 +0800 IronPort-SDR: SFKmyMUW9PHrvcd09nNijGLYSL9DQ1VODt1G61Teczgp10wLoPMukvW4TaEWCwMhjZYIdiEURv flPlpdsiWBAx4KHdTf6oWIAM2U1DKuDCp/zONnC337lhZmn593+GaJq2lpp7zX9Mz3OXpqltYp hTSL7/DZDjEM0rmddNguOkAnbnBu9NPtZA4jQPbX7+ZTprlVul43rnJGcDUfahI0NLq7V5JUV5 lZxCRJLkiv4qGzM51QyeXpW6kJeFTQ/JKMl4G+yCbWu2JVHxCftcCZ3Ou0nEkVVUpDTyLgLpB/ /b/BvKLdzp7rJjR26oYuVGK7 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 17:53:04 -0800 IronPort-SDR: RcvH5BTeY63zPAzw7xAKBu9pqgN3nQgAAqTrYnjm3jEZyCGcoZU14qDW2knAh3sKUsphgHlWMG E5kr1jP+pCLP3MLuFtvWMcLVc2EVFpcX4/n9zRALGE29WTjNr82J6uA/FnT0sHyR2tFuaxHWkU k9mhUus10F5ELFYj7oaH9NXV3JVxj7Xz78+tK6ij0WF8hqOylRwQcFE15FBaIdgkGcIIqPPwIk cxYI0LeM7YRCapdNCYdexQ/dACQgB1PR3Vk8APz7oomaXO6HXeSc90AaxI2P5wVs+bxMnZJlBH ojA= 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; 13 Feb 2022 18:20: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 4JxnxS5DM7z1SVp0 for ; Sun, 13 Feb 2022 18:20: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=1644805211; x=1647397212; bh=ZZNXcE6N18y2HX8pZr WvNEXQPDGP7fWL/LzC29vZopo=; b=kv6A7eDhkIig3f0YDVXf5gwbpRoXlpk0hk u+2q56YlOJjyr9QiroOmgu3W74JquvulghWTK4YQjz7cKOYsaI1x0eO2CkqQT56f bEi5eYf7fyywJl5CnYXNHO33mydMIglIZmOKSKN6AfAT6HNR7/HKusLa7I2X97ht Kj2oreaXsY2JQvBBazQyxzUphL5MVHp9x2olzmF7k8B9z1PfA+x7sVaWe/M66F7M qpCvmoDs11YMBFuEai1Ki5QcRX6IXPmfX95X3HQDv0yMaJP/MgtP+u6Bbu4IqQsm vIaTnWMkwBXRk+RuxLa0IFGW+3wq5fJUds1FmWUTQFIvnu12gXOA== 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 l9mditbLCiZh for ; Sun, 13 Feb 2022 18:20: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 4JxnxQ0h3wz1SVp2; Sun, 13 Feb 2022 18:20:09 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v3 31/31] scsi: pm8001: Simplify pm8001_ccb_task_free() Date: Mon, 14 Feb 2022 11:17:47 +0900 Message-Id: <20220214021747.4976-32-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214021747.4976-1-damien.lemoal@opensource.wdc.com> References: <20220214021747.4976-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 --- drivers/scsi/pm8001/pm8001_hwi.c | 48 +++++++++++++++----------------- drivers/scsi/pm8001/pm8001_sas.c | 25 ++++++++--------- drivers/scsi/pm8001/pm8001_sas.h | 12 ++++---- drivers/scsi/pm8001/pm80xx_hwi.c | 41 ++++++++++++--------------- 4 files changed, 58 insertions(+), 68 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 726421311543..d70a38c17544 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); } } @@ -2734,7 +2733,7 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); ts->resp = SAS_TASK_COMPLETE; 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; @@ -2828,10 +2827,10 @@ static void mpi_sata_event(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, 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_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); } } @@ -3011,12 +3010,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); } } @@ -3666,7 +3663,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) { @@ -4304,12 +4301,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 980afde2a0ab..ddcd96e0fd95 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -496,22 +496,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: @@ -530,12 +529,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); } @@ -952,11 +951,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 c25d2c435f6a..9550c586ff66 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -2159,12 +2159,10 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) t, status, ts->resp, ts->stat); if (t->slow_task) complete(&t->slow_task->completion); - 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); } } @@ -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; @@ -2762,12 +2758,12 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, t, status, ts->resp, ts->stat); if (t->slow_task) complete(&t->slow_task->completion); - 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); 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); } @@ -2872,7 +2868,7 @@ static void mpi_sata_event(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; @@ -2982,12 +2978,12 @@ static void mpi_sata_event(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, 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); 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); } @@ -3196,10 +3192,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); } @@ -4715,13 +4711,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; }