From patchwork Sun Feb 20 03: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: 12752512 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 AEF2DC433EF for ; Sun, 20 Feb 2022 03:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233678AbiBTDSi (ORCPT ); Sat, 19 Feb 2022 22:18:38 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbiBTDSh (ORCPT ); Sat, 19 Feb 2022 22:18:37 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93E00340D0 for ; Sat, 19 Feb 2022 19:18:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327096; x=1676863096; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=irf9kVvrFWPtjmT/Y9qUzAV7O6VBkyqkzMJlMmbKmPE=; b=aEfiobw9TdIax0+2hDE6ZW9NfjbKEejod+svgc9G/QTBdzpcLP9u3gmb h65PgHFynVKEWDTo+I9FViDeJO8sMtoBgKddAAkRv9W4nRum3MxBTwSME sto7Sh9OKrSxHG+A4MNmygRc+loVK5CG7r9vn7doadHlTWwcWFKmBbPCP UTlePfRC/zxnx2b6rqX2nSOq+mksovmXz62QVww/7OSDXyBJs5hn/4Y9n hFH0W6BvwsMUhGogl0QKZ26iaddputWiLAZATtyEAJ7epV3kPbaX+L2gp FB+PWQI4McktRY6oawO42sQMafHqSJwBP0jZe9vBkswAvc0/nkQcdYcId w==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405725" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:15 +0800 IronPort-SDR: F/btDo+TbyQDDgbPAYjWWDSKhuPRH/GwBRikX1r9cNI2idXO7v7OyY1yg+4LapEu933P9FYEG7 2JRVDrCzA6O34LcOOIt6mWIQdr3RcRfK8a9uxx5q9I8ahaHbTEy4ZdIS4b5XhpQJtXFYSgQApG ocTpv+hYbp/YTgkAMN//rqV/Vmocn2dqIjmfzTVttmgDMbl22gqDxFVixM6VyB9ldueMOW5HB/ C4EkQBKsfYD0wYataNFwLb6AjN8ahT5uk/8X6JUJZJdrCf11ND0kIAIqW0AKAuu2CsI5CHIPN9 TefSIxfuJGRjpynjpU/JLdn9 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:49:52 -0800 IronPort-SDR: iyI298WQ7I2R3+HG9NXZDnV9R4oPAIb7KHIhZvxrb+QAP5brcZo/fj9jaYQdzpxzuWoLR6NnL/ hgO946kMR2snWvfrQ+hw910CAeKQ0sA7bgCzVoe4sWGR0TKIlnEDuCfkDeGSwbx/7sWY73dEG3 EeW7F8vId+/Av8jUI+hH5WdpMYR/aTDbinSOc83BhHDfFAsafG1gR9+eTygqErhSE9w8wMXrXo ci2DtgPFBp6IqnQZm2eelLNf4JhzHeNWr/Z9+NKSqpXdnc4LTWz46KqPn6AVXi/j37RgORUPel ixE= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:17 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1Vxh3LNbz1SVp2 for ; Sat, 19 Feb 2022 19:18:16 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327095; x=1647919096; bh=irf9kVvrFWPtjmT/Y9 qUzAV7O6VBkyqkzMJlMmbKmPE=; b=m2vIjEBPF3FkORVB8AEOEwpba++eOSJ6wA oLcKVK3oRku70ApKxB14Sat1bhO914xmesthHh3Eiy4eP5unjtvnkrmd72Me89Cy 3tSTNy2GlQ4UYOSEfzA/+KVHAc+fvsH2HYlIgV9Y/iv2Rgb4BMh8NyANIN/Ha5TH uRw+CfVPwkjt51RshPgHYcSUp8NXdgT5egbWE+r3Xe+uMSISzPuedR5YqzW3yEiJ YgeLQiVdoZ16Wa2qfIK0J3A8rG5KYvrjXdzx93xpWHMp2YCIIfLlGSHLvNfb/Coy 0M5yaLfMB2Em0pY8yyIqAckzGz2MY385BoBB8sLay9v8Y8mwoCMA== 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 UHq8a9yHV0AN for ; Sat, 19 Feb 2022 19:18:15 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxf5p0Sz1Rwrw; Sat, 19 Feb 2022 19:18:14 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 01/31] scsi: libsas: Fix sas_ata_qc_issue() handling of NCQ NON DATA commands Date: Sun, 20 Feb 2022 12:17:40 +0900 Message-Id: <20220220031810.738362-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect for the DMA_NONE (no data transfer) DMA direction, sas_ata_qc_issue() tests if the command protocol is ATA_PROT_NODATA. This test does not include the ATA_CMD_NCQ_NON_DATA command as this command protocol is defined as ATA_PROT_NCQ_NODATA (equal to ATA_PROT_FLAG_NCQ) and not as ATA_PROT_NODATA. To include both NCQ and non-NCQ commands when testing for the DMA_NONE DMA direction, use "!ata_is_data()". Fixes: 176ddd89171d ("scsi: libsas: Reset num_scatter if libata marks qc as NODATA") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/libsas/sas_ata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index d89ffb357f14..dd4ae5e8cb5c 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -195,7 +195,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 Sun Feb 20 03: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: 12752513 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 AF241C433EF for ; Sun, 20 Feb 2022 03:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237502AbiBTDSo (ORCPT ); Sat, 19 Feb 2022 22:18:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233561AbiBTDSi (ORCPT ); Sat, 19 Feb 2022 22:18:38 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60F20340CD for ; Sat, 19 Feb 2022 19:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327096; x=1676863096; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J0/LlqQwzsrgpyn1bhRFQWdRsj7/wpmjTh1sBqjyc6Q=; b=ZD/+oyWOgp4/7C1dqgyaB1aMLPRfIt1/PnP7+Cv6biYdlznIKBZ5coz0 /Z34pzMUqradNKyA3mHAsKaFHcmrQZuim0b9EU5fraS0PMMdiDS3WhqHF OkNNGI2Nc5SUKi9QMCrEHCTQ3ONnSvfGeuS0MZhYw+UliCdcH5p4u+GKO FCY0j+kqPrsRT0bFyCh0nqJbpu0imttNNG6+YiKodjRtMmVbmhpmqIQVX bJsD9nuDtXQYMuJmk9Q508H2BwjU/M8vSrxlBsfsE61otyiS+gvmxpPq8 zehXbD219pLDqCTAvkJYCRScEv2rsXqS6qqdXl8q0WI9nhtnPBturZpOf Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405729" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:16 +0800 IronPort-SDR: m1LWwyIFH/RpYE+nuxrN4IeQP0dHQ+uXXZM2QD7S76jQGyET05tQLdJuJgrRzPe31IwZAJriCn 0fa3Z4nEDjKR0+02UDYUQmJcDDcqc4c53lkZxh9leBPGhW2nRo5qp5hMwxJLTEJep/cyMCuOu4 jFFt+gjGsGL4Q1+o7ty3EP6vLO1YfwJuv22rrSpZ5EMBA0hdi4zcJhNk/otKvElEf2enebaSpX bNlPQx7Mng8o+oPL0LoiNxc2PHSvk1oN10l45S7lkf9wQMGEwO7LSYC3DcuqC5ymsRVc2L28hn 7yavuvombLEpU51x7Zz3GS2z Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:49:53 -0800 IronPort-SDR: KZFD2ajYtrAzwOkoeUtpW9F4HZfo11ZtI1dzaETUeE4MYfbXCNimhTio7d5sCKegnFbT4MIdZN TPqi4hg5hfUtjbz75gV5RubNjUK1SHZO2xbG7R5IHIrLcH7edipeBQEiPQV9Z0R7aR1TVl3UyG IsdL69KxYiWoKMCTDz9VKv3bx4noGoW4DoBhZr/WvdfxyHs4XbffHKiKMUNdrVDVsxGxlB4qsw X1waRWofay1adcjU/beyV1sPONQK0KKBs+rv3XimFT8jW0Bv/mS5QmXRV4iY0x9aG38ricdSAO DR4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:18 -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 4K1Vxj5yZGz1SVp2 for ; Sat, 19 Feb 2022 19:18:17 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327097; x=1647919098; bh=J0/LlqQwzsrgpyn1bh RFQWdRsj7/wpmjTh1sBqjyc6Q=; b=ekkEtmjtdmQ0nEe7I5I7htsR52erUBzLsx u7KwKSg6QuttIOFsTMppvE1QSq3do0rRVVoDkrcFqzex/UF+1WUZVTKIgisAHoGp pedq6pWBHpuH2wLCjSnbcuzSIaRr3OhUAu9zv4xF1nBR1h4nljLc3eNBrlvwjFb+ uYRNtZcRr0c4gtgx1I3UYOXadBTaYoeWc4cimi+iSFvHI6lPqN/nk1s5UewPafb9 gnhFT3Y+jNrgKpST4V8ZCCjYZmEJpvjpoxL19iFW2YTOO7uAV2fpDfIXMbEvaWoS ehrtvyJ5bF3iJuPssN7NHXUyn0spIaOKDYGWS4fd+jzklNSbugsg== 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 JASuRskJLZMz for ; Sat, 19 Feb 2022 19:18:17 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxh1pq7z1Rvlx; Sat, 19 Feb 2022 19:18:16 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 02/31] scsi: pm8001: Fix __iomem pointer use in pm8001_phy_control() Date: Sun, 20 Feb 2022 12:17:41 +0900 Message-Id: <20220220031810.738362-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Avoid the sparse warning "warning: cast removes address space '__iomem' of expression" by declaring the qp pointer as "u32 __iomem *". Accordingly, change the accesses to the qp array to use readl(). Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_sas.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 828d719afa1b..f5678be4c17b 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 Sun Feb 20 03: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: 12752514 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 0C06FC433EF for ; Sun, 20 Feb 2022 03:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237745AbiBTDSp (ORCPT ); Sat, 19 Feb 2022 22:18:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbiBTDSj (ORCPT ); Sat, 19 Feb 2022 22:18:39 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92E2B340D0 for ; Sat, 19 Feb 2022 19:18:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327098; x=1676863098; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qwEC/HAHMVugj2YgjUkTAgDhC0DdmBvV/+2YVPjh/G0=; b=R8HLHpToLq0Jqugn2CmmpoBf/tXC2wOonsvRNuQz31Adidrn/2PIvqiw kakzQrHz63Sxe7z8xTvocm8Ab920ad0MUMl3egbVT5b4rIuGk6TFhv4G2 4CmuYpZveblg81+sa08L7BwoJq7okxwnQCCbbSqLtPxuxVnvH62MHpRm3 peNNubcqSmZq3QVttTtpLbu1ywbHXSQX216I8F/XdrxAlxZ5yk/DPRtdC mb0/MCvWKqiUI5ZVD3Ghd6nzbPH7diphtn7ak8wx7pqKErvGELyvpF7t9 k/Ixki6xFTCyC+L40WQ9gwheKf1toJVKZQ4wI28qfwNF0uG5dRdkopcGc Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405731" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:18 +0800 IronPort-SDR: eiiCcTgx9/QX4gNobxRggcyslURUh7zrCdSpirpNRqN9+5aSIqnrORgGZ3lIXxJDLJG+Mx6bfW e/iYlS1OV96Z4HxgM/voyRHw/oHJZqlICjUfxKiiRNNQzL5Rpqsf0YbefA6AGEgr+qVjhekHt8 hWrpneodUX14MF1KvPB+IIRz0Q9BnJWOcvwMWnkqkCZ8vQTiButTeFs9TtMwMmBe1TH5ZU0/ql puNZ8Soap6CTuKMU4hJ9UASWXe1BI3a9bAPSvMfciiPxqt+5DwyVEanhqjLSgXy/lU5DTIwvfQ OLInnDsLzo6ayzqoVW1NmLfF Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:49:55 -0800 IronPort-SDR: Fr2NkmUPpUvF5QIrRgw6STsFB2bQy2U6WGUBT5JS0AkK5iFTnvrkC3LISv/VIUhR23snGa022x sV5QWKIfQOWcVAjw5qriHj+z1a2ns3hxhKUiRV7Hs38s9JVSZOWgPvXdHGDDO34NKCeGtBGCgo RlOe6F8gRAi/XHby54ZIHpDdnA27pSGecB1MBKJ1T5vxv5dB66wdGtnx05nRP5k8ObhGo31caS HxoryALT4OR7XBSl9TJvyjpZY4JUbVcV6mVeIgqm70WO2XS1FRlRqQqN6KMUi6wE5RLv19tbNr X48= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:19 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1Vxl11SBz1SVp0 for ; Sat, 19 Feb 2022 19:18:19 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327098; x=1647919099; bh=qwEC/HAHMVugj2YgjU kTAgDhC0DdmBvV/+2YVPjh/G0=; b=qlMVZxqfRim40AbedjGHMjmbm6lQKhk8Of fVnFb+tgswEx66VbQabVb9Mpxw2cj6p0ogKr4bmsfujyenMYJYQxE+oDaoFkVXJI 2UHrVtzJKeRKJjdmjS8bvwcSvh/pnSTTC0d9yCmZx6NucljdzEUgIBasQ/m1OVXN rqvAJ0DyE2srpXERoFwYN9//5h/WU8CO2bw7F42q9N9AacIIlWs0hPhItehpret4 vCDhICsSKCzV5wbYwhi1SC+XkcrbXfTMRbHHEDIOeLHJvg1RTx3oK85A93l45bpy vJQCwOAMArqVEF1eU/xAkare4SUd9maIHAPO/8pwLKXOIes766YQ== 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 CrrSn7ENbT6f for ; Sat, 19 Feb 2022 19:18:18 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxj4LvKz1Rwrw; Sat, 19 Feb 2022 19:18:17 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 03/31] scsi: pm8001: Fix pm8001_update_flash() local variable type Date: Sun, 20 Feb 2022 12:17:42 +0900 Message-Id: <20220220031810.738362-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Change the type of partitionSizeTmp from u32 to __be32 to suppress the sparse warning: warning: cast to restricted __be32 Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_ctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 66307783c73c..73f036bed128 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -721,7 +721,8 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) DECLARE_COMPLETION_ONSTACK(completion); u8 *ioctlbuffer; struct fw_control_info *fwControl; - u32 partitionSize, partitionSizeTmp; + __be32 partitionSizeTmp; + u32 partitionSize; u32 loopNumber, loopcount; struct pm8001_fw_image_header *image_hdr; u32 sizeRead = 0; @@ -742,7 +743,7 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data; while (sizeRead < pm8001_ha->fw_image->size) { partitionSizeTmp = - *(u32 *)((u8 *)&image_hdr->image_length + sizeRead); + *(__be32 *)((u8 *)&image_hdr->image_length + sizeRead); partitionSize = be32_to_cpu(partitionSizeTmp); loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN, IOCTL_BUF_SIZE); From patchwork Sun Feb 20 03: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: 12752516 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 0CC4EC433F5 for ; Sun, 20 Feb 2022 03:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238471AbiBTDSr (ORCPT ); Sat, 19 Feb 2022 22:18:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233859AbiBTDSl (ORCPT ); Sat, 19 Feb 2022 22:18:41 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BDA7340D1 for ; Sat, 19 Feb 2022 19:18:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327099; x=1676863099; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7ywyhY05CndcdCJ1fh6/B5S14WqsyWHdIQgte1owJ9Q=; b=c3T6CTdaZT0SMDZFgZn5hNhq5Yfw3XX2WenKH8393EIL2gXuL92enRls 2h8kbfrHLrnIGl1hwGa2Z8jcOxKJKiiUUr/Vaw8bTWIyQbzh90JtphOa7 KTrWaCYSggVdVjrjwKdq182yq+Y3diDJZDdPwcqlGLcK4LrAjv8L0fzcl fQ4vipmkOMliRxtNHIdRKvUKZQYjg90rek4FQpMm6ganiWxxsdBY4ACUI R0lXMxX0O9JceUBOtYqWBV+b2cKyVRFjJIVZqTMFbVXsdu9ktW7JXFaJ1 ugYpWlbZuCy/q1whQFaFikzL9BepJHQ7j3kD07A+js4t8imqpmE3+NgFv g==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405736" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:19 +0800 IronPort-SDR: d/EzlWCg8O6W+9hhgufckSmxK2BnJldVU0dGkYrZYyXjOeeqXzBBN8cyzAd0YnTJJGvwuQi+CV WYJY3Cm5ps3/C1bvtT/P1SrP05878TOTES0D7i8cQwsFFDxMpnS8ufBUShPPBQPcK+dHRRCfJ5 cEzpMmAcwYfdvCPTywLSNL0+m9r4SYwuSXFeme8zA7a2gUb9os1QRZictNlHia1pRsoE7PrAfo pmWTZescRfDnwcNO9wBiO3LOImQme9XHpymmw/w7kVcfbYdMnjVl32wNsMkPZCfuVZxl0yGUC6 ohGewE7hyZdCmJSjZh64gWoF Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:49:56 -0800 IronPort-SDR: 7wLvpCkUJC2BZKSQE6yykrxgiYqMg04pmECerH2wuExZYhkSSi8jnaJIuddNpP7bA5Q9pYd2QZ d4m/RI1Y2mS3L/eWQ6U2DttTe9yBYFp5r/O/Mkv9KLqCvnSsegNY40vDPcu00bB7evS6Z6QrcG IOtH7MgEZ6yXybPCuiqG4y2OmGESVM1FLMgqltrdVc6+leHUy6KxqKEPuB0oorUvXt9DEKhkqg HbwIZYA9HXLQlF0EjVzZJaGqUzOvccL5H/rXXceMnRPz3dNBEEpAPjFp1YReH+goCcPU2IZ0Zk s48= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:21 -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 4K1Vxm3mtkz1SVp1 for ; Sat, 19 Feb 2022 19:18:20 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327100; x=1647919101; bh=7ywyhY05CndcdCJ1fh 6/B5S14WqsyWHdIQgte1owJ9Q=; b=WIjVcczMEZ8nVXU2C9lf8nuHnpPFlVfoNO n54Iypk+M5XbfwuqaqFOHoOlSBMHhyKdbJFUvyOLxXLW7DhaoFwziTqReFKVRA// 5DmmWVZt+WDc+DLUlA0kqtH0ad/94V7PJEopbwa6jg7DN/Z9OJe+4V/YGo7ZkpoY jBX4n8SU1um2bWafCsmTuUaPZGgJpj8E/7hHESc5pS/bMqSiO4b1TNeqWT8J92/Y xe/LwaIA6fYGCi+dsbUmBBnkrKcQVf6JV6bpJ8gZIOTUO1pQ5lMOBAy3PYjUEaCX DA4zawLixQLCgg5fBKhADVLLV+gNcwPPN70zaNAF5vfwcePC1DOQ== 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 qaMzj-hUVEHS for ; Sat, 19 Feb 2022 19:18:20 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxk6pdGz1Rvlx; Sat, 19 Feb 2022 19:18:18 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 04/31] scsi: pm8001: Fix command initialization in pm80XX_send_read_log() Date: Sun, 20 Feb 2022 12:17:43 +0900 Message-Id: <20220220031810.738362-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Since the sata_cmd struct is zeroed out before its fields are initialized, there is no need for using "|=" to initialize the ncqtag_atap_dir_m field. Using a standard assignment removes the sparse warning: warning: invalid assignment: |= Also, since the ncqtag_atap_dir_m field has type __le32, use cpu_to_le32() to generate the assigned value. Fixes: c6b9ef5779c3 ("[SCSI] pm80xx: NCQ error handling changes") Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 2 +- drivers/scsi/pm8001/pm80xx_hwi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 575c6ecfdce3..dab75b481618 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1864,7 +1864,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, sata_cmd.tag = cpu_to_le32(ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); - sata_cmd.ncqtag_atap_dir_m |= ((0x1 << 7) | (0x5 << 9)); + sata_cmd.ncqtag_atap_dir_m = cpu_to_le32((0x1 << 7) | (0x5 << 9)); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index b83500ef3d86..f1663a10693a 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1882,7 +1882,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, sata_cmd.tag = cpu_to_le32(ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); - sata_cmd.ncqtag_atap_dir_m_dad |= ((0x1 << 7) | (0x5 << 9)); + sata_cmd.ncqtag_atap_dir_m_dad = cpu_to_le32(((0x1 << 7) | (0x5 << 9))); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, From patchwork Sun Feb 20 03: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: 12752515 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 464BDC433F5 for ; Sun, 20 Feb 2022 03:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238040AbiBTDSr (ORCPT ); Sat, 19 Feb 2022 22:18:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235446AbiBTDSm (ORCPT ); Sat, 19 Feb 2022 22:18:42 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F9C340D2 for ; Sat, 19 Feb 2022 19:18:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327101; x=1676863101; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tMu46lOD+saf9CD6nTTB39TE+9yuObAVdHXvuV2n3JQ=; b=Cb8FwbbPWDvyIrKrqWXDYb1gvt5r5wc4xz/IDJ8IpAS0DU1vZA690QQo ibok/0KEQASsosNmyg7sUZUIzwssur6tczFQM4zzbZqI+CqcnBy7liO0D LGi5NpU70HefiWxuIQU5esMEoSRyUJaVea3yyblc8rU2RSp5eTbNMZ8Yz SVPE4htH0ZhKYw0qlrh1N5+lcip8KvgnJP6Ai1XyMpDAVVnZO86BxFvc1 q/DtYiIe6eOGt4lDZFbnQp5hykKyx/hPU870P6Nb+mVcdocdX9ePRCj8N HvT2chET+vMt3TkmF509tO9r38X7xfVLA7VFRyBYSqFOHQTm+Y+LIQTzb w==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405737" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:21 +0800 IronPort-SDR: G+snjoB20wn8Qg9wOj+MRNF9wdmHKnX/GYEvzDxlqD/ABRddmYlpBvQ0mn+EkhXupchqolr69f GD6pqRkbHKgi7iAT8IItOSwOnlDwAUxhvszCBOj6VW4hn9+EmQMh0rxmePG/SiOgKpaKJFIar+ 7aFnHhRndA/jsHO6gS2nujiDZ5YUAiUMC9r/T714PdWcdt4Gx5G/BcfiOWdHd0vHwQTHQpRONs 3fiqPO4AEJfWYJdpBeE3yzhjDDcPXgbLaFOtBE6PbA/uIVcuxVUKV+Jp0529Z69W6V24xuFt5p lZEu1AvH/dMmuo2UJmYmtB3g Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:49:57 -0800 IronPort-SDR: DTsP8+t4xBhUS/UCQWfD4+F8M1HpZVOwbKWHxaalvqjgBX1mvVa81rD5b6IPtNj4MO9Cc5iX9a kh+KJhdXkpJLsweK7wpLyHebdMHLf0snLAG++qMqo1uNPKfuroCKey8NoIibejQR9+fMxYuagr BWnBJBBZCtMn0mdPcOSsQY3KdW1Q8WZZV3yZhy08rcqQoj7RncKq4NQtQmhMDxxtvphHZGzwxH O0UkerKJ+VmXNSDEwJhb+dzJA60MPlsQqTUsGoCquqaLh4WAFdg28tyGzl3hUInoEOw9CSOnFY vpE= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:22 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1Vxn60dVz1SVp0 for ; Sat, 19 Feb 2022 19:18:21 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327101; x=1647919102; bh=tMu46lOD+saf9CD6nT TB39TE+9yuObAVdHXvuV2n3JQ=; b=s7VdFW9LCNBmFYr8YBXmpPSibGZIChJlNI 8W8jFZbVaezwTpOa4d2iULfXvXTSw+nEAJTDYsqN7hK6b2/nrmMUbyRV6d5fTjQY yLCq9ifhsitvm5ZqhStyxqHPqJN3/U/v9QlyiyQ66ljQJLfIO8+aYd8T6Q09pz5d RxBLgShXM9EaYFU6DkK9sYEQXkcaQpaCGPOh8ScZHjcUrdQgU8QL9oesgrvwBagT C2vDEU+PrJryl3rrRiGO6xHsN0tWwuSqSlDnZu5vrGVutQomTGxIoxb31AZqqK+w dacHoBwUwE1cjOV3toVwzPSkPM+2PGoZGOp+f0dCsRIqhuq2qCYA== 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 cYFjpGiMGesO for ; Sat, 19 Feb 2022 19:18:21 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxm2RKNz1Rwrw; Sat, 19 Feb 2022 19:18:20 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 05/31] scsi: pm8001: Fix pm80xx_pci_mem_copy() interface Date: Sun, 20 Feb 2022 12:17:44 +0900 Message-Id: <20220220031810.738362-6-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The declaration of the local variable destination1 in pm80xx_pci_mem_copy() as a pointer to a u32 results in the sparse warning: warning: incorrect type in assignment (different base types) expected unsigned int [usertype] got restricted __le32 [usertype] Furthermore, the destination" argument of pm80xx_pci_mem_copy() is wrongly declared with the const attribute. Fix both problems by changing the type of the "destination" argument to "__le32 *" and use this argument directly inside the pm80xx_pci_mem_copy() function, thus removing the need for the destination1 local variable. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index f1663a10693a..0b3386a3c508 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -67,18 +67,16 @@ int pm80xx_bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shift_value) } static void pm80xx_pci_mem_copy(struct pm8001_hba_info *pm8001_ha, u32 soffset, - const void *destination, + __le32 *destination, u32 dw_count, u32 bus_base_number) { u32 index, value, offset; - u32 *destination1; - destination1 = (u32 *)destination; - for (index = 0; index < dw_count; index += 4, destination1++) { + for (index = 0; index < dw_count; index += 4, destination++) { offset = (soffset + index); if (offset < (64 * 1024)) { value = pm8001_cr32(pm8001_ha, bus_base_number, offset); - *destination1 = cpu_to_le32(value); + *destination = cpu_to_le32(value); } } return; From patchwork Sun Feb 20 03: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: 12752517 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 1B93AC433EF for ; Sun, 20 Feb 2022 03:18:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233859AbiBTDSt (ORCPT ); Sat, 19 Feb 2022 22:18:49 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236462AbiBTDSn (ORCPT ); Sat, 19 Feb 2022 22:18:43 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9D71340D3 for ; Sat, 19 Feb 2022 19:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327102; x=1676863102; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+NJqzc6YUpP+vwggbsF6cTeLSsRgTfL3XgaR3agxzlg=; b=SKK+DS+76IHupnprDrmfN/qDk4B7G3M/x48LyolRSH9R3GsYqChDUu76 vn/wud695v72+Q8cvgb+JL/zPFocMtVkrUjXus7uEJW4s5BPTcBBO9k5i EBNgv4TIqNxkHdl92gtKngBnesbxhOIMngW7MQLj6EHLlobju+J+V8DAz db436N9gSdr3AVOUkEeJC4arGfGFQ3OmIKS1+xa0kiYv1OSdZPoTiZu7s mDdSqErf1cciXKoJf97DPgJxcJR1ngOZpLQD74EB7BTrSazbdsc1Ms11R qViydL/ZnJEZW3GHyjJjbctIFKAv3oLHIp82Zqx2a7F6YRQiMR0pWUPwF A==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405746" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:22 +0800 IronPort-SDR: zFDcJKavhOmJCOUzmLHEynt1gpz8sGpwLmla97IaVKqjQwACGND8lpHpjtbxTqmtHRvIeSvcs/ DbCcsiQIPB0m63JQPHZjIxbwLXl/S8WcVG79Xrm/uG4womKhTzBYeJhBqc3/bYbFkK1kJbb22E hVamLv4ItD9XZiy35vyh33Hna7tiY1dJFhcf4x5ozoZo85/jTLRAj4Ni6+4FWLtIcxuYhgYmWY BdDMfyBttPZaC/HzZWY1ZiMje2rHn+SNG87wEjd7yB62umsFMi1ryTyQITvD+GV43rNl5IU3cJ LUDbDA5FRqRPmNHiXZ3/oR71 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:49:59 -0800 IronPort-SDR: 1IvnYAmWNy33TcUOcK/T9KMsOPFBWoDk1m11JfrDJ2lduLsQjU9z96XtOBGQ+inxcW9JeydnLj N/hcSh57Ouz8YVWyo55uSbnXRZqp1NXieOGffkgpON7mDse3s+LkoF2uV9x9lL4ygfgu1l5yJz B3ayFCLS4dSERNaRgm1nX+jeaHbwWjB+yCDgcoArzzxqA17JoMBFPvIj6ogVXG9k1kU+Co0F8O ewkyyQvFa0Etux3/RDSyfztjGPgnzLTHVfyZKH/CQ7WUpx3Y1uKG7potjM0eZsCVQV7lameRvh JKw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:23 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1Vxq1sPdz1SVnx for ; Sat, 19 Feb 2022 19:18:23 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327102; x=1647919103; bh=+NJqzc6YUpP+vwggbs F6cTeLSsRgTfL3XgaR3agxzlg=; b=kl9PzeWgFbOtmicwKn7Trxqbln1kPgJNgf ox+R6hBpumS2txZnkPbABvQBslH+p//1gdT6mrZ05rsrJplmn2NAM2CcZshFvlRf jb4B7x3z0fHdvvmpqs2wOg4pyPjhRSDwCqvEsfelSLUUdI8WOfzfFdD+w4jOG6Y3 I9OS3+VpAdAqF22azWdgreKkg+CgUOaar8cMQRPPgvNbx92MbiJDVvfjfgiuyCc8 o/v4YgHEvhwE6bflNW6q7hzK1K+2lYGtvONFPtW9V9CKaZGIFUWREbS/uflaG9S+ o0G5cR7of/HspNQ9b4og9cqf4Z63DJBL5gn9uMOXlM1SYD/F2byw== 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 1_qNkagE6yt8 for ; Sat, 19 Feb 2022 19:18:22 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxn5B9Qz1Rvlx; Sat, 19 Feb 2022 19:18:21 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 06/31] scsi: pm8001: Fix command initialization in pm8001_chip_ssp_tm_req() Date: Sun, 20 Feb 2022 12:17:45 +0900 Message-Id: <20220220031810.738362-7-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The ds_ads_m field of struct ssp_ini_tm_start_req has the type __le32. Assigning a value to it should thus use cpu_to_le32(). This fixes the sparse warning: warning: incorrect type in assignment (different base types) expected restricted __le32 [addressable] [assigned] [usertype] ds_ads_m got int Fixes: dbf9bfe61571 ("[SCSI] pm8001: add SAS/SATA HBA driver") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index dab75b481618..d80b48e0e41b 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4619,7 +4619,7 @@ int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha, memcpy(sspTMCmd.lun, task->ssp_task.LUN, 8); sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag); if (pm8001_ha->chip_id != chip_8001) - sspTMCmd.ds_ads_m = 0x08; + sspTMCmd.ds_ads_m = cpu_to_le32(0x08); circularQ = &pm8001_ha->inbnd_q_tbl[0]; ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd, sizeof(sspTMCmd), 0); From patchwork Sun Feb 20 03: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: 12752518 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 2552EC433EF for ; Sun, 20 Feb 2022 03:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239777AbiBTDSw (ORCPT ); Sat, 19 Feb 2022 22:18:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237906AbiBTDSp (ORCPT ); Sat, 19 Feb 2022 22:18:45 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB6A340CD for ; Sat, 19 Feb 2022 19:18:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327104; x=1676863104; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QveB5a+85eplIPaj4PtIIZ6/INt1r9nE8RbC6a9EBNw=; b=Tcyq09cEQAgX2MdVpY+5NK7xmiO/CUCu56BNvMV7ODeDwmtGzRnOqADR 649IfFsMkYTriS0N0xzhXEBpJDAtjTMnteKDZCo44/9avDy10Zoqap4c1 nhdksHprDGCGXKC+PxOJrC7pPRkyVnsnfCbiQMW8626Suaj4r7QFlIDVp qsAFED2oq5UCeoXhrqkbzzOJVSZlD1cVAyYmnH3gXzklTITL+r+P8Odq3 z6oJDMdEZAaHfcL34v2l0u0bcTk/ftuSa7hCERJLSQUWeUnUzmw/qkviM sHYZUXUbzMEFNGR+ZGDy0x6O/LI00cY+GRtQw5ynlD2oYADVBZhILN6mz Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405749" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:24 +0800 IronPort-SDR: ViGUMU7PBCCwUPIpX4eYYVn6AqSXJFgTLbAGGdzwX3zkQqIscuBr0XmzjCEZwq2ZaC3rriHp/2 wZcaK5gregNs+jBbkikjUFnsL1iPxOv9/xGkrRI9c0FL1dHaFnacz0v5xEbbmEW02lZErX6d1b XyFkIUtQ5SPeE7dRZN8e/QlVn1nBZvoiONpXpGr3CrtUXdKvH0pVFb2Mk7gkUArI2Zcuoeaz4p Iw0F6gtCx2huVZ4o3pA3T7Xu1W8B0IdXHw1yZxHaxV7Dt6RhHGau89PR0ufL9l3Csfkr/LGEYL g8dNfE/ayRRmu4dZdnMYzwzm Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:00 -0800 IronPort-SDR: GDq8zRZQ0hsXx/IiVCmFdg+290VytsxoBkBp0DhuyAVP/EJArhYmNG2vdcQq/yCRhPgPVxuCDA oRlJmVmQIMIGSo2ds1FC+OuXJX3PLG1iHX8yreNdQYE7RYlbBvzb63Jkm8gOLczHrnBENtY72A pVmbBE3uSYg3Zw+HSad0V5YJrJTlKfzfEGVJXfKerCXSa00w9HgEwvAP79aqBT5bcktefz/NLO s+0Nyz/2JtBdm6Vj16ovNrLjZQwYq1ri83GRJVgybXgFE/a8MB3HlQfkOR7dOeVAI2RyTKHQDS pIs= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:25 -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 4K1Vxr5D2yz1SVp3 for ; Sat, 19 Feb 2022 19:18:24 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327104; x=1647919105; bh=QveB5a+85eplIPaj4P tIIZ6/INt1r9nE8RbC6a9EBNw=; b=esJxp/a+QURTtWT00kOe7rFkcOkkAY0yOF oedI5IsXbWQ4dBskbhGJCt+cEC39yjHhtUHTmkoKNssM4FC1RuOCN39/xqO/eYld v2oDqDqcdshSweg34aJaN6n8XD05MHcC5WNQqWm/ISMZHIQBJMAlLCfjMvMA3Rcl wUMiBbq1/OIJexACRcu4O7HAOPn79O1bh/YhncuOx5IOElS8NV3LvLQHOhik5Z7E c43dXQYEXulXyBVUUtJq/qN4Ht7dCLTD7kQpIplYRKdXPU/GGyI/FDN833KuH4xQ rRo4tAYRItkHkFaU8PArjCB5LuiAKGbXgUPjSvBXHfcC5krJOEgg== 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 cUETIVvw4GIG for ; Sat, 19 Feb 2022 19:18:24 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxq0rffz1Rwrw; Sat, 19 Feb 2022 19:18:22 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 07/31] scsi: pm8001: Fix payload initialization in pm80xx_set_thermal_config() Date: Sun, 20 Feb 2022 12:17:46 +0900 Message-Id: <20220220031810.738362-8-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The fields of the set_ctrl_cfg_req structure have the __le32 type, so use cpu_to_le32() to assign them. This removes the sparse warnings: warning: incorrect type in assignment (different base types) expected restricted __le32 got unsigned int Fixes: 842784e0d15b ("pm80xx: Update For Thermal Page Code") Fixes: f5860992db55 ("[SCSI] pm80xx: Added SPCv/ve specific hardware functionalities and relevant changes in common files") Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 0b3386a3c508..b303bc347f3d 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1201,9 +1201,11 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) else page_code = THERMAL_PAGE_CODE_8H; - payload.cfg_pg[0] = (THERMAL_LOG_ENABLE << 9) | - (THERMAL_ENABLE << 8) | page_code; - payload.cfg_pg[1] = (LTEMPHIL << 24) | (RTEMPHIL << 8); + payload.cfg_pg[0] = + cpu_to_le32((THERMAL_LOG_ENABLE << 9) | + (THERMAL_ENABLE << 8) | page_code); + payload.cfg_pg[1] = + cpu_to_le32((LTEMPHIL << 24) | (RTEMPHIL << 8)); pm8001_dbg(pm8001_ha, DEV, "Setting up thermal config. cfg_pg 0 0x%x cfg_pg 1 0x%x\n", From patchwork Sun Feb 20 03: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: 12752520 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 4C78CC433EF for ; Sun, 20 Feb 2022 03:18:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240498AbiBTDSz (ORCPT ); Sat, 19 Feb 2022 22:18:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239389AbiBTDSt (ORCPT ); Sat, 19 Feb 2022 22:18:49 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61E1A340D0 for ; Sat, 19 Feb 2022 19:18:26 -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=1645327108; x=1676863108; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tEJfk/UE9FOASU+9JhmgRQlEK/ajrA/oKGoTSJqp5mA=; b=lpPQsLYl9Q0oOT65fRYUsuvGSCJCBJviXTV/NxyngpOEQSSP4YBEs8M7 u+aBn9Lvs/FO8lGc4A4N8mcyOGQVaPGH/jt2er3DT7B6d028mXxKW5Ha0 w1we+5qWBXZqb8vM9VrSiCH7w2O7C4uEbaTY9M2sW84xW64HM3QeR3Uoo dLku3Fznu/JmZAoRBAygHKChPVic6kE/gILkmZTTOiQ7iA/ldDMdCW/YS PNEOlizghQkwgiDw3g4nwyo3tcZ6GdtUdxtrsgwr3IKGH6KQDEYxoz56w kTZ8aKiaYIPbNMTYPg6Rbky8wx3N0Xdn/Zm7VwYWs7LfanGPIIOj4njhI w==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405752" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:25 +0800 IronPort-SDR: zKKy0aKzhYccgWjuhzb+f5B44gdwisx3AjevVbvV43jCDqzFRzovB578m3ZHgFm7/7BZ/OEfVU LZLfX7PruF78dAuWjYmr1lKxjkTi6JLCDaSQtXh2qtLgMAE75kQcv+sT1HXHkzU5iE/I0wyRHE bGdYf9LJHyCkdOo3K6WJG5H88W44P6Hnstl+2Jx5Fgu5wqqw5amfiM8MEL1BWu/Hfhu1xshl6u 6t2dbHpsjutSAMgSaGYxR9N2pkpAOS/UQqY9DR+ZD9KFAX2xPh4MqNHmX5BlzVn3ngQmRuBM5V SFR84UsZ2x4Lh0ZInPvFe5gw Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:02 -0800 IronPort-SDR: nvulKrS2Ynzx3txtV2UrJai0Br1Fe1f2O79AK3Lt53KPPknCg9CH8x9M+coazZRnabX/Gsg5kN 3JcjJalk4LIGqyhjKDZxZ8gy3WQQ/ZNYl7qFKKCFACQBiqABFiXN6IHJaEIdiE9zmuCrZLKJqU 9Q+KZ3Mvgig4czc3viXtm6WxxdmV7iXnQjIbce8Jr3XSgzokWOESswFXMyM8BNKO9Mf/467kZ7 VUS1QZz1oSpELQLP+POaJrs81eUIucN1Sl5E+0HCTspfuqvzQwh7R9buJ4iHk7mUmPOqxo0sww n8M= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:26 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1Vxt1tZMz1SVp1 for ; Sat, 19 Feb 2022 19:18:26 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327105; x=1647919106; bh=tEJfk/UE9FOASU+9Jh mgRQlEK/ajrA/oKGoTSJqp5mA=; b=MrWgBWwQ+CujzEJG4flFmFU2Fe9e3M3UAF /TLNe6oSBcrkLYuc+rFzxY3yFpYVLySmMjN+CO5o0CG2BSabSccr39ubXlrvJhmZ Wy9gGLYOzGkaoAg2TgE7E2jSnZfC3KERm86VmzwDhLPehC0umv1RbhNJi0hnJEFQ ttbryc7PSz/nMx+klND+fXrVPUkWDezi+kHwx/3cMXVBye9RBQYF01N/G08Sbhjs +grzkGFVCS3ll4bxHwd6ULYqjoX1TxIPWJqnJeM6qaOax+soC6HPnZjJ50hXgmWp gUwRjMk172KXrdpHJC8c+qo8jvWn2KrvrHWff4zKYmhbzWbYrnOw== 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 JNysSaY1XAUo for ; Sat, 19 Feb 2022 19:18:25 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxr3qtQz1Rvlx; Sat, 19 Feb 2022 19:18:24 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 08/31] scsi: pm8001: Fix le32 values handling in pm80xx_set_sas_protocol_timer_config() Date: Sun, 20 Feb 2022 12:17:47 +0900 Message-Id: <20220220031810.738362-9-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org All fields of the SASProtocolTimerConfig structure have the __le32 type. As such, use cpu_to_le32() to initialize them. This change suppresses many sparse warnings: warning: incorrect type in assignment (different base types) expected restricted __le32 [addressable] [usertype] pageCode got int Note that the check to limit the value of the STP_IDLE_TMO field is removed as this field is initialized using the fixed (and small) value defined by the STP_IDLE_TIME macro. The pm8001_dbg() calls printing the values of the SASProtocolTimerConfig structure fileds are changed to use le32_to_cpu() to present the values in human readable form. Fixes: a6cb3d012b98 ("[SCSI] pm80xx: thermal, sas controller config and error handling update") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 52 +++++++++++++++----------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index b303bc347f3d..e6fb89138030 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1245,43 +1245,41 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); - SASConfigPage.pageCode = SAS_PROTOCOL_TIMER_CONFIG_PAGE; - SASConfigPage.MST_MSI = 3 << 15; - SASConfigPage.STP_SSP_MCT_TMO = (STP_MCT_TMO << 16) | SSP_MCT_TMO; - SASConfigPage.STP_FRM_TMO = (SAS_MAX_OPEN_TIME << 24) | - (SMP_MAX_CONN_TIMER << 16) | STP_FRM_TIMER; - SASConfigPage.STP_IDLE_TMO = STP_IDLE_TIME; - - if (SASConfigPage.STP_IDLE_TMO > 0x3FFFFFF) - SASConfigPage.STP_IDLE_TMO = 0x3FFFFFF; - - - SASConfigPage.OPNRJT_RTRY_INTVL = (SAS_MFD << 16) | - SAS_OPNRJT_RTRY_INTVL; - SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = (SAS_DOPNRJT_RTRY_TMO << 16) - | SAS_COPNRJT_RTRY_TMO; - SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = (SAS_DOPNRJT_RTRY_THR << 16) - | SAS_COPNRJT_RTRY_THR; - SASConfigPage.MAX_AIP = SAS_MAX_AIP; + SASConfigPage.pageCode = cpu_to_le32(SAS_PROTOCOL_TIMER_CONFIG_PAGE); + SASConfigPage.MST_MSI = cpu_to_le32(3 << 15); + SASConfigPage.STP_SSP_MCT_TMO = + cpu_to_le32((STP_MCT_TMO << 16) | SSP_MCT_TMO); + SASConfigPage.STP_FRM_TMO = + cpu_to_le32((SAS_MAX_OPEN_TIME << 24) | + (SMP_MAX_CONN_TIMER << 16) | STP_FRM_TIMER); + SASConfigPage.STP_IDLE_TMO = cpu_to_le32(STP_IDLE_TIME); + + SASConfigPage.OPNRJT_RTRY_INTVL = + cpu_to_le32((SAS_MFD << 16) | SAS_OPNRJT_RTRY_INTVL); + SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = + cpu_to_le32((SAS_DOPNRJT_RTRY_TMO << 16) | SAS_COPNRJT_RTRY_TMO); + SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = + cpu_to_le32((SAS_DOPNRJT_RTRY_THR << 16) | SAS_COPNRJT_RTRY_THR); + SASConfigPage.MAX_AIP = cpu_to_le32(SAS_MAX_AIP); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.pageCode 0x%08x\n", - SASConfigPage.pageCode); + le32_to_cpu(SASConfigPage.pageCode)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.MST_MSI 0x%08x\n", - SASConfigPage.MST_MSI); + le32_to_cpu(SASConfigPage.MST_MSI)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_SSP_MCT_TMO 0x%08x\n", - SASConfigPage.STP_SSP_MCT_TMO); + le32_to_cpu(SASConfigPage.STP_SSP_MCT_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_FRM_TMO 0x%08x\n", - SASConfigPage.STP_FRM_TMO); + le32_to_cpu(SASConfigPage.STP_FRM_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_IDLE_TMO 0x%08x\n", - SASConfigPage.STP_IDLE_TMO); + le32_to_cpu(SASConfigPage.STP_IDLE_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.OPNRJT_RTRY_INTVL 0x%08x\n", - SASConfigPage.OPNRJT_RTRY_INTVL); + le32_to_cpu(SASConfigPage.OPNRJT_RTRY_INTVL)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO 0x%08x\n", - SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO); + le32_to_cpu(SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR 0x%08x\n", - SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR); + le32_to_cpu(SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.MAX_AIP 0x%08x\n", - SASConfigPage.MAX_AIP); + le32_to_cpu(SASConfigPage.MAX_AIP)); memcpy(&payload.cfg_pg, &SASConfigPage, sizeof(SASProtocolTimerConfig_t)); From patchwork Sun Feb 20 03:17:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12752519 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 E85D8C433F5 for ; Sun, 20 Feb 2022 03:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240224AbiBTDSx (ORCPT ); Sat, 19 Feb 2022 22:18:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238602AbiBTDSt (ORCPT ); Sat, 19 Feb 2022 22:18:49 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D031340D1 for ; Sat, 19 Feb 2022 19:18:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327108; x=1676863108; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PplX+kDNXdsQ5HZh8arIKafLu+DD+Al5/ujtqhFFtf0=; b=EFWkJZg3yNzIazN/4WfIymbLk/hY/JvOw2EVx9Nzqp4QKuh90+bVu8cV qv8S1q4d0BokZSf+OTx0DW7XbC6Yh6mElN4MyS4ZoFqZxWHXdQxFcbe3K LOaJ75KZWBVZnbWdayrmNvx0Q0rMcsG5ljdNNGytLP0JeBKEK4tNsXqH+ wTqDw50dwjE9V1xl95CPPszlR5GFLsPj0kswfwihn/zElMJbskNUWnegq vvmY2kpy+urjGUkeGJgGRj8ttyQlSezMzZl4l9Esn/o8yBP6+5GV7D4/D NSRIdwvkHZNelp+fhZkeMI+BOanXiWiRiic46+zdEADKqGZgtvQ2vrYbu A==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405755" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:26 +0800 IronPort-SDR: b8B9RfjeM0Kf32q/p5PYVGFSQT2O1DoZpC75yy/Pf5Gqrdnm3AFXrJJXpiZpml6TtaYFLvazqd 1b/NtMlW+W9eD3YloCcsoVgIHIwluPQrFrz/OwwIStc4vM41KkRuKrHvf6blY9wyVxj2WECAHx usJfrKsrX4thXtZqpRI2IYXL4tdDVRK6myEqUnKcpctuv7JCgvzDv5ryAaRcS/f+3Zc/NmMq62 jkHHb+1Ol6OQrXE5LdOBZIlsQqZ2rjIvZti6OaGUba/GKJHSITTkuKKUyQsVUFcocjwrJRbSB7 so3pDJXIxPecLbJrxE2RVUWp Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:03 -0800 IronPort-SDR: 4S4ecbexQ093WcSHwciCYT193rvgMDH1HZdCOEvVl2nCgPHJT5wWhfRNiJM66X4YJOaCRl5geB 9pqIfro5Oq6SxrN/RcpU19mBh7jAFFS0WFDzG5tGW/h9At6piawQe3zTebHplv8yPcJSjgHxXP EPtDIUY9Yn/34LkMn891JKiKI3cq2SjkIkJnHoBUAF0GtkX8NKdUQVBq2P0v1oDaZe/+bRbFFi FnFeqwO0gEj3GhaQZFfj/GtEiZk50Da5roTAMT+O6TQBLJvxCScaai3oNWK4T7+xXEavQkXSio SvI= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:28 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1Vxv3nQpz1SVnx for ; Sat, 19 Feb 2022 19:18:27 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327107; x=1647919108; bh=PplX+kDNXdsQ5HZh8a rIKafLu+DD+Al5/ujtqhFFtf0=; b=HjWEMRDvwO9t5iWQMzC3b0H3GtBS3yFGKI od5j67W/Mbg3V4bKEUrUW+ZQwZzP6gTDRxqpRheQB8X6taKhPSoJaRfcoIaeHsVl 0ZamE2SZeLlEL1mDOqUHwLVWscSG4C7KMT0oRVVJ3z9ogIO4psvsDJvb31FmxxGz ed5X3dx599+n59ckASk1b+ceHBieeGaid8JtOuLOSKBjdcd4eDyMndluAjvgfEkz fdp9dvT3BDw5w4dTJMsTJKW3samdRFaDRXWpBUIN2arVRcabluZZEsJUsTWdply/ pja3txF75d4/54OlN/APkR65JgkbGwo3PbNIa6yuAXqagdTDE+BA== 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 yoriKdONc5WM for ; Sat, 19 Feb 2022 19:18:27 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxt0Ks6z1Rwrw; Sat, 19 Feb 2022 19:18:25 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 09/31] scsi: pm8001: Fix payload initialization in pm80xx_encrypt_update() Date: Sun, 20 Feb 2022 12:17:48 +0900 Message-Id: <20220220031810.738362-10-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org All fields of the kek_mgmt_req structure have the type __le32. So make sure to use cpu_to_le32() to initialize them. This suppresses the sparse warning: warning: incorrect type in assignment (different base types) expected restricted __le32 [addressable] [assigned] [usertype] new_curidx_ksop got int Fixes: 5860992db55c ("[SCSI] pm80xx: Added SPCv/ve specific hardware functionalities and relevant changes in common files") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index e6fb89138030..b06d5ded45ca 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1405,12 +1405,13 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) /* Currently only one key is used. New KEK index is 1. * Current KEK index is 1. Store KEK to NVRAM is 1. */ - payload.new_curidx_ksop = ((1 << 24) | (1 << 16) | (1 << 8) | - KEK_MGMT_SUBOP_KEYCARDUPDATE); + payload.new_curidx_ksop = + cpu_to_le32(((1 << 24) | (1 << 16) | (1 << 8) | + KEK_MGMT_SUBOP_KEYCARDUPDATE)); pm8001_dbg(pm8001_ha, DEV, "Saving Encryption info to flash. payload 0x%x\n", - payload.new_curidx_ksop); + le32_to_cpu(payload.new_curidx_ksop)); rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); From patchwork Sun Feb 20 03:17:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12752521 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 9DACDC433FE for ; Sun, 20 Feb 2022 03:18:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241843AbiBTDS5 (ORCPT ); Sat, 19 Feb 2022 22:18:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236462AbiBTDSu (ORCPT ); Sat, 19 Feb 2022 22:18:50 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B11D8340D2 for ; Sat, 19 Feb 2022 19:18:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327108; x=1676863108; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NznwQIrXtOr3EbXJhwYPD9nDQOPGAk8nVW66eSLouuE=; b=i1mi9K22l4sI0o66GuAVGbj0MXhWRVmYsqBzBd7Q/6eNZ4/VgHcC/GN4 25lUyAHW0Y7hnEHWjXfeP6hu9ODkaIaXoa7VeyGOOVboi60Bp3yWztwPZ XPeEutPyfeTHFTH2iptwrr8MLZ98FAcJxPcOnvI6/Wsx/jwWeiKF1iMl5 ki8+ic+IpKo/Hsk6xQfunMUYHF77KcETZZMpnCiH3JA8pv6YwCNvQ67Ww HR5IlC7lLdqgv0qg0iA9/EUS+nHdhNZfA4GNwk6vK9jmKImbN3KHwmdgd POVIf2RtxalKdd7IFly37SWXB0EAsenmY699k5lLUkR4tFD1PKxYTZXh0 g==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405758" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:28 +0800 IronPort-SDR: MAfd1q60B/l9re27SVnFwihAqLV0dZoutI/3p+fSWfBMc1dM/zD/wMVz+QABZw8iLIhngogA7p mMY/0XvcgJjG2XaxcYyp+oxep5520TYPlqIC5Daxl++gq7wvuGSDw6ofJtjgXFh+CUhLq5ymUL HH0UlCc0UYWbd02+Y1U53SXgD/5LI5nqyylae/4SIYS8BM2JbZbEfnFSYDUuESljyJ1jpkFByV gXpDWPGDSDE/5DI4NV8yRFKEYlZosEq95a1+Y/cY5XZjgZmZNBcmEpGLOuYNZqjqeMLpFjaufs YuBO69RqxEGy9jkweSNf0MKY Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:04 -0800 IronPort-SDR: fTzvbQG00I/Tir3Ujf5j/UO5KS6Yjkfi1nCU8b5yc/PJEIo3NfkQKEso4ibuJrWyrz7zIpCDqx Q6z6JyqZAh5iDUW1sBAN26ojvDNOQA1tM0UQWc8/UNdBpaclFIaLcIIKF/74zJXMBR4cunvBEV hyGlLGenNDM+en2isfe9EdmwWLg3kTic9IIVQ48QiUeQiW/gWNiTiPDtxdp6h4YI9TK8nE/sVP GfWx4vE+6PN/l6OB6Znc8vHUOLD4qnGaUwMH+bTAnG2z14C7hgF9sLRD5g294gDMGgagnSEQTq Y2o= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:29 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1Vxx10jCz1SHwl for ; Sat, 19 Feb 2022 19:18:29 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327108; x=1647919109; bh=NznwQIrXtOr3EbXJhw YPD9nDQOPGAk8nVW66eSLouuE=; b=Ft7fh0g0GZAgo4EZzgFD65Skd67daPJ3a7 d3JJOyY8YTS+fOtyI78hcGWuI1hxMDDVDRENF8fawicC9M+xhjk7jW8ptQjE/G4G yW45ZzJt0Zh0QVzO9gCJdJHWRVSPILOFVV0XqQGyTCT4tyY6eKBMqIa3rqQ0hjc2 //RH0vAl7wmZjpwD09u51gqlK0JkbEGUlUmoTPyjsQxERWX0HxtI4Aambqd1gi5O Mzd67oeHAOK1mwpHpU/nRlLvoDrV0jCljLG7OaKt8O8moLAlVjoKE3PxuPZdrmon crYyxH0cdxpiuCq2eU/Blv74ivWDCQojsx0yn7528iSW9sP2WjQA== 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 yGeMMRXcn3_N for ; Sat, 19 Feb 2022 19:18:28 -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 4K1Vxv2rpdz1Rvlx; Sat, 19 Feb 2022 19:18:27 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 10/31] scsi: pm8001: Fix le32 values handling in pm80xx_chip_ssp_io_req() Date: Sun, 20 Feb 2022 12:17:49 +0900 Message-Id: <20220220031810.738362-11-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make sure that the __le32 fields of struct ssp_ini_io_start_req are manipulated after applying the correct endian conversion. That is, use cpu_to_le32() for assigning values and le32_to_cpu() for consulting a field value. In particular, make sure that the calculations for the 4G boundary check are done using CPU endianness and *not* little endian values. With these fixes, many sparse warnings are removed. While at it, add blank lines after variable declarations and in some other places to make this code more readable. Fixes: 0ecdf00ba6e5 ("[SCSI] pm80xx: 4G boundary fix.") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 41 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index b06d5ded45ca..130747b5a70a 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4374,13 +4374,15 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, struct ssp_ini_io_start_req ssp_cmd; u32 tag = ccb->ccb_tag; int ret; - u64 phys_addr, start_addr, end_addr; + u64 phys_addr, end_addr; u32 end_addr_high, end_addr_low; struct inbound_queue_table *circularQ; u32 q_index, cpu_id; u32 opc = OPC_INB_SSPINIIOSTART; + memset(&ssp_cmd, 0, sizeof(ssp_cmd)); memcpy(ssp_cmd.ssp_iu.lun, task->ssp_task.LUN, 8); + /* data address domain added for spcv; set to 0 by host, * used internally by controller * 0 for SAS 1.1 and SAS 2.0 compatible TLR @@ -4391,7 +4393,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.device_id = cpu_to_le32(pm8001_dev->device_id); ssp_cmd.tag = cpu_to_le32(tag); if (task->ssp_task.enable_first_burst) - ssp_cmd.ssp_iu.efb_prio_attr |= 0x80; + ssp_cmd.ssp_iu.efb_prio_attr = 0x80; ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_prio << 3); ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7); memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cmd->cmnd, @@ -4423,21 +4425,24 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.enc_esgl = cpu_to_le32(1<<31); } else if (task->num_scatter == 1) { u64 dma_addr = sg_dma_address(task->scatter); + ssp_cmd.enc_addr_low = cpu_to_le32(lower_32_bits(dma_addr)); ssp_cmd.enc_addr_high = cpu_to_le32(upper_32_bits(dma_addr)); ssp_cmd.enc_len = cpu_to_le32(task->total_xfer_len); ssp_cmd.enc_esgl = 0; + /* Check 4G Boundary */ - start_addr = cpu_to_le64(dma_addr); - end_addr = (start_addr + ssp_cmd.enc_len) - 1; - end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); - end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); - if (end_addr_high != ssp_cmd.enc_addr_high) { + end_addr = dma_addr + le32_to_cpu(ssp_cmd.enc_len) - 1; + end_addr_low = lower_32_bits(end_addr); + end_addr_high = upper_32_bits(end_addr); + + if (end_addr_high != le32_to_cpu(ssp_cmd.enc_addr_high)) { pm8001_dbg(pm8001_ha, FAIL, "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", - start_addr, ssp_cmd.enc_len, + dma_addr, + le32_to_cpu(ssp_cmd.enc_len), end_addr_high, end_addr_low); pm8001_chip_make_sg(task->scatter, 1, ccb->buf_prd); @@ -4446,7 +4451,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, cpu_to_le32(lower_32_bits(phys_addr)); ssp_cmd.enc_addr_high = cpu_to_le32(upper_32_bits(phys_addr)); - ssp_cmd.enc_esgl = cpu_to_le32(1<<31); + ssp_cmd.enc_esgl = cpu_to_le32(1U<<31); } } else if (task->num_scatter == 0) { ssp_cmd.enc_addr_low = 0; @@ -4454,8 +4459,10 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.enc_len = cpu_to_le32(task->total_xfer_len); ssp_cmd.enc_esgl = 0; } + /* XTS mode. All other fields are 0 */ - ssp_cmd.key_cmode = 0x6 << 4; + ssp_cmd.key_cmode = cpu_to_le32(0x6 << 4); + /* set tweak values. Should be the start lba */ ssp_cmd.twk_val0 = cpu_to_le32((task->ssp_task.cmd->cmnd[2] << 24) | (task->ssp_task.cmd->cmnd[3] << 16) | @@ -4477,20 +4484,22 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.esgl = cpu_to_le32(1<<31); } else if (task->num_scatter == 1) { u64 dma_addr = sg_dma_address(task->scatter); + ssp_cmd.addr_low = cpu_to_le32(lower_32_bits(dma_addr)); ssp_cmd.addr_high = cpu_to_le32(upper_32_bits(dma_addr)); ssp_cmd.len = cpu_to_le32(task->total_xfer_len); ssp_cmd.esgl = 0; + /* Check 4G Boundary */ - start_addr = cpu_to_le64(dma_addr); - end_addr = (start_addr + ssp_cmd.len) - 1; - end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); - end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); - if (end_addr_high != ssp_cmd.addr_high) { + end_addr = dma_addr + le32_to_cpu(ssp_cmd.len) - 1; + end_addr_low = lower_32_bits(end_addr); + end_addr_high = upper_32_bits(end_addr); + if (end_addr_high != le32_to_cpu(ssp_cmd.addr_high)) { pm8001_dbg(pm8001_ha, FAIL, "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", - start_addr, ssp_cmd.len, + dma_addr, + le32_to_cpu(ssp_cmd.len), end_addr_high, end_addr_low); pm8001_chip_make_sg(task->scatter, 1, ccb->buf_prd); From patchwork Sun Feb 20 03:17:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12752522 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 86623C433EF for ; Sun, 20 Feb 2022 03:18:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242177AbiBTDS5 (ORCPT ); Sat, 19 Feb 2022 22:18:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239698AbiBTDSv (ORCPT ); Sat, 19 Feb 2022 22:18:51 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B3E9340D3 for ; Sat, 19 Feb 2022 19:18:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327110; x=1676863110; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RWs2sw36i5zBmGZYuC/mk8fWJ3x6aeqwKl3ALeic7R0=; b=qHleYOVo+RD4nEEsBRU4OWj5D6jYo28KqE4QPFoDhKqhdocx5pj1ok/t 9Qntj2CQtM7ysFN3UGnsKq+7Oy2yKOuQ0BqzsjSjYQKVIvYp45LYyUTUq nD26GbNoTTTsywmRKxI7DIoPHU6K8Tw/rG2IL9dbgM2gqzyfGN0H3qwDZ b1ZZaFF5xf/zZkW4uOuYFcY0yW++RVa4IZ9Feak/XOl+CaqjNLK8RFeFc 4LL3Z+Jd7lSbR17h/b4csLwXb4EIMRnUL9dfnG5I5MRiQVX/iKoZVOUZW bzZI/lBW37xfVzQd20agTCiXcN7WJNGJULE+t2c1STRPd+68t0g6koNzV g==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405761" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:30 +0800 IronPort-SDR: M1s6XxVY5CpjHfRCy8s0Fo1wvz2IfTpLKQc4xFkfaxsz7yTMe2NCUSBTWKFZeqgrXtVe3l4WXw 6HwwI125Dt60dXzR+P7POrUM7gdYb+EQQQnaHn6NsS3VUgI8Ldcc/sX2eh8RfH7zaBMHt8D+yb WnPALNEzibbxzP1I1ajsZjcyIMT7sSe0MJPqPtLdCLZsqYM62b9mkqX82z8vXLNamzzFLYO5aK 7KAseRp6e3uqQ5dGjCAsw5/YCziC5JZ4bRbgg7HMWP0MpHy89G/52N4ZP+NFLGNcqgi5jlNyJc eYszAb47qHcukWsWFu0d+bbK Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:06 -0800 IronPort-SDR: 2+G579Jn8X1jmedOpb3EKQ8oopy71NqX69eFL+Unu9ey3TEF6OZx8CLFki4Cw/0JE6Ois59mgd DeGRD8u/pCkEHTUJp3lhxfCEUMGL62N7KFsnPe1IojstihOqJkqkNUkXz3JMV4+tp0bge1Onwr BRhhy9RFEKr9T6xqsfD5+5MtvuCI5fS/LPMMWDNAHVYcQc5BvRsrjVW/Ch76eJ5JgeRfifTGJJ TyC0T1aZcCb+hsSemTX1q9DHY6PHTdDusyglelbmSLjStJgGUa8vFhXCMTt0qd+2d4zhA3Dkb+ LzM= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:31 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1Vxy587mz1SVp0 for ; Sat, 19 Feb 2022 19:18:30 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327109; x=1647919110; bh=RWs2sw36i5zBmGZYuC /mk8fWJ3x6aeqwKl3ALeic7R0=; b=f01VcrYY2aExMrvADI1FBmtxqcWPV2imAT FgMQVPxK6L1xVTUCRfM7S35R4+3MiLpTp4Gam505JmYRKK6AzLeeGtH77Joh06oa eLP/g6jOmybCzNSX6Z2ycXXKiKX6hIaKJYsS2q8K3s4isWj+/9yZdcOb7Vpopd9L jnEugutj5jX19RwdDKLICOoDl46z07H6qh4cClxnxlB3GlfHqr/x8aZtECJ7qcjR Br+qVY6vckjBWfydvoA4/21fabBG93o8gC9i2VK7LCtadB2pyBQwkkrCMnzjki7K 3qxF2HeFAckvIpeSv3EQhZQtDz/vW34ili6VQIf9g0JLbK+X9VGw== 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 uwVfzXpomkDQ for ; Sat, 19 Feb 2022 19:18:29 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vxw5Pxqz1Rwrw; Sat, 19 Feb 2022 19:18:28 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 11/31] scsi: pm8001: Fix le32 values handling in pm80xx_chip_sata_req() Date: Sun, 20 Feb 2022 12:17:50 +0900 Message-Id: <20220220031810.738362-12-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make sure that the __le32 fields of struct sata_cmd are manipulated after applying the correct endian conversion. That is, use cpu_to_le32() for assigning values and le32_to_cpu() for consulting a field value. In particular, make sure that the calculations for the 4G boundary check are done using CPU endianness and *not* little endian values. With these fixes, many sparse warnings are removed. While at it, fix some code identation and add blank lines after variable declarations and in some other places to make this code more readable. Fixes: 0ecdf00ba6e5 ("[SCSI] pm80xx: 4G boundary fix.") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 82 ++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 130747b5a70a..1f3b01c70f24 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4534,7 +4534,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, u32 q_index, cpu_id; struct sata_start_req sata_cmd; u32 hdr_tag, ncg_tag = 0; - u64 phys_addr, start_addr, end_addr; + u64 phys_addr, end_addr; u32 end_addr_high, end_addr_low; u32 ATAP = 0x0; u32 dir; @@ -4595,32 +4595,38 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, pm8001_chip_make_sg(task->scatter, ccb->n_elem, ccb->buf_prd); phys_addr = ccb->ccb_dma_handle; - sata_cmd.enc_addr_low = lower_32_bits(phys_addr); - sata_cmd.enc_addr_high = upper_32_bits(phys_addr); + sata_cmd.enc_addr_low = + cpu_to_le32(lower_32_bits(phys_addr)); + sata_cmd.enc_addr_high = + cpu_to_le32(upper_32_bits(phys_addr)); sata_cmd.enc_esgl = cpu_to_le32(1 << 31); } else if (task->num_scatter == 1) { u64 dma_addr = sg_dma_address(task->scatter); - sata_cmd.enc_addr_low = lower_32_bits(dma_addr); - sata_cmd.enc_addr_high = upper_32_bits(dma_addr); + + sata_cmd.enc_addr_low = + cpu_to_le32(lower_32_bits(dma_addr)); + sata_cmd.enc_addr_high = + cpu_to_le32(upper_32_bits(dma_addr)); sata_cmd.enc_len = cpu_to_le32(task->total_xfer_len); sata_cmd.enc_esgl = 0; + /* Check 4G Boundary */ - start_addr = cpu_to_le64(dma_addr); - end_addr = (start_addr + sata_cmd.enc_len) - 1; - end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); - end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); - if (end_addr_high != sata_cmd.enc_addr_high) { + end_addr = dma_addr + le32_to_cpu(sata_cmd.enc_len) - 1; + end_addr_low = lower_32_bits(end_addr); + end_addr_high = upper_32_bits(end_addr); + if (end_addr_high != le32_to_cpu(sata_cmd.enc_addr_high)) { pm8001_dbg(pm8001_ha, FAIL, "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", - start_addr, sata_cmd.enc_len, + dma_addr, + le32_to_cpu(sata_cmd.enc_len), end_addr_high, end_addr_low); pm8001_chip_make_sg(task->scatter, 1, ccb->buf_prd); phys_addr = ccb->ccb_dma_handle; sata_cmd.enc_addr_low = - lower_32_bits(phys_addr); + cpu_to_le32(lower_32_bits(phys_addr)); sata_cmd.enc_addr_high = - upper_32_bits(phys_addr); + cpu_to_le32(upper_32_bits(phys_addr)); sata_cmd.enc_esgl = cpu_to_le32(1 << 31); } @@ -4631,7 +4637,8 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, sata_cmd.enc_esgl = 0; } /* XTS mode. All other fields are 0 */ - sata_cmd.key_index_mode = 0x6 << 4; + sata_cmd.key_index_mode = cpu_to_le32(0x6 << 4); + /* set tweak values. Should be the start lba */ sata_cmd.twk_val0 = cpu_to_le32((sata_cmd.sata_fis.lbal_exp << 24) | @@ -4657,31 +4664,31 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, phys_addr = ccb->ccb_dma_handle; sata_cmd.addr_low = lower_32_bits(phys_addr); sata_cmd.addr_high = upper_32_bits(phys_addr); - sata_cmd.esgl = cpu_to_le32(1 << 31); + sata_cmd.esgl = cpu_to_le32(1U << 31); } else if (task->num_scatter == 1) { u64 dma_addr = sg_dma_address(task->scatter); + sata_cmd.addr_low = lower_32_bits(dma_addr); sata_cmd.addr_high = upper_32_bits(dma_addr); sata_cmd.len = cpu_to_le32(task->total_xfer_len); sata_cmd.esgl = 0; + /* Check 4G Boundary */ - start_addr = cpu_to_le64(dma_addr); - end_addr = (start_addr + sata_cmd.len) - 1; - end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); - end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); + end_addr = dma_addr + le32_to_cpu(sata_cmd.len) - 1; + end_addr_low = lower_32_bits(end_addr); + end_addr_high = upper_32_bits(end_addr); if (end_addr_high != sata_cmd.addr_high) { pm8001_dbg(pm8001_ha, FAIL, "The sg list address start_addr=0x%016llx data_len=0x%xend_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", - start_addr, sata_cmd.len, + dma_addr, + le32_to_cpu(sata_cmd.len), end_addr_high, end_addr_low); pm8001_chip_make_sg(task->scatter, 1, ccb->buf_prd); phys_addr = ccb->ccb_dma_handle; - sata_cmd.addr_low = - lower_32_bits(phys_addr); - sata_cmd.addr_high = - upper_32_bits(phys_addr); - sata_cmd.esgl = cpu_to_le32(1 << 31); + sata_cmd.addr_low = lower_32_bits(phys_addr); + sata_cmd.addr_high = upper_32_bits(phys_addr); + sata_cmd.esgl = cpu_to_le32(1U << 31); } } else if (task->num_scatter == 0) { sata_cmd.addr_low = 0; @@ -4689,27 +4696,28 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, sata_cmd.len = cpu_to_le32(task->total_xfer_len); sata_cmd.esgl = 0; } + /* scsi cdb */ sata_cmd.atapi_scsi_cdb[0] = cpu_to_le32(((task->ata_task.atapi_packet[0]) | - (task->ata_task.atapi_packet[1] << 8) | - (task->ata_task.atapi_packet[2] << 16) | - (task->ata_task.atapi_packet[3] << 24))); + (task->ata_task.atapi_packet[1] << 8) | + (task->ata_task.atapi_packet[2] << 16) | + (task->ata_task.atapi_packet[3] << 24))); sata_cmd.atapi_scsi_cdb[1] = cpu_to_le32(((task->ata_task.atapi_packet[4]) | - (task->ata_task.atapi_packet[5] << 8) | - (task->ata_task.atapi_packet[6] << 16) | - (task->ata_task.atapi_packet[7] << 24))); + (task->ata_task.atapi_packet[5] << 8) | + (task->ata_task.atapi_packet[6] << 16) | + (task->ata_task.atapi_packet[7] << 24))); sata_cmd.atapi_scsi_cdb[2] = cpu_to_le32(((task->ata_task.atapi_packet[8]) | - (task->ata_task.atapi_packet[9] << 8) | - (task->ata_task.atapi_packet[10] << 16) | - (task->ata_task.atapi_packet[11] << 24))); + (task->ata_task.atapi_packet[9] << 8) | + (task->ata_task.atapi_packet[10] << 16) | + (task->ata_task.atapi_packet[11] << 24))); sata_cmd.atapi_scsi_cdb[3] = cpu_to_le32(((task->ata_task.atapi_packet[12]) | - (task->ata_task.atapi_packet[13] << 8) | - (task->ata_task.atapi_packet[14] << 16) | - (task->ata_task.atapi_packet[15] << 24))); + (task->ata_task.atapi_packet[13] << 8) | + (task->ata_task.atapi_packet[14] << 16) | + (task->ata_task.atapi_packet[15] << 24))); } /* Check for read log for failed drive and return */ From patchwork Sun Feb 20 03:17:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12752523 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 3FE76C433FE for ; Sun, 20 Feb 2022 03:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242899AbiBTDS7 (ORCPT ); Sat, 19 Feb 2022 22:18:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239782AbiBTDSw (ORCPT ); Sat, 19 Feb 2022 22:18:52 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B16B340CD for ; Sat, 19 Feb 2022 19:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327111; x=1676863111; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lVB2sM0qCfqo8mvvo1uohffxKjaC+Yh2JveklQXFsqs=; b=qqxjA9ThcGvs0yy6XCSk5n/GuKNSI4fHwJzlujwnIOSC2Lsj1ldai369 wp0KmvtRrMsrJD5Yzw6qZOEkCbp/xVmtbWeD0glsIux4l4eSpO8wlhnvn nMpgf/ol60ToVXprxiH/j/npWgzWpswKMSV0IMMLLxNo1+RxWC8LaEVBz 2Idxx76H9sBK53cRRih7NfkxmN6/YXtdksFQd1djV09pDCAbdvL9NPd/1 aTFxrgP4lP1/DsBH8FeMdO247jnuZuXxEm/e5nmxaoPxIe+6DkA0y+W7v x61vzer0XaQUuKsCbYk3ojG8zkkYxm4uboxB30HbrqQJsdKPu5kR0+HbT Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405763" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:31 +0800 IronPort-SDR: J2KJFKepD6Ub6fB191ErwJju0XgYKwk/oVIORnSIE9oIDAxuxC2abIxhq3n61DRLHjwBXUOxV9 shZFvvLilmHtDQi140QCkcs8FVMKRtyg0t3dwwRzjl9GafesFtyCNDz/KiApMaqnUnfuuNRyhJ 0+sBJkDlqdgHOvuQPFMmXefUNlDOTuMu9sc9zQn83bGFHXMTUbeO69XIub8q4fZrOu8oSQaZce VwGBtWQCJ6n3GE4saLrJSxoXEGV5azE3zNqVLKYNTsbpJDfSFbkvXf3p0ZNkuIzJf7z8zeU3J/ kCaclJI9Wje+ZmmIRCuYOeGC Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:07 -0800 IronPort-SDR: xVc3QIZe6tmgBUdYCI/ZE6AvwsILrXnLTTW+9au3dLxWAx2aPdfn9zctXPX1NKpg4S8qtPhhps 03OHZ1yAgP56Iy2x9p2i8BOp29B9nV+D1kk0i4zq37HulxPvcvEpa+wPbmorYRsthEPI+SI3Qr 8j+6aFJ3ODa8Etcb3s0yXkbdrLiezCFb8BkWV1UyxSGBvGuZw0P4IJA0di+jmR5iqJ+LCxMNXx rGvQbRJOUjP7SCOZ3KRZpbITO4D6VX/edEIroAjbA7M3Q5zeIfrfctV7XB6e1jp7yUBWOeOn50 lY4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1Vy00Dyvz1SVnx for ; Sat, 19 Feb 2022 19:18: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=1645327111; x=1647919112; bh=lVB2sM0qCfqo8mvvo1 uohffxKjaC+Yh2JveklQXFsqs=; b=gWeOvtA3Jbe5G3Y/O73r5lspqyUnGzMeYE sQcZ4Rxc8BKfnHuFj4PgtOvPZPz65OT0tC9L8lldS1AkB2WtS6JaZjsFj+tdz3rD QghAJ7TzXyR1+ygboWRHzIicwxof5s4LAh13zLKNoDgu3Ui9kRZDta1OL+LfejDr IA7QUIV7SQMslFuDcuEoE1XFUCRYUtr1ZQib/o/pidCgb8ytNpfUAEIHFnJsEMtg Ie6g5YoHH79paypLlVyOkiM2+bIhSwEooEzUz7MNnoAQXJG6Q6PvjxiM+rRa+dva IcWu339MXktoZmWloxHWrYrzrB51fq84BVjBCvw+9aYEEPtvOHhA== 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 OorrXS_lRvr8 for ; Sat, 19 Feb 2022 19:18: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 4K1Vxy2jwMz1Rvlx; Sat, 19 Feb 2022 19:18:30 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 12/31] scsi: pm8001: Fix use of struct set_phy_profile_req fields Date: Sun, 20 Feb 2022 12:17:51 +0900 Message-Id: <20220220031810.738362-13-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In mpi_set_phy_profile_req() and pm8001_set_phy_profile_single(), use cpu_to_le32() to initialize the ppc_phyid field of struct set_phy_profile_req. Furthermore, fix the definition of the reserved field of this structure to be an array of __le32, to match the use of cpu_to_le32() when assigning values. These changes remove several sparse type warnings. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 12 +++++++----- drivers/scsi/pm8001/pm80xx_hwi.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 1f3b01c70f24..60c305f987b5 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4970,12 +4970,13 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, pm8001_dbg(pm8001_ha, FAIL, "Invalid tag\n"); circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); - payload.ppc_phyid = (((operation & 0xF) << 8) | (phyid & 0xFF)); + payload.ppc_phyid = + cpu_to_le32(((operation & 0xF) << 8) | (phyid & 0xFF)); pm8001_dbg(pm8001_ha, INIT, " phy profile command for phy %x ,length is %d\n", - payload.ppc_phyid, length); + le32_to_cpu(payload.ppc_phyid), length); for (i = length; i < (length + PHY_DWORD_LENGTH - 1); i++) { - payload.reserved[j] = cpu_to_le32(*((u32 *)buf + i)); + payload.reserved[j] = cpu_to_le32(*((u32 *)buf + i)); j++; } rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, @@ -5015,8 +5016,9 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, opc = OPC_INB_SET_PHY_PROFILE; payload.tag = cpu_to_le32(tag); - payload.ppc_phyid = (((SAS_PHY_ANALOG_SETTINGS_PAGE & 0xF) << 8) - | (phy & 0xFF)); + payload.ppc_phyid = + cpu_to_le32(((SAS_PHY_ANALOG_SETTINGS_PAGE & 0xF) << 8) + | (phy & 0xFF)); for (i = 0; i < length; i++) payload.reserved[i] = cpu_to_le32(*(buf + i)); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h index c41ed039c92a..d66b49323d49 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.h +++ b/drivers/scsi/pm8001/pm80xx_hwi.h @@ -972,7 +972,7 @@ struct dek_mgmt_req { struct set_phy_profile_req { __le32 tag; __le32 ppc_phyid; - u32 reserved[29]; + __le32 reserved[29]; } __attribute__((packed, aligned(4))); /** From patchwork Sun Feb 20 03:17:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12752524 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 1F239C433EF for ; Sun, 20 Feb 2022 03:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243119AbiBTDTB (ORCPT ); Sat, 19 Feb 2022 22:19:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240322AbiBTDSy (ORCPT ); Sat, 19 Feb 2022 22:18:54 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE36340D0 for ; Sat, 19 Feb 2022 19:18: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=1645327113; x=1676863113; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+0OrtXq+6naR0bB1OGjcvN2Cz9hw+Zu3eTf+q2N6Z9w=; b=JgnamMF7pBxN9LkHDWkMZmYV1kyiH0a6rGFkRQsAwNuXlLTpMlahVjnM zwDNN3YX//lEi0RL0gk+yoEkzj9pJ9AH+lQ2VafZkdJzNPvKgOBElyjlj i6ICOYM1F2F1LvKu9cev+ZZVTa5003QjkVYdHkPutFylI9WOFzApq4eM9 Dj+O4fKexkhBlcNsakG0W4B6yZG4EGkVmLc7qotu3caQbynEv7KlTGqlP lzKc8FcfdIlfeIskAW8iTidr3I+5alq1ileDSGC5ve7h9BeHuh7jsUBSk 72wOmhkNoStUVSrEpHmzr7Y50JBHyZ5IBB73F9oitgtCLyLc3hp/YFqGk Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405769" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:32 +0800 IronPort-SDR: w6T7ipiOkPf2YQPQEyL3yalnr5FMTA//Ejp0MTETzVm3ApIPQuUF0qSJjU/WAzfaReZFQe6Rvh cd7gob3zTCoFcFwKdcvilkX8jEx5cc4QcK4ymumioyjKvl8/RGJQBYN2CjbvKMbTj+6L3sFIXX +VRGDKZL19INoDfIDLEQUq5Hexc4EFy3vHzxxdChNoAPDaPrTd1Vj2dYd6It9aOX1hIhHglQUj CyNNLInlVVuKg1vjUuc0Fa0JzaU5VFE19DJVSnibBlQmglW2XcVLJ1E48PPLuNZ2EO90j3zdvQ tRvEcCnNb9K5l58VsEz10DS4 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:09 -0800 IronPort-SDR: zoaMauOO5/hV7IDeMBLKKkkwm80DeD1nxj4764X4it6OpxyA6gFkXtJhbDn1ZDorxYz7ywfZ72 SV+yNffCqNlSINIov0DtLx350TTFPxoRN9kJ/QA38U2pruFt//YYdv35DhRHWw8qg7axRdND0O H1dRamBQlCrysvXDRQN+Z/XCMyiW/5ZBej5e8VUpVHkC28mTeqsLE35cNPjvcM4d8fB8fNPGtj T+lUudupfpE7QemIqFm1xeQIfHxNWjmdXmWYu8wdj4bQ8ZMbhRxNBh4f6fCr/zvMJfDDBHr55A x00= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1Vy139hBz1SVp4 for ; Sat, 19 Feb 2022 19:18: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=1645327112; x=1647919113; bh=+0OrtXq+6naR0bB1OG jcvN2Cz9hw+Zu3eTf+q2N6Z9w=; b=E+aDquTbyWFg4tSJAawYa03gzJgEx3/yfH gF2Y6jaACTTdiROff2o59RTpt2uvwmmlDx7HzF0Hfr9V7W+8nvxa1B5tO0SYPvJN nB5CFk/5qq+ta27ABN8uH9PyO4mf+/t7QkU0Ma/IXtglzmIm918LmMtz/lHtM/dr TISxie+qvB71PmHHoPEdAorIiLx8+txL1/AkCzAEoCn51XpkhYFbGGkZ+TDy/VXi lljvGimtOTyLiqZrDY8ZpA4l66JZ508NUkyM1eKk7Gf0hmyD6swUEnmhO2cg08n9 BRru+4tFwA64KrFqsNjwzIUZCQaboAnQpMe3KoWz5KSdilE9mgfA== 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 sbhdRSgDuyT6 for ; Sat, 19 Feb 2022 19:18: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 4K1Vxz6DRHz1Rwrw; Sat, 19 Feb 2022 19:18:31 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 13/31] scsi: pm8001: Remove local variable in pm8001_pci_resume() Date: Sun, 20 Feb 2022 12:17:52 +0900 Message-Id: <20220220031810.738362-14-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm8001_pci_resume(), the use of the u32 type for the local variable device_state causes a sparse warning: warning: incorrect type in assignment (different base types) expected unsigned int [usertype] device_state got restricted pci_power_t [usertype] current_state Since this variable is used only once in the function, remove it and use pdev->current_state directly. While at it, also add a blank line after the last local variable declaration. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index d7b95ad4533e..381105286953 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1336,13 +1336,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 Sun Feb 20 03:17:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12752525 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 629A7C433F5 for ; Sun, 20 Feb 2022 03:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243371AbiBTDTC (ORCPT ); Sat, 19 Feb 2022 22:19:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240614AbiBTDSz (ORCPT ); Sat, 19 Feb 2022 22:18:55 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C17340D1 for ; Sat, 19 Feb 2022 19:18:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327114; x=1676863114; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JPPcNbEYri1ah8CSIxH5TG0sGDMY7KcxgAntH1kk7SY=; b=Hjcihd3DMciL0eZBYjVQ7AVgQkxA2emhCfufUWUjLREFbPVl9AlK4w1S 1Q+G+gEK0BcMy8iXpdGCYHKaFRUjp6l9qjcI1WUb81scd+spiiGDwj0qm vkcZEhzxwkijj6MgD9i9mci1OXiRGwlKWDo1ZJ8GNJKN4Q09QOf5748ok gj6e/yLPF6QlaeCBd7/9dpC/NwLhaLJeJSVjbHUc87rUjY9SqTeY9H+Fk 80COeyhXiDWqh6v1ZTARrAEA4vRxlTyRlHFhZ8gvzh5psEEcclU98jpke YxLxhgIRw74+Tc5+iS20LJeNRy1zhER+G2H92Pofp2EamiI6WYCtUE0rN g==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405772" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:34 +0800 IronPort-SDR: BYFzLeNlCL1wjLYMSgLpdPbG0FK4tkZGRVkl2gYHcnNkMWgMLpZwEWGdxmhKC5sIC7JyZIcXMy Y0BO1YCQ7h1L3fv7JJo9ddsNu590UwGcvoa3WDacCWfWcbRH4InOb2fvmhVcNJg/pDo4X0iraq wTf1s6U2LlDMR7/+CKeDUyfDWsflKmaGcEYXMpwBqeQZhsLuVb9t5umWE45gvgEl4WG6xkU7Hh LUZKtLW/BNIPnqaB+u4/AHcQ5XSWkY+/LwT7Bwm2pzWAzjcS3a4FzJpeGFItjDATW5UQ45Q2lL U77ZM5aQ/1IAlnAl7llrimGH Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:10 -0800 IronPort-SDR: N/p2XmbMv0UE1gQvmk0sQXFqm16tegZKy1t07hiX7lPp98Uc/mX7hx2u9NhQjKc/0FIBdiZ86l pK7kJRJI7C8Oje3we47Ilpdblr+tD1BqqckzgHXYTJw6IgHXYX/Q1oSl1hKxsjTSY0yeZR2Fjr gy68BKeqxjnxiGaeyFjBsC+7iI12XzNy0/N+KvncGUGn0Bt1oDApVlEo5qsClvgXZSCYsI/2t4 aJWiqOdz4sBiUNhJOolxPAZPVAkzUC6W5Xo6BxyoPuw/1okGfVTX3D4ifvNsuvWfIwCYwfY0/K 8Rc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1Vy26Qpqz1SVnx for ; Sat, 19 Feb 2022 19:18: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=1645327114; x=1647919115; bh=JPPcNbEYri1ah8CSIx H5TG0sGDMY7KcxgAntH1kk7SY=; b=ZCHpomEQJpLq5oRWvDhEzYdKRH+VR0UO5X HXXjPnFiLT5ill4I5C5q5M+x1nNeRSRQEK6bHfvkGh50ry9FJASvA/NSK9vydDRL sZY+cQeI4gB8+Lu0p4aUSvXMeMtqgj8ZzglR3sTvMcbYMO97Q2wtuBKtDo9ToRc9 3vv1N94kP0Xg/UY6hxB8xhrikvgk5Ia7ESdoYZH3gF2gbThx0Q0ACL/pSN6cBo2+ bhcDCSL5sd/DrlDHkmHOL118lXCnzY34CB0haTd+VQQV1JYeiBN/K02Oc8/I1iTK bl9WTLDNJjmI0l4xIar4bzcJEa9zsMVEYMMCn8s5rc0Mq/QAg9MQ== 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 8XV060PDCpCJ for ; Sat, 19 Feb 2022 19:18: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 4K1Vy121kSz1Rvlx; Sat, 19 Feb 2022 19:18:33 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 14/31] scsi: pm8001: Fix NCQ NON DATA command task initialization Date: Sun, 20 Feb 2022 12:17:53 +0900 Message-Id: <20220220031810.738362-15-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In the pm8001_chip_sata_req() and pm80xx_chip_sata_req() functions, all tasks with a DMA direction of DMA_NONE (no data transfer) are initialized using the ATAP value 0x04. However, NCQ NON DATA commands, while being DMA_NONE commands are NCQ commands and need to be initialized using the value 0x07 for ATAP, similarly to other NCQ commands. Make sure that NCQ NON DATA command tasks are initialized similarly to other NCQ commands by also testing the task "use_ncq" field in addition to the DMA direction. While at it, reorganize the code into a chain of if - else if - else to avoid useless affectations and debug messages. Fixes: dbf9bfe61571 ("[SCSI] pm8001: add SAS/SATA HBA driver") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 14 +++++++------- drivers/scsi/pm8001/pm80xx_hwi.c | 13 ++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index d80b48e0e41b..c680baa5ef24 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4265,22 +4265,22 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, u32 opc = OPC_INB_SATA_HOST_OPSTART; memset(&sata_cmd, 0, sizeof(sata_cmd)); circularQ = &pm8001_ha->inbnd_q_tbl[0]; - if (task->data_dir == DMA_NONE) { + + if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { ATAP = 0x04; /* no data*/ pm8001_dbg(pm8001_ha, IO, "no data\n"); } else if (likely(!task->ata_task.device_control_reg_update)) { - if (task->ata_task.dma_xfer) { + if (task->ata_task.use_ncq && + dev->sata_dev.class != ATA_DEV_ATAPI) { + ATAP = 0x07; /* FPDMA */ + pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); + } else if (task->ata_task.dma_xfer) { ATAP = 0x06; /* DMA */ pm8001_dbg(pm8001_ha, IO, "DMA\n"); } else { ATAP = 0x05; /* PIO*/ pm8001_dbg(pm8001_ha, IO, "PIO\n"); } - if (task->ata_task.use_ncq && - dev->sata_dev.class != ATA_DEV_ATAPI) { - ATAP = 0x07; /* FPDMA */ - pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); - } } if (task->ata_task.use_ncq && pm8001_get_ncq_tag(task, &hdr_tag)) { task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 60c305f987b5..3deb89b11d2f 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4546,22 +4546,21 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num); circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; - if (task->data_dir == DMA_NONE) { + if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { ATAP = 0x04; /* no data*/ pm8001_dbg(pm8001_ha, IO, "no data\n"); } else if (likely(!task->ata_task.device_control_reg_update)) { - if (task->ata_task.dma_xfer) { + if (task->ata_task.use_ncq && + dev->sata_dev.class != ATA_DEV_ATAPI) { + ATAP = 0x07; /* FPDMA */ + pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); + } else if (task->ata_task.dma_xfer) { ATAP = 0x06; /* DMA */ pm8001_dbg(pm8001_ha, IO, "DMA\n"); } else { ATAP = 0x05; /* PIO*/ pm8001_dbg(pm8001_ha, IO, "PIO\n"); } - if (task->ata_task.use_ncq && - dev->sata_dev.class != ATA_DEV_ATAPI) { - ATAP = 0x07; /* FPDMA */ - pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); - } } if (task->ata_task.use_ncq && pm8001_get_ncq_tag(task, &hdr_tag)) { task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); From patchwork Sun Feb 20 03:17:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12752526 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 B9C5BC433F5 for ; Sun, 20 Feb 2022 03:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243373AbiBTDTD (ORCPT ); Sat, 19 Feb 2022 22:19:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241170AbiBTDS4 (ORCPT ); Sat, 19 Feb 2022 22:18:56 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4EE8340D2 for ; Sat, 19 Feb 2022 19:18: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=1645327115; x=1676863115; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+9fKbn8w8UkJ7eV+ZqVWq14jYorsWkfFH+qUx4KFby0=; b=FKqG6mOSQjvH9iFZRvl43ksYNUu5hRQf/iHWuilRyLHTJCKBw3j8nBAP oPNbC+1GnRVSxcWSuZVG1zSa+P1qvaPqbqYj9quZPbz6zL/47yTEdtaSx ltAS324bXiValTSrTBj/jffpHQK9byZlgHQg6PK+LXV9Oqrq7jU9REDJI idyQ78Ya1MDwH3+xYn4aJHkCIyZZDYnKVTbTuDq3R+xvIf15lok8rkkGG r5JGTlmXm9ibXHtpxcWUAX8nsGYdPgZHC1i6AqTW0LxGQyCWtFPOC1C03 RnlsJTH/lehTBVPw9BX9tgkhecAwiXbwq1glUAGa0v+PJJdEPk0h2H1Li w==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405776" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:35 +0800 IronPort-SDR: Y/Rkh6kCueeraGzObAD9alTb7h6VpknEGCgv8mx1dteot7xxDbOumoe0RXHFqGU6ksOTfL7rK8 /Iw2EXfWSYAXonN8hEahfGRlZ5y+bNiOU07e4Tj5v1czyX+YTD51C0EUAYSwIfvWBH/L/1Hydx MOUEdqI3ZyM0OynmzfKh/c3zwYyoUHoQBzfrDjxJ75xTgITEnz1yG3vXJt4AqJLovxGgaO5bSv t9ss3ND1YmaY3l9p1tg7butzQWkrepx5QMQGvpJpE6GYUlEJaI+kuyYhRT+lTdV+fo0M1J7r9r CRDXZMCbGfAYBuMZASRuKUoJ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:12 -0800 IronPort-SDR: np/i3tZG+n4jmcSCLwikxzth/CBZRw7cMRe3CK4NFQpegjU7h+ytYQu9l2/b2MLPVvvdcUYsjF 0JluPulbmsOSiN9QtkQcDwn+UXuQnCXqU/3Ltja39h9wZijyPaZ1bJnesdd1GvfM9dLIQts5bK y131mqhAXP7EaxnHBXGLiUp6mkmyy0B9aBw9FirCIMnfA/NBBH1oZlcQ628n5AxE74wd82yJp3 bKiPa5/yQOUNapypW+gZgHWAaDVUjvTu74mCJ9lv1L9CSmtL1S2xxeaKLfvcYuPn1BJbs1vdeG tZA= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1Vy42LTgz1SVp3 for ; Sat, 19 Feb 2022 19:18: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=1645327115; x=1647919116; bh=+9fKbn8w8UkJ7eV+Zq VWq14jYorsWkfFH+qUx4KFby0=; b=AgHzIWuji9XarDOHGqHmsyZSEH/IVufdA7 pOrHMa3BbnDSVAifMiLfmoGLfDSgvWczZEYtOTLFQI5A267DslldUyDEYtoE1aXF ITBXXXEgpMqjmN6z/guyB5dycVBeYqLG1jcT2yZVCzykkMPC57QdaBqQxBoISfIU dhhJSRkqGqs08XD5KxG2eV+sJXWGgaA+TSST/gnJGxXLiVfpNEmr2JSybEYtubrd szZ5riwKhPiTOdISshFH2v/pvCKEVRuLnZSOlCbj44lTNJ6PNYKi518h1NmEz420 2EiwvXApQZde20j4tEf1fls/I4Bvd/lEUPFr7rt/ndKkr0MkAPXw== 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 L50bCx4XFiKf for ; Sat, 19 Feb 2022 19:18: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 4K1Vy2564fz1Rwrw; Sat, 19 Feb 2022 19:18:34 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 15/31] scsi: pm8001: Fix NCQ NON DATA command completion handling Date: Sun, 20 Feb 2022 12:17:54 +0900 Message-Id: <20220220031810.738362-16-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org NCQ NON DATA is an NCQ command with the DMA_NONE DMA direction and so a register-device-to-host-FIS response is expected for it. However, for an IO_SUCCESS case, mpi_sata_completion() expects a set-device-bits-FIS for any ata task with an use_ncq field true, which includes NCQ NON DATA commands. Fix this to correctly treat NCQ NON DATA commands as non-data by also testing for the DMA_NONE DMA direction. Fixes: dbf9bfe61571 ("[SCSI] pm8001: add SAS/SATA HBA driver") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 3 ++- drivers/scsi/pm8001/pm80xx_hwi.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index c680baa5ef24..35eda16a2743 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -2415,7 +2415,8 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) len = sizeof(struct pio_setup_fis); pm8001_dbg(pm8001_ha, IO, "PIO read len = %d\n", len); - } else if (t->ata_task.use_ncq) { + } else if (t->ata_task.use_ncq && + t->data_dir != DMA_NONE) { len = sizeof(struct set_dev_bits_fis); pm8001_dbg(pm8001_ha, IO, "FPDMA len = %d\n", len); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 3deb89b11d2f..ac2178a13e4c 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -2507,7 +2507,8 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, len = sizeof(struct pio_setup_fis); pm8001_dbg(pm8001_ha, IO, "PIO read len = %d\n", len); - } else if (t->ata_task.use_ncq) { + } else if (t->ata_task.use_ncq && + t->data_dir != DMA_NONE) { len = sizeof(struct set_dev_bits_fis); pm8001_dbg(pm8001_ha, IO, "FPDMA len = %d\n", len); From patchwork Sun Feb 20 03:17:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12752527 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 26F4AC433EF for ; Sun, 20 Feb 2022 03:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243381AbiBTDTE (ORCPT ); Sat, 19 Feb 2022 22:19:04 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242505AbiBTDS6 (ORCPT ); Sat, 19 Feb 2022 22:18:58 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A09B340D3 for ; Sat, 19 Feb 2022 19:18: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=1645327117; x=1676863117; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nyw6ZF9z51vXsM5UOyHqddSYZgT8VVrFBo/jONyktvU=; b=D2MvuhWcCWDQfB21xVRX2Okrd5kckVO0dqEKA5FDIoT01O1L8jFh1p5+ 2nB7cO3h4J2AAAsZ2qdf+N93lbyzv382/N+6M5JD0+VduE9nrfde451Mz uSpJoQlRJJHgnJUwtprZiZ3C+ZlLXhLdMIrqz2j3GYjskc8rBkVklWzY8 VGoN6j/pHggkLo6b9E9lob9I98GOTiLGY3Icy59uulYp8Pq5Qz4F0seV1 8EJNPJ9CTh4QI/fje6wkRWCuV/qVfpV/HK/tb3pD3S0YYnCimOUUjuJjO ciMDTwRiEnGbublSo4yLaKVX0hGgXJ4WbjsOLhcSRMhhG6kjsoMtC7VSh w==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405779" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:37 +0800 IronPort-SDR: eb1XbJQ2T6CKDlszDtOMe6RXcWwBihXhulTXlK4RIMi6FPH3PbozVzM7JCxk5q8zOAkq8+7S9V f5LL4HTV+Hcl6CATd2gZDA40RKIvWb6HwSuM//pAcTBhyHu9R1mZtuIWlPR3n50MR0PsQDr043 aBHCxkMqq+o+PCWOaPsiUvW7dwJ3YowcA8PqvDqLFMnpiyTwy5V0SQIbijLhieBvceLnSLhdUx dPuEpndcyf1o26zx4Y4sokOErW63vuFIYbuD4o3E5E+oy83QcV3dViyrB4FC7agBDV0ON+qrQC v6BRlmN0O67w2VAiP6mgQ3Up Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:13 -0800 IronPort-SDR: gT2cKM3C4BAc5qTDkgqVJVmnqdfiQw0q/EqJ6J4LlUgUL23r4W0GLjOGxsEc/K/RPcjsnt57/I 5mMgsH2d4LR/0GKpDXgUK5U9Y4Yro1ck5Kg6kmcOICOC1FeEHfQpsowlcoswR41EWdQPusg3Xl AN4smYfawRlv0xJEUBZ6KYe77bMqp8QqtLKcy9cGosu2s7HGTcGNb+A1hBjp8vPM3qnOGt2bT+ PvamqfV/ck6TzXPMM3Yg7YUY8erIbvSPODuEt0/GvsFwHmui3o7XrABOIZxxp8ftccRWiK+y/R 2iQ= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1Vy55rz5z1SVp3 for ; Sat, 19 Feb 2022 19:18:37 -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=1645327117; x=1647919118; bh=nyw6ZF9z51vXsM5UOy HqddSYZgT8VVrFBo/jONyktvU=; b=krv7gxHcc+bqBh8TwR2pRU4uHkxhUdO/ZN 6+U61mKp5wIwY8xtYt8o5kJrtCgMFkPM4j7UMkO7tlGQPNBW9pFLPK+/ViaHg07u 3VBPPqz5sDiHJpBiPk62+LdPRbQH6qmWJVOHHGFvH3QaBfaxyKf/fJvgqxmCsYQN RpX0eQDa7zQfiBUTVlcj/v4SU9k/97BbuvMAnaJpR0aWUAyVhsXH9EADkUENStj1 5NUflcZD83FPBZuU2F5kxQaSNRINwJu5GbUDCj7tf9AVbbd0aFQs/OsCaa4XXcum hEitbd86jK7xFeXrPCkDmjo69seNFFjio6IIVdTq7Rkd7A+c4Xkg== 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 C0a6-NK6M6lZ for ; Sat, 19 Feb 2022 19:18: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 4K1Vy40lt9z1Rvlx; Sat, 19 Feb 2022 19:18:35 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 16/31] scsi: pm8001: Fix abort all task initialization Date: Sun, 20 Feb 2022 12:17:55 +0900 Message-Id: <20220220031810.738362-17-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm80xx_send_abort_all(), the n_elem field of the ccb used is not initialized to 0. This missing initialization sometimes lead to the task completion path seeing the ccb with a non-zero n_elem resulting in the execution of invalid dma_unmap_sg() calls in pm8001_ccb_task_free(), causing a crash such as: [ 197.676341] RIP: 0010:iommu_dma_unmap_sg+0x6d/0x280 [ 197.700204] RSP: 0018:ffff889bbcf89c88 EFLAGS: 00010012 [ 197.705485] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff83d0bda0 [ 197.712687] RDX: 0000000000000002 RSI: 0000000000000000 RDI: ffff88810dffc0d0 [ 197.719887] RBP: 0000000000000000 R08: 0000000000000000 R09: ffff8881c790098b [ 197.727089] R10: ffffed1038f20131 R11: 0000000000000001 R12: 0000000000000000 [ 197.734296] R13: ffff88810dffc0d0 R14: 0000000000000010 R15: 0000000000000000 [ 197.741493] FS: 0000000000000000(0000) GS:ffff889bbcf80000(0000) knlGS:0000000000000000 [ 197.749659] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 197.755459] CR2: 00007f16c1b42734 CR3: 0000000004814000 CR4: 0000000000350ee0 [ 197.762656] Call Trace: [ 197.765127] [ 197.767162] pm8001_ccb_task_free+0x5f1/0x820 [pm80xx] [ 197.772364] ? do_raw_spin_unlock+0x54/0x220 [ 197.776680] pm8001_mpi_task_abort_resp+0x2ce/0x4f0 [pm80xx] [ 197.782406] process_oq+0xe85/0x7890 [pm80xx] [ 197.786817] ? lock_acquire+0x194/0x490 [ 197.790697] ? handle_irq_event+0x10e/0x1b0 [ 197.794920] ? mpi_sata_completion+0x2d70/0x2d70 [pm80xx] [ 197.800378] ? __wake_up_bit+0x100/0x100 [ 197.804340] ? lock_is_held_type+0x98/0x110 [ 197.808565] pm80xx_chip_isr+0x94/0x130 [pm80xx] [ 197.813243] tasklet_action_common.constprop.0+0x24b/0x2f0 [ 197.818785] __do_softirq+0x1b5/0x82d [ 197.822485] ? do_raw_spin_unlock+0x54/0x220 [ 197.826799] __irq_exit_rcu+0x17e/0x1e0 [ 197.830678] irq_exit_rcu+0xa/0x20 [ 197.834114] common_interrupt+0x78/0x90 [ 197.840051] [ 197.844236] [ 197.848397] asm_common_interrupt+0x1e/0x40 Avoid this issue by always initializing the ccb n_elem field to 0 in pm8001_send_abort_all(), pm8001_send_read_log() and pm80xx_send_abort_all(). Fixes: c6b9ef5779c3 ("[SCSI] pm80xx: NCQ error handling changes") Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 2 ++ drivers/scsi/pm8001/pm80xx_hwi.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 35eda16a2743..cfeefdf26f5d 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1787,6 +1787,7 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; + ccb->n_elem = 0; circularQ = &pm8001_ha->inbnd_q_tbl[0]; @@ -1848,6 +1849,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; + ccb->n_elem = 0; pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index ac2178a13e4c..8fd38e54f07c 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1800,6 +1800,7 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; + ccb->n_elem = 0; circularQ = &pm8001_ha->inbnd_q_tbl[0]; From patchwork Sun Feb 20 03:17:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12752528 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 720B2C433EF for ; Sun, 20 Feb 2022 03:18:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243399AbiBTDTG (ORCPT ); Sat, 19 Feb 2022 22:19:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242894AbiBTDS7 (ORCPT ); Sat, 19 Feb 2022 22:18:59 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEDE7340CD for ; Sat, 19 Feb 2022 19:18: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=1645327118; x=1676863118; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aFrF4rJ6wByeGWngQJkFybPJUoSWqcmYvM759TiDF+A=; b=OV+1oL78fpMUAe89hScN9Rgu+dyQjbhsOj/9ogl7mDLzKpUxCRgN+agR PewUXQeVIzornocxKrNlp0AAcdTAFOTcs543FUl47Y7mLmtolK5b0rXTv fQTY9g3kapON6butA6cPTagtVmWqAwL7QnCAsLOef84nwqJx8VQ737Eb8 Lw+or00yOOw5bzHhANr6cnbHTTJR+OO3n3biEKWffBmPc0/MYSyAgBa2D XgaoUyJfCOwCxl62yISLed+5FWugHr/sru4yP6bVnd+Dcfa2EYPLDPAIA NQPECMpHoiQMScSorU5m/xw6xWpbqOG6UxAa3Aywa3ym8QbBLWtjj+VUm w==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405782" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:38 +0800 IronPort-SDR: j5aSI1t+5CC/QEYivafgiS0WZlqKQzV1IAOLO1ZQ1v/yq6IHAK1S9RhJEs1kPkO1lNdkE20gL7 VAXU8KHMHbU89nSWLDbc0UpdQOolSEwe57wCV5fW+/19UHBNoueXTxqxrsjC97R4QDU1zbdm2p DzA30MqUIXXseBaPA3FZQ55IXu4py4FsR+ue8pWxqKiADjg6Zqny73yiTggwMhXvtfDSdRKjz0 zJv7MwZWTkZ3T7VAQDaUnzOqLhB4GdEeUd5QZrDqedNCDe1pPyZzqi2/3G4t26T+Jx53MIE085 9/Y2o24NolZ0Ws8+/U3a5yte Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:15 -0800 IronPort-SDR: uZ7uMddqGmyY08X9Q4EzODOPHQcsPfBxeEBMTRsjbUy3Lh4zqmqDYZ9RVySHUOZVckQFzeyIRJ 6pPDFRsy9Rs4HseIN4VZNVY0KVAANUjh6lMwXcqZFyP5O/xPEicCtfxaKRJrSZRqodfzB9eY5B bMuBVO9xgZB6NXpmlhHBNv2YWN6JD/8URpdgvQqIfsk+3H5LvQOSbJ/YPr8eQcTEpyVbifzeF/ 6pbPT744XDM5M3niDZIHeRaYfz/dW9LsGOx8ZHWzUlwax+hth7ShkodffABiMTXJt4tb8N8VPA UvI= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1Vy70zKRz1SVp0 for ; Sat, 19 Feb 2022 19:18: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=1645327118; x=1647919119; bh=aFrF4rJ6wByeGWngQJ kFybPJUoSWqcmYvM759TiDF+A=; b=gwMUfA/DbdWs4VFVI5eJooCdgwjzxNUsaF N43SEryvyqvNOZl2xXkDlQPqLQSTclTUzi7QFZkmOoM1SlqONhRkUTXBpCVT+kl9 Z9+vh3u4PEE3/TAyAi4/xRmYrBIr/w5WykkZZb1ONhHLosrOSZhyqUnGCjEWOVby Qw/Dui0X4vQtFAoO2l/05G6xDE6H2IPOzSJnXIg1aaG/7XWi39veFTUx+nIIeQ/W 7Je1+tt0WaN6e3d0sL0K/PfZ1oi8E37FJi9wnpg+dZVdGEiZyU/tR4vvOLKJHJ8Z LTRe8CgWO+rcqiiPGztvIFS4QWTNmiMN+sCdFYrBDFBO2QzUPfow== 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 OZOJM7c-wZ-b for ; Sat, 19 Feb 2022 19:18: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 4K1Vy53Dfrz1Rwrw; Sat, 19 Feb 2022 19:18:37 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 17/31] scsi: pm8001: Fix pm8001_tag_alloc() failures handling Date: Sun, 20 Feb 2022 12:17:56 +0900 Message-Id: <20220220031810.738362-18-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In mpi_set_phy_profile_req() and in pm8001_set_phy_profile_single(), if pm8001_tag_alloc() fails to allocate a new tag, a warning message is issued but the uninitialized tag variable is still used to build a command. Avoid this by returning early in case of tag allocation failure. Also make sure to always return the error code returned by pm8001_tag_alloc() when this function fails instead of an arbitrary value. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm80xx_hwi.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 8fd38e54f07c..76260d06b6be 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1191,7 +1191,7 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) memset(&payload, 0, sizeof(struct set_ctrl_cfg_req)); rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) - return -1; + return rc; circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); @@ -1240,7 +1240,7 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) - return -1; + return rc; circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); @@ -1398,7 +1398,7 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) memset(&payload, 0, sizeof(struct kek_mgmt_req)); rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) - return -1; + return rc; circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); @@ -4967,8 +4967,11 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, memset(&payload, 0, sizeof(payload)); rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) + if (rc) { pm8001_dbg(pm8001_ha, FAIL, "Invalid tag\n"); + return; + } + circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); payload.ppc_phyid = @@ -5010,8 +5013,10 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, memset(&payload, 0, sizeof(payload)); rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) + if (rc) { pm8001_dbg(pm8001_ha, INIT, "Invalid tag\n"); + return; + } circularQ = &pm8001_ha->inbnd_q_tbl[0]; opc = OPC_INB_SET_PHY_PROFILE; From patchwork Sun Feb 20 03:17:57 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: 12752529 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 D6E60C433FE for ; Sun, 20 Feb 2022 03:18:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243408AbiBTDTJ (ORCPT ); Sat, 19 Feb 2022 22:19:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243335AbiBTDTB (ORCPT ); Sat, 19 Feb 2022 22:19:01 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38618340D0 for ; Sat, 19 Feb 2022 19:18: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=1645327120; x=1676863120; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bEKyvJPR+/aaT0vvGkpCE94GOQCxPwoiIcR1hUfldWU=; b=MV+IesEb0YMPJOsbdwkRjn/W8D7ez29u1Mtz+LNh2Y9zpBD6g0Ma2t/d Crc5wZ2EVlaNh/mmn+TwWTvElicBVj9b6PFgQPu5MtFFKoCBRTr7PfB2u s2l6utTxapE1VGSJsLMQu6KNRu/YsrGcwX+ISpF9F03/XxT8uxu5h16pY UK12bple6fxvQ/CWDq2y/9XDIo4v4K32bHFu1YKh51rHLPiTReU1Ow1hw +2XESDprodX19yO3tuJETZxDp7mJqh03EO+lJZnk3gonjWs2u0IYuvwFG BHWaQJG9ZDhb9hYUcNzOS1df+6yq/R5nWFGy/Qwip8kU/f3ofQcvAnb+n Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405785" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:40 +0800 IronPort-SDR: ILBbuELqpCp+xJqwFBnYt+BFtCWGnQkff42jWeP2GeRpbQTKbI+54pfNIpQ+I92Lumi4iZub73 WtaDiww95mvIqphCvLdzMiK/OFKMOiRMPN3CrtIToi05mihD2Qj6HekpfKAKIuF8+evxJFS5s2 3drW0lz5/IeVhK1SH3EOsHdgSuaMtjqXMo96Md102NMOvrr3jfEn27XBIDkmArTb5fuqMcWnH+ hctoDMsuyawgoLMH3WQ97i3QQ4Owwni4qd46B6bLwgw/S52TJt1m2X55tkmbadRU92sZ3eYWfu p3PkbGbNFN5DFyDxhxSw0DIf Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:16 -0800 IronPort-SDR: IfeGivujH583M5RD8lLX6LNoAucE6NyhJCawFV310ghLvCzEoVZIJVx7iSsHdQIX3Bh0x84hJ0 PKNIyFDr3grq+IDi9/XRzlQUoaAPvmRip3TfFSFMpYnGMRfZoaLaigwxm5W119yQoae6TDGbVn lWh+GWeLNAPKl4SsnxlsH9HzGvuAO7s4YVqxWl5ZwB5Nz0V5vUux303116Wa1f9COPGpJqurvo OIsi73ejeD5GHfDLd23z7J4qcApLDy9e4N9/0uv+Dq8xs106ZHSpA4MnBWnRzzuoSw/fqkqBR2 EG8= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1Vy83nMKz1SVp4 for ; Sat, 19 Feb 2022 19:18: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=1645327120; x=1647919121; bh=bEKyvJPR+/aaT0vvGk pCE94GOQCxPwoiIcR1hUfldWU=; b=CbwMWPh5jXpAUgmEZqNliqCrs8vVZNEfgL hkOowVvxnBFUqHATMFOO2KTqFxA9iUG+6BMJBLgJrBIwrvj3oxWe+92R5ADXNdzx XhbDpsJAqY/Ie7m/1uGj3lzU0NidPTqtWQ6fsug+N2l3MYlkvvycnf43wFhKtsAW elgHsY5VraNByQJ54GVAFWJYR2U7D0VhgUE8SCoPOcVNeaPJ83JtY6AL4H8rZaVI gAqlD9eDumQEp3RlAOjKdZvLFdXzat0AZ9gDUsKkEMAi7tQEf7HGhsKupj8KnnbC nI4U1PZ4LZiPG6hnt2gi8oUfvxAgBq/N56+wyP3MJeRdo/wGB3TQ== 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 fIrXij0goZcO for ; Sat, 19 Feb 2022 19:18: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 4K1Vy672Wwz1Rvlx; Sat, 19 Feb 2022 19:18:38 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 18/31] scsi: pm8001: Fix pm8001_mpi_task_abort_resp() Date: Sun, 20 Feb 2022 12:17:57 +0900 Message-Id: <20220220031810.738362-19-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The call to pm8001_ccb_task_free() at the end of pm8001_mpi_task_abort_resp() already frees the ccb tag. So when the device NCQ_ABORT_ALL_FLAG is set, the tag should not be freed again. Also change the hardcoded 0xBFFFFFFF value to ~NCQ_ABORT_ALL_FLAG as it ought to be. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index cfeefdf26f5d..be57b9ae5486 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -3700,12 +3700,11 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) mb(); if (pm8001_dev->id & NCQ_ABORT_ALL_FLAG) { - pm8001_tag_free(pm8001_ha, tag); sas_free_task(t); - /* clear the flag */ - pm8001_dev->id &= 0xBFFFFFFF; - } else + pm8001_dev->id &= ~NCQ_ABORT_ALL_FLAG; + } else { t->task_done(t); + } return 0; } From patchwork Sun Feb 20 03:17:58 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: 12752530 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 C7C10C433F5 for ; Sun, 20 Feb 2022 03:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243413AbiBTDTL (ORCPT ); Sat, 19 Feb 2022 22:19:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240614AbiBTDTD (ORCPT ); Sat, 19 Feb 2022 22:19:03 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17226340CD for ; Sat, 19 Feb 2022 19:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1645327122; x=1676863122; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I/9M3iBe0UPPyMeEFV/Y0UfCTDQKGPaDwzMHmZnBLAU=; b=KNx4xHQQhiDJaWznC1NcDt51L6o6M7lD2DWNU2uPeeq++fm+mtLFfmVk eYKKl0ILnXdVXItGjquWrXaXfa6NGy72EEa7dl7Hbd8x/U5YH1NUcWmkU R4RlvC64zkdIKlaiz7XGkbj71oh5ssbOPkRV1UfIA6GZmuF3+mWIKXlpn bV1IsZkYrLMcD/EVqE+Zc2uEnxlmpheosm6GLGtTr0/sC4ms8bhfpBGwC LCf0VWlPf4261ALp1lF+Ooq4r2ABygEeJqavN8r3a1bY3IrzRZEXAxp7G DxXulMwo+ZYCB6W++cFEOiLyEvb5nKLPI7DX+9FFQnQzdgpwLe+geV4re A==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405789" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:42 +0800 IronPort-SDR: PbFvW/gQioto8FGDZXMIK4XJg/6zFyCWZGdQXA8JEla+0uDpKttsnm0YafdkOIc5zAti/n7DSZ 7IVQLpIAnTgahSkD52U+bZRuL5e5tx6fUdOvT6hLHpMXlGgsqHxYjmPCyGG8M094RS1g/+PM4+ pXf5XtNM9JkRfqQ/NNWbUVjVJuO3H1bGfdrm91r3q6rG1bL5srWH0kyTeEwJP2b4sEEayNyfkv 8RZ8wzI36VTWgQ5DydIBYM410mXbMfuoHcciD6oZUYrEsPwZH5sYxHYpW3tZi9pLxqLgowPe4P ghlgaFUm6nUjQWFzZPXEU3FT Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:18 -0800 IronPort-SDR: +XHHgtpYErAXxbiZvm2+/GcIOa0mUeFBsfuT84chlEnLbBEnqMyb1nmCjtlWWzjNgO5jkqq7zy yZbNBLnF7YiUqm1AI6ytbfN9r+AUu8rG2LsH7P3OWFxGOQ3f2KRZcs62zM3UH96Sp1Ax/69Xkx 8ULa0abjh0jHlCWQ+xJer800OOVkuF6BY5o3QzL0JVqdOF5FEUgqd2JWGEdIC7KJDUx7+O2REy iLOEd2eCe3uv7HqO34vJz31ryAxRR2+Y7jSklCld+QtIcY3hBy7XuNGXgcxkZAmi0iJawJTNmm Fzk= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:43 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1VyB3jPzz1SVp2 for ; Sat, 19 Feb 2022 19:18:42 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327121; x=1647919122; bh=I/9M3iBe0UPPyMeEFV /Y0UfCTDQKGPaDwzMHmZnBLAU=; b=sNh2aI29OGiXbDD/hBkoNgK+jlUNc6yJEa nB0gIF2zyalwb7nD5Jy/sZOVQkiA3D1mTzX8yyONt10T1F9Yl8GOSyz45cZF1Rpp iGonemKGNR6TzByGo80DvxLGDxbyIjR1QKceU1uq0Zdz+zf+0+N5SvjlyfpZDgtQ IEQSKRQxoNqr8CZjKrlhpTga1/vBSgnPxXriDv3pBBwhphXg2aOPnECnu8T0p7Pb A/D6Qclo45UGRy38bNu+Nwr+xQa4QV0dJwbrak/thpj7Vxg/nJWV2rti5EdegNqR O2z5AOHv7yiaaFXbFLxGNMDje3pLPRZTCaG4QCxryLVXhYju7jXg== 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 0_yzCgdqYXQB for ; Sat, 19 Feb 2022 19:18: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 4K1Vy82WGWz1Rwrw; Sat, 19 Feb 2022 19:18:40 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 19/31] scsi: pm8001: Fix tag values handling Date: Sun, 20 Feb 2022 12:17:58 +0900 Message-Id: <20220220031810.738362-20-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The function pm8001_tag_alloc() determines free tags using the function find_first_zero_bit() which can return 0 when the first bit of the bitmap being inspected is 0. As such, tag 0 is a valid tag value that should not be dismissed as invalid. Fix the functions pm8001_work_fn(), mpi_sata_completion(), pm8001_mpi_task_abort_resp() and pm8001_open_reject_retry() to not dismiss 0 tags as invalid. The value 0xffffffff is used for invalid tags for unused ccb information structures. Add the macro definition PM8001_INVALID_TAG to define this value. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 52 +++++++++++-------------------- drivers/scsi/pm8001/pm8001_init.c | 3 +- drivers/scsi/pm8001/pm8001_sas.c | 13 ++++---- drivers/scsi/pm8001/pm8001_sas.h | 2 ++ drivers/scsi/pm8001/pm80xx_hwi.c | 5 --- 5 files changed, 28 insertions(+), 47 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index be57b9ae5486..6f9ee77cc576 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1522,7 +1522,6 @@ void pm8001_work_fn(struct work_struct *work) case IO_XFER_ERROR_BREAK: { /* This one stashes the sas_task instead */ struct sas_task *t = (struct sas_task *)pm8001_dev; - u32 tag; struct pm8001_ccb_info *ccb; struct pm8001_hba_info *pm8001_ha = pw->pm8001_ha; unsigned long flags, flags1; @@ -1544,8 +1543,8 @@ void pm8001_work_fn(struct work_struct *work) /* Search for a possible ccb that matches the task */ for (i = 0; ccb = NULL, i < PM8001_MAX_CCB; i++) { ccb = &pm8001_ha->ccb_info[i]; - tag = ccb->ccb_tag; - if ((tag != 0xFFFFFFFF) && (ccb->task == t)) + if ((ccb->ccb_tag != PM8001_INVALID_TAG) && + (ccb->task == t)) break; } if (!ccb) { @@ -1566,11 +1565,11 @@ void pm8001_work_fn(struct work_struct *work) spin_unlock_irqrestore(&t->task_state_lock, flags1); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with event 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, pw->handler, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); spin_unlock_irqrestore(&pm8001_ha->lock, flags); } else { spin_unlock_irqrestore(&t->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); mb();/* in order to force CPU ordering */ spin_unlock_irqrestore(&pm8001_ha->lock, flags); t->task_done(t); @@ -1579,7 +1578,6 @@ void pm8001_work_fn(struct work_struct *work) case IO_XFER_OPEN_RETRY_TIMEOUT: { /* This one stashes the sas_task instead */ struct sas_task *t = (struct sas_task *)pm8001_dev; - u32 tag; struct pm8001_ccb_info *ccb; struct pm8001_hba_info *pm8001_ha = pw->pm8001_ha; unsigned long flags, flags1; @@ -1613,8 +1611,8 @@ void pm8001_work_fn(struct work_struct *work) /* Search for a possible ccb that matches the task */ for (i = 0; ccb = NULL, i < PM8001_MAX_CCB; i++) { ccb = &pm8001_ha->ccb_info[i]; - tag = ccb->ccb_tag; - if ((tag != 0xFFFFFFFF) && (ccb->task == t)) + if ((ccb->ccb_tag != PM8001_INVALID_TAG) && + (ccb->task == t)) break; } if (!ccb) { @@ -1685,19 +1683,13 @@ void pm8001_work_fn(struct work_struct *work) struct task_status_struct *ts; struct sas_task *task; int i; - u32 tag, device_id; + u32 device_id; for (i = 0; ccb = NULL, i < PM8001_MAX_CCB; i++) { ccb = &pm8001_ha->ccb_info[i]; task = ccb->task; ts = &task->task_status; - tag = ccb->ccb_tag; - /* check if tag is NULL */ - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, - "tag Null\n"); - continue; - } + if (task != NULL) { dev = task->dev; if (!dev) { @@ -1706,10 +1698,11 @@ void pm8001_work_fn(struct work_struct *work) continue; } /*complete sas task and update to top layer */ - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, task, ccb, + ccb->ccb_tag); ts->resp = SAS_TASK_COMPLETE; task->task_done(task); - } else if (tag != 0xFFFFFFFF) { + } else if (ccb->ccb_tag != PM8001_INVALID_TAG) { /* complete the internal commands/non-sas task */ pm8001_dev = ccb->device; if (pm8001_dev->dcompletion) { @@ -1717,7 +1710,7 @@ void pm8001_work_fn(struct work_struct *work) pm8001_dev->dcompletion = NULL; } complete(pm8001_ha->nvmd_completion); - pm8001_tag_free(pm8001_ha, tag); + pm8001_tag_free(pm8001_ha, ccb->ccb_tag); } } /* Deregister all the device ids */ @@ -2313,11 +2306,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) param = le32_to_cpu(psataPayload->param); tag = le32_to_cpu(psataPayload->tag); - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, "tag null\n"); - return; - } - ccb = &pm8001_ha->ccb_info[tag]; t = ccb->task; pm8001_dev = ccb->device; @@ -3051,7 +3039,7 @@ void pm8001_mpi_set_dev_state_resp(struct pm8001_hba_info *pm8001_ha, device_id, pds, nds, status); complete(pm8001_dev->setds_completion); ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); } @@ -3069,7 +3057,7 @@ void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) dlen_status); } ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); } @@ -3096,7 +3084,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) * freed by requesting path anywhere. */ ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); return; } @@ -3142,7 +3130,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) complete(pm8001_ha->nvmd_completion); pm8001_dbg(pm8001_ha, MSG, "Get nvmd data complete!\n"); ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); } @@ -3555,7 +3543,7 @@ int pm8001_mpi_reg_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) } complete(pm8001_dev->dcompletion); ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, htag); return 0; } @@ -3627,7 +3615,7 @@ int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info *pm8001_ha, } kfree(ccb->fw_control_context); ccb->task = NULL; - ccb->ccb_tag = 0xFFFFFFFF; + ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); complete(pm8001_ha->nvmd_completion); return 0; @@ -3663,10 +3651,6 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) status = le32_to_cpu(pPayload->status); tag = le32_to_cpu(pPayload->tag); - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, " TAG NULL. RETURNING !!!\n"); - return -1; - } scp = le32_to_cpu(pPayload->scp); ccb = &pm8001_ha->ccb_info[tag]; diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 381105286953..9b04f1a6a67d 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1217,10 +1217,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 f5678be4c17b..f409dfa049c0 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -553,7 +553,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); } @@ -831,9 +831,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; @@ -845,9 +847,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; @@ -867,11 +866,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 d26f25186779..5082c7dc07ee 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -732,6 +732,8 @@ void pm8001_free_dev(struct pm8001_device *pm8001_dev); /* ctl shared API */ extern const struct attribute_group *pm8001_host_groups[]; +#define PM8001_INVALID_TAG ((u32)-1) + static inline void pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, struct sas_task *task, struct pm8001_ccb_info *ccb, diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 76260d06b6be..cc46e2013eeb 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -2402,11 +2402,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, param = le32_to_cpu(psataPayload->param); tag = le32_to_cpu(psataPayload->tag); - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, "tag null\n"); - return; - } - ccb = &pm8001_ha->ccb_info[tag]; t = ccb->task; pm8001_dev = ccb->device; From patchwork Sun Feb 20 03:17:59 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: 12752531 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 D34E1C433EF for ; Sun, 20 Feb 2022 03:18:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243417AbiBTDTL (ORCPT ); Sat, 19 Feb 2022 22:19:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243375AbiBTDTE (ORCPT ); Sat, 19 Feb 2022 22:19:04 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0980A340D0 for ; Sat, 19 Feb 2022 19:18: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=1645327123; x=1676863123; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XHnl2/M7VbXK4hf62VEy+cdvARX61GHwvczUM/MOT6g=; b=U/nUCc8OgkhfpJPwaZa1NSvrG+w8/Lrke7SvrggTetMApmITI6LbzdoV HNk5C2eRRu3toS/+g/EgVP4M0Ia8AdHSmegQklo4A8F+MWz4XPw3l0LHS PGsNBYiuX3afLlHJ26tO4J2o3zOwHrRy17UrrwF/vqBAqPbEU2m+wKL8q 4amuS+NNnW+Pm9yLF99/M3yCfz5mn/Hzef4xW9ox68XpwBsy4fIIs8JEG Si/Lfh/do8pJY6LAuoT3Z7rTZaZY56aBtn9FpTFK81yW5vFqgDK8XLg0/ LA8M5NVu6RDl98sl919uwQv9RPxjTQVaXu3HlBh5FGTIvWkvnqOn+Irpx Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405793" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:43 +0800 IronPort-SDR: JbOMjgXMHokbTBOsGuE7Ucg1np6N9FEvTnWksy1Pn7SM1BPna+HOdL6+2pQaJ8Hjrh8B7TSaru yN7Pk6aecd+f/97+pDM5aC15vrU+CcwG15eQDGzwiTMuKKL3U7MA4OJY0lvrGzQ0P6sze8NEWv 4dW06+jB/FCmH+BYpT5S4dYqVo3R+x6y1rrfMdtmRh0x7WnIlSs58aK5STBomDLGyrQ1wyD5fY 4sf5fkykVxPboZMNhokq7NjxJSnHsRU0opE0MqcHULJG+kSTl9iTcob8mKZl5Fo2j6f57z1+I5 kCNQAmSLF8+Ey95r70t6+2eP Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:19 -0800 IronPort-SDR: Jo0IW/0rL0YxSNpojHHoqtUYrpPg6h90vNQjteI49gP0C0Q+1nGTbZCJWcW7CZw4iu+MU1KdWE O5pzWSyo8LL9AFN4fxMOwTFsEIpD31E0FOFFpmU55u15kFdI2X0R5bZ+SVi5KaiAsBefBECLBf jlJzOkgvzy9oW6Ls2NERJQYfJjU6O06fW1yKf8kQCDLQW8blk9fynalTbaJgwkGCXm+YfPsgv1 SsTp7Qb0Tpm1ufgW0iARLlo6r9xNfIlER15SusVZ3Tw+7hPwpbK9/qSjlOChjL5hix3WXRat86 FV0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1VyC3Vszz1SVp0 for ; Sat, 19 Feb 2022 19:18: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=1645327123; x=1647919124; bh=XHnl2/M7VbXK4hf62V Ey+cdvARX61GHwvczUM/MOT6g=; b=twIVr+OFRNKo321imBCNXSrwkZh2lkxVav 68WUz+9rEEOtHmDrs/fDkEp99xYJiQMvQmPBHWVl9gG8Z4EyX3HsxOO8AsTZK+/h Ga4BMT4jenPZM/IlTiGVUWbvUugvoQG4XplIVoLxwSzkdGI55Py1l3hN8F7Xzg7S I3XMfCS1S9PODjDWJf+htAq2G5cq5nKeYA618QlAA9SgW3h3ScWvjTIPZnpgloN9 xTxMmtOHGjdiAICNr2SglgG6C6kte8GowEjq99vKMCjei028m5hwXYLa4FXCStR3 xFMFYUfLQQIUZfix1m4+dqxi3ggWg+a6ZC+eYcB/Qx1rpLTcy8+Q== 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 VJIZRKdMwOJv for ; Sat, 19 Feb 2022 19:18:43 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1Vy95pv8z1Rvlx; Sat, 19 Feb 2022 19:18:41 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 20/31] scsi: pm8001: Fix task leak in pm8001_send_abort_all() Date: Sun, 20 Feb 2022 12:17:59 +0900 Message-Id: <20220220031810.738362-21-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm8001_send_abort_all(), make sure to free the allocated sas task if pm8001_tag_alloc() or pm8001_mpi_build_cmd() fail. Signed-off-by: Damien Le Moal Reviewed-by: John Garry --- drivers/scsi/pm8001/pm8001_hwi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 6f9ee77cc576..defac9855d9e 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 Sun Feb 20 03:18:00 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: 12752532 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 1540EC433F5 for ; Sun, 20 Feb 2022 03:19:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243427AbiBTDTa (ORCPT ); Sat, 19 Feb 2022 22:19:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242505AbiBTDTF (ORCPT ); Sat, 19 Feb 2022 22:19:05 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96E80340CD for ; Sat, 19 Feb 2022 19:18: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=1645327125; x=1676863125; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cVLfE2ARMTCIVjN7No5d+rL7rcPTNAHsN17sOgkyRHA=; b=DZTZZGEND18YDe0d0mvQgPkQv3iycgZZmBDiQ+atEURyWXiCacC8rWOB JFdUX4Go8zC4bVvmrIW0QKVISRRRKe7azb7PYJ1BKC70Lpdi2bjxvSwUk AsLlUTZfGL4kMBN+xDVuN6mkaK+pFMgrLt0ZI/cNggBTyhD0IkHq9qweJ w1e5nOxo/ooJUP6yO7RoGc4F6ueLHlWMCp6UNV73d/Io1K8wqFwv3B6mr p7n6kJnYe2CrdpMVqkWgkf+Q3J5c4vWHNsT8NoDG8M2Yysf7rsPHBUkQV lJQ4Io5d19sw76HRMbSW71ihJIU2PMfE1Tosqjs6mKZ6wVMVSpxYYs896 g==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405798" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:45 +0800 IronPort-SDR: CZxND97Gi3iX86R6CURjACxNRrx+kATSY0wjn2mjL3h9q0oehDWdsmNUVfn75sA21D5L23tpGj mLocHz0e8J4vuDE7v+izzNwTrnesNmkyHexsLmEHpEaj+Cmz+xmuYl0COh7CPgT0w30OmBIX/b XyZJynOBf8oxftzF8uZKYlJYbRfaCBcMrtWTVHDhhRdMZS1XJFnIKTViYlEpS2IolzkFUySZfI enccybjaB5KI+AM2r8Jz25uL7AS5AXi9Oc7Z+A52g4NMHjfNQpDamnxBsE7k2e4gDi0eDvvfdp HC/QjRgN5gp7GCFRFVCAmo/K Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:20 -0800 IronPort-SDR: 0GWGC0a65uNzCMz0sbq2VihT8UfWn7mHeWmVHbWm7QKar5HCXO2WxVJyeFj/i7uMrz77HvP8jM onCoz4rugVyLxQdjnpKBGVunG6jug9sajwvpWNKJSs1JY50tvT/NAOvJ7+Y4VhY+ftQOnTFbWi 7f7MWlT5BGqPaFGFdnetdCVOOoM3uqYq0O/TLpWAhjwxbwHZkki02h0EYm3VPVxcdod14JCRAD Pf00tuO/bkffEMNluhF40qpV6EpVNv6SAqJTl7iGGFU0MxDBMJHDvZNZtflUGRrObkUwbB7CJV gog= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1VyF07Wnz1SVp1 for ; Sat, 19 Feb 2022 19:18:45 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327124; x=1647919125; bh=cVLfE2ARMTCIVjN7No 5d+rL7rcPTNAHsN17sOgkyRHA=; b=O4HRkAZ8LndCUURBS/hQmPWXxNM4iZIa+y q+8R04XbVLHTKmKCYDPVWyLsNWiBnt8D4/A/nP3U0EIGjyCNmLw2C18wR5rBmPT1 mMWRGWrgFZuhMn+VYIQb6Z0aDl6SulL4LyemHWHHgXAo8OpDnE+Q5adCQeuzzMcj surjIAn5jPrm3xF0Eaw2NP2HlERBU73sPCzpumjsA4ha6mnWr/1da5ptrtH72kFF +faYvuVEpAb57qG7aZxqHhG7QMcGAVbx0VRfpNARS22DydMqpphK0jILW/fUmV78 3Qd/Q0QQMYmOmryLfXNdYuiQTDbEYfGIo69+CPgjSaALrvUustyA== 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 8TOe5WTRDuUe for ; Sat, 19 Feb 2022 19:18: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 4K1VyC2kPjz1Rwrw; Sat, 19 Feb 2022 19:18:43 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 21/31] scsi: pm8001: Fix tag leaks on error Date: Sun, 20 Feb 2022 12:18:00 +0900 Message-Id: <20220220031810.738362-22-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm8001_chip_set_dev_state_req(), pm8001_chip_fw_flash_update_req(), pm80xx_chip_phy_ctl_req() and pm8001_chip_reg_dev_req() add missing calls to pm8001_tag_free() to free the allocated tag when pm8001_mpi_build_cmd() fails. Similarly, in pm8001_exec_internal_task_abort(), if the chip ->task_abort method fails, the tag allocated for the abort request task must be freed. Add the missing call to pm8001_tag_free(). Signed-off-by: Damien Le Moal Reviewed-by: John Garry --- drivers/scsi/pm8001/pm8001_hwi.c | 9 +++++++++ drivers/scsi/pm8001/pm8001_sas.c | 2 +- drivers/scsi/pm8001/pm80xx_hwi.c | 9 +++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index defac9855d9e..ba7cefb803c3 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4458,6 +4458,9 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, SAS_ADDR_SIZE); rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } @@ -4870,6 +4873,9 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, ccb->ccb_tag = tag; rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, tag); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } @@ -4974,6 +4980,9 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, payload.nds = cpu_to_le32(state); rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index f409dfa049c0..c26f37c88cac 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -738,10 +738,10 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, res = PM8001_CHIP_DISP->task_abort(pm8001_ha, pm8001_dev, flag, task_tag, ccb_tag); - if (res) { del_timer(&task->slow_task->timer); pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n"); + pm8001_tag_free(pm8001_ha, ccb_tag); goto ex_err; } wait_for_completion(&task->slow_task->completion); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index cc46e2013eeb..4419fdb0db78 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4915,8 +4915,13 @@ static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, payload.tag = cpu_to_le32(tag); payload.phyop_phyid = cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF)); - return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + + return rc; } static u32 pm80xx_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha) From patchwork Sun Feb 20 03:18:01 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: 12752533 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 AB8E4C433EF for ; Sun, 20 Feb 2022 03:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242505AbiBTDTb (ORCPT ); Sat, 19 Feb 2022 22:19:31 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243390AbiBTDTG (ORCPT ); Sat, 19 Feb 2022 22:19:06 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D38D340D0 for ; Sat, 19 Feb 2022 19:18: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=1645327126; x=1676863126; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=icyG2a6vKJMXPyTVSV0pQp/YMvTKdf/9Dx/UzI1uFjM=; b=c9Xd71YBmW90CEX5oei6fj6saC3OAZflzLPHxAFOrlwDyZKK6C9JrOMl 32PKgXOknmPEJ25ViSGuJaZf9OuwXIw7n5/KC7k9C1glX5rnDqXYl0+5z KVgqHSKGdJ9YoHKpE27XyIR7FxF2IRui2j7mbQ9pHeATfwCJ0LlG8HMzA HlDVwwTTFqyrIo4Gtr5qpAJ9DeLggJKXyNnRMcrN1HYR+dnUgJ/4giKty ZZXL9Q74/a5RvGGNcIDHyB0tMy5ioOxp/3ve/zWfRH/lrSvtf7TRFX767 j6Z82rVbi128lEQJpect5kK6TIKh+NAvIcoxQAnaH/DBo1XEAAfpCa+Kt w==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405801" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:46 +0800 IronPort-SDR: KEafW3Qa2c5atQuX92bkMyEi1rYkzu3UGMO82xRvnv3UQWadIkMIZp+kJrBotoJveOSdDxpseT UexEsspRhoTD4rXqM7IDy7DwvtdfEDEJCZjloc9kPmHrixhX3Z8BmJFX/I66M8Hyd8FSE2mtzg ZApHWJShTUdhoZgAiXTVP/YsudxWsg8z3snRem1k/lXgGp03EsmN0ewUwj0dKK5JNpi5noHbIF sVHePZe0DX24rxSotya766ywp7NfEdTv+Zdp+MBNAALEHXT/nODcQmWNhSlzc/Y1XizrD8FcCC BHoBskqfPFLNRJ73Azl6WTGS Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:22 -0800 IronPort-SDR: F6XAzpNDK9WrFsIxMzReGzHVHYarqXxZJF59Y4dndjMBxG5xoFjYUwWoVNTYygy1FiFAD3eo4k HCwaOkDSIFePJXdmegaahSesE6m97K9nSpKA2L4RZXNawjxccLeCJdDak5VBCha3w2eZKy4sB5 GbU3EytbIC058jB7aPHNyTecftdEIkZBASq/XJ9et1mCmI1sWWKNSja8+9MnoL6HQzKZIGeG9+ SyVfTcDpgig4Doyr6JKYPEfhBucLUP+oW7Z4YbXzSEAF8T33tRWlmAxeGY86xf/Rx6Oknlsa9m 0yU= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1VyG1pwhz1SVp1 for ; Sat, 19 Feb 2022 19:18: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=1645327125; x=1647919126; bh=icyG2a6vKJMXPyTVSV 0pQp/YMvTKdf/9Dx/UzI1uFjM=; b=uZkbq69afewL4kXVDmDALiLBPaCQ6JbdVL AadlpBgAxI7E6QUKm23WXmEz+MHWXYWnVYiSAYNYzgmCDrYEYHVtw7rRS6gOUizl pWJd3rJhRN1ZTNOuqakXXLibK+7PWyRRqknWbDlhPKKQplQMXvLimSWBUmTCuQ9a smHk38nZGlnukq5RryEEP9pyJ9ay1py1zbIVHe1RaW6dDVd/kbdLG8peGnziIhSd TUJHeDfM1Kym1JeVzL4wBQ/zha08GvWcA0bdRFWtNf9v/hqJpFIqQlIo/BPXZbrr rnamdLtnsJJ76OQP6kJUOsxDGqohR1oBXsNpt/XKnYk7G0ka8BBw== 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 2FFiSB1_o8Na for ; Sat, 19 Feb 2022 19:18: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 4K1VyD5Zqsz1Rvlx; Sat, 19 Feb 2022 19:18:44 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 22/31] scsi: pm8001: fix memory leak in pm8001_chip_fw_flash_update_req() Date: Sun, 20 Feb 2022 12:18:01 +0900 Message-Id: <20220220031810.738362-23-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm8001_chip_fw_flash_update_build(), if pm8001_chip_fw_flash_update_build() fails, the struct fw_control_ex allocated must be freed. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index ba7cefb803c3..14bc4f88c6e6 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4873,8 +4873,10 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, ccb->ccb_tag = tag; rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, tag); - if (rc) + if (rc) { + kfree(fw_control_context); pm8001_tag_free(pm8001_ha, tag); + } return rc; } From patchwork Sun Feb 20 03:18:02 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: 12752538 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 CCA7CC433F5 for ; Sun, 20 Feb 2022 03:19:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243437AbiBTDTj (ORCPT ); Sat, 19 Feb 2022 22:19:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243405AbiBTDTH (ORCPT ); Sat, 19 Feb 2022 22:19:07 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41DE0340D1 for ; Sat, 19 Feb 2022 19:18:48 -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=1645327127; x=1676863127; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wwvhY+uxe6LyvEGXqKRRT6frlKW9xOaFjjpahO0hdn8=; b=Pl8qZTrErVGoWfR1KRskc5Td71zl//d+fmxQnuPDGP/9Mxl+Jtfmi8i9 5mjjj1rCgMRcgqvpW+sRub0fGRjV71Zy5iMgIB0+fmNaqSFWSBUfvWrf8 3gLZUEP2Xa/Fz5wUJyVXJYAZ9Sw7vAI8LWE0Uy8wwmGqvw6HHU5tK9d19 rF6fJlcrKV2W8JKdSke+6oWokVaUwNHdjkL35alvt6aBbni4U6NrEacP+ 6pxFjOs1kcU96Mdg8dlShUuKN3yyKF53d35JSfV55hAr7PJh/ehmsi7ph 8vum8k3LuBOFvK0SdugpSjLa6U2LNls5Tyi+31aQlCi75uXASHtVjaXcl g==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405807" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:47 +0800 IronPort-SDR: q1Zu0sKiF5ANnLyZxB4udf9Jih2nWj37cl/FSyqb2yfdPCZ50ctPJKa2KGXLmvi3Cq3zObBSAH To7yA2T963FkB64Vol4jm+wkIgkJbGQdbBjuRFBXoARlq+7sxX65rw+zNn/T5sAmXetNgvnXPC p5QQImPnx2D7TxKvRsAAuMestvm2XCr9uArEnBbmvAAG3lY0iJ2Htu4xWifg4xl/5PtrZwq1Is 76cMsUBbdDgHANZ58FToKDxyS3lhVBOecnxyXgqsf0VxI4wVoVhazY6szR0lG3h1bN2ALwe9Bp qMS2FOCHTXQpswOHplMYa9Nr Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:23 -0800 IronPort-SDR: Q3sdhO1vj8qsv7KTGbOkG+W/AYipqp+JBpcrudUpBWZK8EKCy8XkyDo//kiTvpzxuiwvOXBcYC sCSSocor13GYyIoFfo4LxXzNZK6bdEBiS9VCQsVmvwz66yUZlKuqP7hMbB9jx7s4rFKegDK4JS iNj6+sd4acMIkqObHy7jvsxHxhBkcHdUqgxQDVBStYLozOvvNNv2Qcfe9wFbXtXcFRcKjYfBAw jhDKD4wDZtLeo+SPqrQeQI9o4APnDK5o8nD03laS9iiLjPpa3fcVfr1OOuNoLCtZQbrbujrk+7 HIc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18:48 -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 4K1VyH4b3rz1SVp4 for ; Sat, 19 Feb 2022 19:18: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=1645327127; x=1647919128; bh=wwvhY+uxe6LyvEGXqK RRT6frlKW9xOaFjjpahO0hdn8=; b=Dg+2G+R/k9vLB89sDhjjwsCRqx1q4winwY lQ1V7ay58sdssSB/4Z8IpiIxG1Vqs059k9qyt6tCg3+/gj4cOl6OIbUi05gmfone n2j6/tkikR4mJI0GLH8Ot8Cglb0dwAWeijputhf+QubELGjkVQgcPtBT46HapTyG UQQ/PXgekJjP5Q9xa9fVXabgMBA2rS4ffCLZ8pri3XYcdLnIjkGSLx33Cc9MZ4Sf jwNSG/LVkNW8MvsP/XoPtm6n3yR+cMWZvw8jPmwO31Y3u3WsdOTqAqSf2VEyEGcZ qYGJh+YmQ2oCX0qS4NEaNVcU5pGM1DARI64+wrEZJjKqbXJ0AxiQ== 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 aC345oKjeYFM for ; Sat, 19 Feb 2022 19:18:47 -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 4K1VyG0f7fz1Rwrw; Sat, 19 Feb 2022 19:18:45 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 23/31] scsi: libsas: Simplify sas_ata_qc_issue() detection of NCQ commands Date: Sun, 20 Feb 2022 12:18:02 +0900 Message-Id: <20220220031810.738362-24-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect if a command is NCQ, there is no need to test all possible NCQ command codes. Instead, use ata_is_ncq() to test the command protocol. Signed-off-by: Damien Le Moal Reviewed-by: John Garry --- 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 dd4ae5e8cb5c..d34c82e24d9a 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -179,14 +179,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 Sun Feb 20 03:18:03 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: 12752537 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 7054FC433EF for ; Sun, 20 Feb 2022 03:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237502AbiBTDTh (ORCPT ); Sat, 19 Feb 2022 22:19:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243407AbiBTDTJ (ORCPT ); Sat, 19 Feb 2022 22:19:09 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78F3C340D2 for ; Sat, 19 Feb 2022 19:18: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=1645327129; x=1676863129; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1xeafIdaW3IGXUiFvb5jh90tQpCsmAXWyaCBFXB/Ung=; b=S+wHt2RU/XVu6/MXvWFNlYu8WsNPE+QAQGfywg7t5TCdx4hKXxz412qk XCG5heXDJrKd23NAyQE9I4ByWSibo1jJv2El0Phqj+1w8r5f6h0h/VquU zv1FQrIn/kurHJHasGgcR62nSt05pnvm51M+pGkD57R3KgoYnzAgU/b0U K/itQHQQ4CEK2lJOb4ojO/vITVzjWjWFoLqHZEUkLG2Sk8eK9IIpNtqxp uH8Fjo4W5ZL4n8O0Fd1f9nvkZS6nAfRatusIm9SdJsFTk9G4ubc8UBcG4 uqUiAdYsq/sLicfFwQA0uQYPIvOahTg1J3AXcIEtwAKNbX/Nn1u+JRouP w==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405811" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:48 +0800 IronPort-SDR: Mjb1nh+hZg1zHoLInEnWdgSRGp75ihvka7CRNoG2s5rnVo1CtHGsgh8muPdotgXMlWnnErpnlC jtacnNL049pW3zOBc/C3W5J6KpNFGNXLxCKeQHkkVffWU/TglcS0cbS0WjL1SywdtUmY2cgF2R kHCinfXyv6rk73kjFZ7Mnd6ct3Gea1juDzY//2bsoquMAx3SFmRhM6oyPVtB6ggyW7ms4jg21G 1e8y2BhgGIMU6V+k3upyXj8qZAe0e51dVgbjXq5jsfw2JLAVasGbykTFQNAbj8ZwhS0ix5mDBp N7kHWFjjaFYzoDKp07TtzZ0c Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:24 -0800 IronPort-SDR: vSo8yqqxOOPaX4IqI1xM3oMZvUtHu8JTxqeq2OZ3lFSLNnLaEaBQn2H8ikKUnQYLji5vferD4t Z3KMma4PahrGJ/OvlPnl4SjuSMgm7c/klnSmv7kHu1X8xwfCY519ONtT7IlPy3NE49RdYo+ubV LLjsY8fv1BdXx7wVD6TXzPNIebn2t/lHtXZZGRXWG/ZxDqQvpivWt8FHB+bvVIPOOFvTjcPhP0 ZIDVJKz5deotUoCbYOlhuNmTUMQAJxrguuU7bX+kaFJmxvjKD7Uh3iQCw/yknRfSzQBfr+Kx24 Hhw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1VyJ6sZJz1SHwl for ; Sat, 19 Feb 2022 19:18: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=1645327128; x=1647919129; bh=1xeafIdaW3IGXUiFvb 5jh90tQpCsmAXWyaCBFXB/Ung=; b=kOJV/jyJTQpUNg+oLfNgb0uUWpa5yzMV3W QIYG1SMzyWudL92GNX386vbJfJ+noedR4dyJR6Hb1busRmxDBoh2spg1soi3efOk TMimqYs7ON7dVUxotKkxdJ/S5/J5B96Y/0ha3NAoqNNV8WUZDMV/fTwZqXAIP8id f6rYG+H/YUFu2+YzllSZjx08rEeAkEI0PGD3lCl25+Vse1nwncMS2pyH0aha6bIg xEC8mZ0yWWllCPASWf+T7Orkt8jvEnvLuIhgW/nH4BX5zG2ZSuV6FLnWEfklQAfR pLFu5H3/fTgEBVnVHrEyxI72iWbCyC1VScwM8S46agDrmj/kzDCA== 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 luBpD9a9Gouf for ; Sat, 19 Feb 2022 19:18: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 4K1VyH35S7z1Rvlx; Sat, 19 Feb 2022 19:18:47 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 24/31] scsi: pm8001: Cleanup pm8001_exec_internal_task_abort() Date: Sun, 20 Feb 2022 12:18:03 +0900 Message-Id: <20220220031810.738362-25-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace the goto statement in the for loop with "break" and remove the ex_err label. Also fix long lines, identation and blank lines to make the code more readable. Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_sas.c | 38 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index c26f37c88cac..b41f3aa6ce3e 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -724,50 +724,54 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, task->task_proto = dev->tproto; task->task_done = pm8001_task_done; task->slow_task->timer.function = pm8001_tmf_timedout; - task->slow_task->timer.expires = jiffies + PM8001_TASK_TIMEOUT * HZ; + task->slow_task->timer.expires = + jiffies + PM8001_TASK_TIMEOUT * HZ; add_timer(&task->slow_task->timer); res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); if (res) - goto ex_err; + break; + ccb = &pm8001_ha->ccb_info[ccb_tag]; ccb->device = pm8001_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; ccb->n_elem = 0; - res = PM8001_CHIP_DISP->task_abort(pm8001_ha, - pm8001_dev, flag, task_tag, ccb_tag); + res = PM8001_CHIP_DISP->task_abort(pm8001_ha, pm8001_dev, flag, + task_tag, ccb_tag); if (res) { del_timer(&task->slow_task->timer); - pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n"); + pm8001_dbg(pm8001_ha, FAIL, + "Executing internal task failed\n"); pm8001_tag_free(pm8001_ha, ccb_tag); - goto ex_err; + break; } + wait_for_completion(&task->slow_task->completion); res = TMF_RESP_FUNC_FAILED; + /* Even TMF timed out, return direct. */ if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { pm8001_dbg(pm8001_ha, FAIL, "TMF task timeout.\n"); - goto ex_err; + break; } if (task->task_status.resp == SAS_TASK_COMPLETE && task->task_status.stat == SAS_SAM_STAT_GOOD) { res = TMF_RESP_FUNC_COMPLETE; break; - - } else { - pm8001_dbg(pm8001_ha, EH, - " Task to dev %016llx response: 0x%x status 0x%x\n", - SAS_ADDR(dev->sas_addr), - task->task_status.resp, - task->task_status.stat); - sas_free_task(task); - task = NULL; } + + pm8001_dbg(pm8001_ha, EH, + " Task to dev %016llx response: 0x%x status 0x%x\n", + SAS_ADDR(dev->sas_addr), + task->task_status.resp, + task->task_status.stat); + sas_free_task(task); + task = NULL; } -ex_err: + BUG_ON(retry == 3 && task != NULL); sas_free_task(task); return res; From patchwork Sun Feb 20 03:18:04 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: 12752536 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 B18ABC433EF for ; Sun, 20 Feb 2022 03:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243431AbiBTDTf (ORCPT ); Sat, 19 Feb 2022 22:19:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243412AbiBTDTK (ORCPT ); Sat, 19 Feb 2022 22:19:10 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFCA0340D3 for ; Sat, 19 Feb 2022 19:18: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=1645327130; x=1676863130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uPLB3X/uRqDQhm7Cw3AJNnBX3Q4TxG2g7Ya2O0duFBY=; b=buzQDHdQiTvJ0KrIzxpjNq8KMb+Of3ZeXq2v0k6H8zcZa0TbwKB+28j/ XqaXd8GyMge0xkf7XHzsQ32IRrENYWhzVzbjMT4ANyTJWxqTNE0bsO5Aa uOHdQMxisel8A9KvhsadSViOcoo5R9kBxL/MlyKPV7S7sWrtIXlGqNdAd WCyI3gn7N1YhBPsZqD9s/o90HwVWlGQtNwgoY+4w/enVepLqK7ZeppdB7 PnDG2dsxtDJSDLFWSGLiEVkcjk/iZ+Szxvq412UhIimcqmk0Gs4LDBrYl ddvcN9Cn9T9PzMMQmZM9lGN1RalSpgzL9ayw1zuvoXGTJu+ZRWnUGJ+OG w==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405814" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:50 +0800 IronPort-SDR: VHXm+/0ay6rRVTIBii80CZAoCkTIge4bJZK6DnVqWTgDuZbIDUuyQC6/8NyjCUdlqhXUI4z/LU NQ5sJ/0kGXPUT0CQqzHxmoNW/JExF2tEarvP/DJPiu3hpDfoyZMywIP8NSSe5HBD3MyJJhKAvR vApQFVfBHOXCDfLagQLf20RSJLgCFr/Luozjdaznkr9TdmPJwXnZ96VolW+CarmeM2pZHO413U zQlGBfECe+btGPcfKI3+Zlh2T23Kk2a2AVxgt8Jfir19UYhAkHwFFXorNuUEoTynVBwBBzjwHY vaE6IMbJ4DJw2LpbGLKxcsZh Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:26 -0800 IronPort-SDR: UkePtRH4qOfvuu6287E4TXBcZBoiHUk/4TaPcxztXTyEwxn9Je7jDG3g6pHcVFi1dB+1seKsIx klX4hzvO5sy6/maQYF/0lFbmfVCWbMNTeEIQlxhM99dOL4g8SKUBKi/Z07RaVZRk9ai0Nss7f4 3cX/2Sn+8xD0BZldqX6gWylFxmHaVRgopJ/oSWWnVhCHIaEddRYbp5aTtT9kivKwLw6S3arMsR wqFS4k5Bly34vTgFuNU++WXm+fmaLBwvxF8JBCsUL8cm978EauUkVdvKxZUXgNRgXvmY7W1IJV Edc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1VyL1zrDz1SVp0 for ; Sat, 19 Feb 2022 19:18:50 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1645327129; x=1647919130; bh=uPLB3X/uRqDQhm7Cw3 AJNnBX3Q4TxG2g7Ya2O0duFBY=; b=Pi5adARpJPCAGTOGcVE/gj4tXK42dENJEe tfEo/2Fw7Eg7y56WHBngGXCiILNS/fqLaTrWCEazLQN2oywHiB4jsaK+DyfynhKm SVqljQSkXufGNO9g5a4RlVgFWVI3waxFcvmSlWJqamURggjD+ohpl65cTr5G1wAj WV1Eg7sML1jCnFBOBNfwsiLM4FhnzExcaPvbma9WMfS3RhxC1b4/ip39oTEpvHzs AEUGKM2TDxIV5+MXfkoye7DcB6awAI5xS2J77KTtsctiHIFi+iUyGzAA4qXF9CBq AmioT1id2E7Tc2OT+5kizN24sKCz+TdeCM6bh4iuhxWKttBoegWQ== 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 1TIvplhhi_uU for ; Sat, 19 Feb 2022 19:18: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 4K1VyJ5ZJGz1Rwrw; Sat, 19 Feb 2022 19:18:48 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 25/31] scsi: pm8001: Simplify pm8001_get_ncq_tag() Date: Sun, 20 Feb 2022 12:18:04 +0900 Message-Id: <20220220031810.738362-26-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect if a command is NCQ, there is no need to test all possible NCQ command codes. Instead, use ata_is_ncq() to test the command protocol. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_sas.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index b41f3aa6ce3e..55859d24edd3 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 Sun Feb 20 03:18:05 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: 12752534 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 784B4C433F5 for ; Sun, 20 Feb 2022 03:19:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243390AbiBTDTc (ORCPT ); Sat, 19 Feb 2022 22:19:32 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234347AbiBTDT3 (ORCPT ); Sat, 19 Feb 2022 22:19:29 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8031C340D4 for ; Sat, 19 Feb 2022 19:18: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=1645327135; x=1676863135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JGTIk9a9W86uP2S6P+cS9aSUW2EM1MAfKsxYZSQSKjY=; b=mQn6K8TAv/9xgqrmSO/njXmyUkuW/s/Q8ZdvS+kcQVJD4PCdg48nvxtD 67BD06/0p2trDQ1ATUaLru65dcB11OMZa2F6sH7yPc7WcO5Q6CVTfzR8u nhc2LohfVSmTgMb+w3W+9Cmwjw0zneREYJMg6cOY+27DH585maau95DbL 9YsnOk98wH8wuLEgfKll5EdCxZs7cryvvc4mNaLENGH4e2V9gZoux6Hvn MyhSJLsjPdsLA+vLhnXb5A4mjIAHAIpfwkrNg1gYIDJk81/p5vHGuTP0B K8cxkXJUmUqFWX+0q0yWenxeQTWTnRAd1XA1sE0JQo1fWE2GfzkBgsOba Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405820" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:54 +0800 IronPort-SDR: hPqGTPx7Ceq7LPF1ZbhxgYvKY5jeaoQQzsnfRPZS7ewObX6zj2j7CDpHjk5xJxzVvuQJIzhADG gCEnHeQP2Mg6ZUkjoHsOy/VoZUgxwDzASthV6NLh6DuZ1evfgPUo32SHsAGES2ylwLtk+Mjdm7 QhJBvorW2L5hGW3NpGb4YZTaLyQD0ZCUR2LWcaEDjANwcT/0P8oH70p427V/7Pc3TFcTM8Dl1s uXAYN4Lnf/LJnSWKgSfnpFLzKLhgixhQJWhJXgOXW8iZTr4PgqekiZFCc+aAp8t5c7dLhPa3mh CLSnr1wtG4SiyXb9Vs9VoEhv Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:30 -0800 IronPort-SDR: ofSo6ynMXZjZpDvABLVGXsOqRaEys5YbBObh3Bdfr/EBGCzb33SRJz59HskWem2vLlS4XHJcK0 7Ad7HWRe4rtWJdp4oxaOGFONWptN6rPJRfw5vkD9JC6oveKjeR7TsX+D/yKRb55F03Lntn7ZZ3 rOJEkyxXOJsAZdlmmOnPcgS4EP+9aZtuodZx/yemrJZ1BZMY3Kxd4V1HS6jMPvoKRTK1MmbzYm pQ0bNb+A+oP+HfAHXpnA0GyC6Uk3H8fVoZ42zxTUv/VnIaMFBqeHh8jXpRn5JDFCg09mSFncSt Wgo= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1VyP4f1lz1SVp4 for ; Sat, 19 Feb 2022 19:18: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=1645327131; x=1647919132; bh=JGTIk9a9W86uP2S6P+ cS9aSUW2EM1MAfKsxYZSQSKjY=; b=NzgalUnMtlUErHfCapI3Z2LAvy2U6tccE4 JVCm35vzalRiXAt83UD1XI+FkZU57YnipRwgCz6Oh1PjdfRHGu8oFDTzqv0mLGjr 7/NO+w2OTYTkgkUUe6IjOdk6T1MOTfYvIyzabCqJpgh9ESNKfErOx6YY+mfQe0XI vYiwTou+qqefyAJNV2PluuxCBGxEl7bsOS0bR4ErygLea05JFHJ5BMaTggzup8OJ qUfMfyuHhE7P3sEFpNA3IwOlF96nmCltKoIDgPBLC4hx55/HsXSyWw3xXxZQHoL0 cZ74Wbga2w2o61YB5F6OdM9w4uMvCSDtB3HKgNV249kfi4QplvkQ== 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 GYEwhzq2GW8m for ; Sat, 19 Feb 2022 19:18: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 4K1VyL1372z1Rvlx; Sat, 19 Feb 2022 19:18:49 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 26/31] scsi: pm8001: Introduce ccb alloc/free helpers Date: Sun, 20 Feb 2022 12:18:05 +0900 Message-Id: <20220220031810.738362-27-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Introduce the pm8001_ccb_alloc() and pm8001_ccb_free() helpers to replace the typical code patterns: res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); if (res) ... ccb = &pm8001_ha->ccb_info[ccb_tag]; ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; ccb->n_elem = 0; and ccb->task = NULL; ccb->ccb_tag = PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); With the simpler function calls: ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); if (!ccb) ... and pm8001_ccb_free(pm8001_ha, ccb); The pm8001_ccb_alloc() helper ensures that all fields of the ccb info structure for the newly allocated tag are all initialized, except the buf_prd field. The pm8001_ccb_free() helper clears the initialized fields and the ccb tag to ensure that iteration over the adapter ccb_info array detects ccbs that are in use. All call site of the pm8001_tag_alloc() function that use a ccb info associated with an allocated tag are converted to use the new helpers. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 180 +++++++++++++------------------ drivers/scsi/pm8001/pm8001_sas.c | 46 ++++---- drivers/scsi/pm8001/pm8001_sas.h | 47 ++++++++ drivers/scsi/pm8001/pm80xx_hwi.c | 64 +++++------ 4 files changed, 166 insertions(+), 171 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 14bc4f88c6e6..d45765aac148 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1710,7 +1710,7 @@ void pm8001_work_fn(struct work_struct *work) pm8001_dev->dcompletion = NULL; } complete(pm8001_ha->nvmd_completion); - pm8001_tag_free(pm8001_ha, ccb->ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); } } /* Deregister all the device ids */ @@ -1749,8 +1749,6 @@ int pm8001_handle_event(struct pm8001_hba_info *pm8001_ha, void *data, static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev) { - int res; - u32 ccb_tag; struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct task_abort_req task_abort; @@ -1771,32 +1769,25 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, task->task_done = pm8001_task_done; - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) { + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); + if (!ccb) { sas_free_task(task); return; } - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_ha_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&task_abort, 0, sizeof(task_abort)); task_abort.abort_all = cpu_to_le32(1); task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); - task_abort.tag = cpu_to_le32(ccb_tag); + task_abort.tag = cpu_to_le32(ccb->ccb_tag); ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, sizeof(task_abort), 0); if (ret) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); } - } static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, @@ -1804,7 +1795,6 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, { struct sata_start_req sata_cmd; int res; - u32 ccb_tag; struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct host_to_dev_fis fis; @@ -1820,20 +1810,13 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, } task->task_done = pm8001_task_done; - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) { - sas_free_task(task); - pm8001_dbg(pm8001_ha, FAIL, "cannot allocate tag !!!\n"); - return; - } - - /* allocate domain device by ourselves as libsas - * is not going to provide any - */ + /* + * Allocate domain device by ourselves as libsas is not going to + * provide any. + */ dev = kzalloc(sizeof(struct domain_device), GFP_ATOMIC); if (!dev) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); pm8001_dbg(pm8001_ha, FAIL, "Domain device cannot be allocated\n"); return; @@ -1841,11 +1824,13 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, task->dev = dev; task->dev->lldd_dev = pm8001_ha_dev; - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_ha_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); + if (!ccb) { + sas_free_task(task); + kfree(dev); + return; + } + pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; @@ -1860,7 +1845,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, fis.lbal = 0x10; fis.sector_count = 0x1; - sata_cmd.tag = cpu_to_le32(ccb_tag); + sata_cmd.tag = cpu_to_le32(ccb->ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); sata_cmd.ncqtag_atap_dir_m = cpu_to_le32((0x1 << 7) | (0x5 << 9)); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); @@ -1869,7 +1854,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, sizeof(sata_cmd), 0); if (res) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); kfree(dev); } } @@ -3038,12 +3023,12 @@ void pm8001_mpi_set_dev_state_resp(struct pm8001_hba_info *pm8001_ha, u32 device_id = le32_to_cpu(pPayload->device_id); u8 pds = le32_to_cpu(pPayload->pds_nds) & PDS_BITS; u8 nds = le32_to_cpu(pPayload->pds_nds) & NDS_BITS; - pm8001_dbg(pm8001_ha, MSG, "Set device id = 0x%x state from 0x%x to 0x%x status = 0x%x!\n", + + pm8001_dbg(pm8001_ha, MSG, + "Set device id = 0x%x state from 0x%x to 0x%x status = 0x%x!\n", device_id, pds, nds, status); complete(pm8001_dev->setds_completion); - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) @@ -3053,15 +3038,14 @@ void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) u32 tag = le32_to_cpu(pPayload->tag); struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[tag]; u32 dlen_status = le32_to_cpu(pPayload->dlen_status); + complete(pm8001_ha->nvmd_completion); pm8001_dbg(pm8001_ha, MSG, "Set nvm data complete!\n"); if ((dlen_status & NVMD_STAT) != 0) { pm8001_dbg(pm8001_ha, FAIL, "Set nvm data error %x\n", dlen_status); } - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } void @@ -3086,9 +3070,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) /* We should free tag during failure also, the tag is not being * freed by requesting path anywhere. */ - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); return; } if (ir_tds_bn_dps_das_nvm & IPMode) { @@ -3132,9 +3114,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) */ complete(pm8001_ha->nvmd_completion); pm8001_dbg(pm8001_ha, MSG, "Get nvmd data complete!\n"); - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha, void *piomb) @@ -3545,9 +3525,7 @@ int pm8001_mpi_reg_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) break; } complete(pm8001_dev->dcompletion); - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, htag); + pm8001_ccb_free(pm8001_ha, ccb); return 0; } @@ -3580,6 +3558,7 @@ int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info *pm8001_ha, (struct fw_flash_Update_resp *)(piomb + 4); u32 tag = le32_to_cpu(ppayload->tag); struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[tag]; + status = le32_to_cpu(ppayload->status); switch (status) { case FLASH_UPDATE_COMPLETE_PENDING_REBOOT: @@ -3617,9 +3596,7 @@ int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info *pm8001_ha, break; } kfree(ccb->fw_control_context); - ccb->task = NULL; - ccb->ccb_tag = PM8001_INVALID_TAG; - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); complete(pm8001_ha->nvmd_completion); return 0; } @@ -4412,7 +4389,7 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, u32 stp_sspsmp_sata = 0x4; struct inbound_queue_table *circularQ; u32 linkrate, phy_id; - int rc, tag = 0xdeadbeef; + int rc; struct pm8001_ccb_info *ccb; u8 retryFlag = 0x1; u16 firstBurstSize = 0; @@ -4423,13 +4400,11 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) - return rc; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->device = pm8001_dev; - ccb->ccb_tag = tag; - payload.tag = cpu_to_le32(tag); + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); + if (!ccb) + return -SAS_QUEUE_FULL; + + payload.tag = cpu_to_le32(ccb->ccb_tag); if (flag == 1) stp_sspsmp_sata = 0x02; /*direct attached sata */ else { @@ -4459,7 +4434,7 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); if (rc) - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); return rc; } @@ -4624,7 +4599,6 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, u32 opc = OPC_INB_GET_NVMD_DATA; u32 nvmd_type; int rc; - u32 tag; struct pm8001_ccb_info *ccb; struct inbound_queue_table *circularQ; struct get_nvm_data_req nvmd_req; @@ -4639,15 +4613,15 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, fw_control_context->len = ioctl_payload->rd_length; circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&nvmd_req, 0, sizeof(nvmd_req)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) { + + ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); + if (!ccb) { kfree(fw_control_context); - return rc; + return -SAS_QUEUE_FULL; } - ccb = &pm8001_ha->ccb_info[tag]; - ccb->ccb_tag = tag; ccb->fw_control_context = fw_control_context; - nvmd_req.tag = cpu_to_le32(tag); + + nvmd_req.tag = cpu_to_le32(ccb->ccb_tag); switch (nvmd_type) { case TWI_DEVICE: { @@ -4708,7 +4682,7 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, sizeof(nvmd_req), 0); if (rc) { kfree(fw_control_context); - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } return rc; } @@ -4719,7 +4693,6 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, u32 opc = OPC_INB_SET_NVMD_DATA; u32 nvmd_type; int rc; - u32 tag; struct pm8001_ccb_info *ccb; struct inbound_queue_table *circularQ; struct set_nvm_data_req nvmd_req; @@ -4735,15 +4708,15 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, &ioctl_payload->func_specific, ioctl_payload->wr_length); memset(&nvmd_req, 0, sizeof(nvmd_req)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) { + + ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); + if (!ccb) { kfree(fw_control_context); - return -EBUSY; + return -SAS_QUEUE_FULL; } - ccb = &pm8001_ha->ccb_info[tag]; ccb->fw_control_context = fw_control_context; - ccb->ccb_tag = tag; - nvmd_req.tag = cpu_to_le32(tag); + + nvmd_req.tag = cpu_to_le32(ccb->ccb_tag); switch (nvmd_type) { case TWI_DEVICE: { u32 twi_addr, twi_page_size; @@ -4793,7 +4766,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, sizeof(nvmd_req), 0); if (rc) { kfree(fw_control_context); - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } return rc; } @@ -4839,7 +4812,6 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, struct fw_control_info *fw_control; struct fw_control_ex *fw_control_context; int rc; - u32 tag; struct pm8001_ccb_info *ccb; void *buffer = pm8001_ha->memoryMap.region[FW_FLASH].virt_ptr; dma_addr_t phys_addr = pm8001_ha->memoryMap.region[FW_FLASH].phys_addr; @@ -4863,19 +4835,19 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, fw_control_context->virtAddr = buffer; fw_control_context->phys_addr = phys_addr; fw_control_context->len = fw_control->len; - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) { + + ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); + if (!ccb) { kfree(fw_control_context); - return -EBUSY; + return -SAS_QUEUE_FULL; } - ccb = &pm8001_ha->ccb_info[tag]; ccb->fw_control_context = fw_control_context; - ccb->ccb_tag = tag; + rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, - tag); + ccb->ccb_tag); if (rc) { kfree(fw_control_context); - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } return rc; @@ -4967,26 +4939,25 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, struct inbound_queue_table *circularQ; struct pm8001_ccb_info *ccb; int rc; - u32 tag; u32 opc = OPC_INB_SET_DEVICE_STATE; + memset(&payload, 0, sizeof(payload)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) - return -1; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->ccb_tag = tag; - ccb->device = pm8001_dev; + + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); + if (!ccb) + return -SAS_QUEUE_FULL; + circularQ = &pm8001_ha->inbnd_q_tbl[0]; - payload.tag = cpu_to_le32(tag); + payload.tag = cpu_to_le32(ccb->ccb_tag); payload.device_id = cpu_to_le32(pm8001_dev->device_id); payload.nds = cpu_to_le32(state); + rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); if (rc) - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); return rc; - } static int @@ -4996,25 +4967,26 @@ pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha) struct inbound_queue_table *circularQ; struct pm8001_ccb_info *ccb; int rc; - u32 tag; u32 opc = OPC_INB_SAS_RE_INITIALIZE; + memset(&payload, 0, sizeof(payload)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) - return -ENOMEM; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->ccb_tag = tag; + + ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); + if (!ccb) + return -SAS_QUEUE_FULL; + circularQ = &pm8001_ha->inbnd_q_tbl[0]; - payload.tag = cpu_to_le32(tag); + payload.tag = cpu_to_le32(ccb->ccb_tag); payload.SSAHOLT = cpu_to_le32(0xd << 25); payload.sata_hol_tmo = cpu_to_le32(80); payload.open_reject_cmdretries_data_retries = cpu_to_le32(0xff00ff); + rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); if (rc) - pm8001_tag_free(pm8001_ha, tag); - return rc; + pm8001_ccb_free(pm8001_ha, ccb); + return rc; } const struct pm8001_dispatch pm8001_8001_dispatch = { diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 55859d24edd3..6e5d1af12230 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; @@ -381,7 +381,7 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags) struct pm8001_port *port = NULL; struct sas_task *t = task; struct pm8001_ccb_info *ccb; - u32 tag = 0xdeadbeef, rc = 0, n_elem = 0; + u32 rc = 0, n_elem = 0; unsigned long flags = 0; enum sas_protocol task_proto = t->task_proto; struct sas_tmf_task *tmf = task->tmf; @@ -427,10 +427,12 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags) 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) { @@ -440,7 +442,7 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags) t->data_dir); if (!n_elem) { rc = -ENOMEM; - goto err_out_tag; + goto err_out_ccb; } } } else { @@ -449,9 +451,7 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags) 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); @@ -480,15 +480,15 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags) 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)) @@ -548,10 +548,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); } /** @@ -707,7 +704,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; @@ -724,23 +720,19 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, jiffies + PM8001_TASK_TIMEOUT * HZ; add_timer(&task->slow_task->timer); - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, task); + if (!ccb) { + res = -SAS_QUEUE_FULL; break; - - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; + } res = PM8001_CHIP_DISP->task_abort(pm8001_ha, pm8001_dev, flag, - task_tag, ccb_tag); + task_tag, ccb->ccb_tag); if (res) { del_timer(&task->slow_task->timer); pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n"); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); break; } diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 5082c7dc07ee..00b4470634bd 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -734,6 +734,53 @@ extern const struct attribute_group *pm8001_host_groups[]; #define PM8001_INVALID_TAG ((u32)-1) +/* + * Allocate a new tag and return the corresponding ccb after initializing it. + */ +static inline struct pm8001_ccb_info * +pm8001_ccb_alloc(struct pm8001_hba_info *pm8001_ha, + struct pm8001_device *dev, struct sas_task *task) +{ + struct pm8001_ccb_info *ccb; + u32 tag; + + if (pm8001_tag_alloc(pm8001_ha, &tag)) { + pm8001_dbg(pm8001_ha, FAIL, "Failed to allocate a tag\n"); + return NULL; + } + + ccb = &pm8001_ha->ccb_info[tag]; + ccb->task = task; + ccb->n_elem = 0; + ccb->ccb_tag = tag; + ccb->device = dev; + ccb->fw_control_context = NULL; + ccb->open_retry = 0; + + return ccb; +} + +/* + * Free the tag of an initialized ccb. + */ +static inline void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, + struct pm8001_ccb_info *ccb) +{ + u32 tag = ccb->ccb_tag; + + /* + * Cleanup the ccb to make sure that a manual scan of the adapter + * ccb_info array can detect ccb's that are in use. + * C.f. pm8001_open_reject_retry() + */ + ccb->task = NULL; + ccb->ccb_tag = PM8001_INVALID_TAG; + ccb->device = NULL; + ccb->fw_control_context = NULL; + + pm8001_tag_free(pm8001_ha, tag); +} + static inline void pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, struct sas_task *task, struct pm8001_ccb_info *ccb, diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 4419fdb0db78..57ea933dab66 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1767,8 +1767,6 @@ pm80xx_chip_interrupt_disable(struct pm8001_hba_info *pm8001_ha, u8 vec) static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev) { - int res; - u32 ccb_tag; struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct task_abort_req task_abort; @@ -1790,31 +1788,25 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, task->task_done = pm8001_task_done; - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) { + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); + if (!ccb) { sas_free_task(task); return; } - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_ha_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&task_abort, 0, sizeof(task_abort)); task_abort.abort_all = cpu_to_le32(1); task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); - task_abort.tag = cpu_to_le32(ccb_tag); + task_abort.tag = cpu_to_le32(ccb->ccb_tag); ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, sizeof(task_abort), 0); pm8001_dbg(pm8001_ha, FAIL, "Executing abort task end\n"); if (ret) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); } } @@ -1823,7 +1815,6 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, { struct sata_start_req sata_cmd; int res; - u32 ccb_tag; struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct host_to_dev_fis fis; @@ -1839,20 +1830,13 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, } task->task_done = pm8001_task_done; - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) { - sas_free_task(task); - pm8001_dbg(pm8001_ha, FAIL, "cannot allocate tag !!!\n"); - return; - } - - /* allocate domain device by ourselves as libsas - * is not going to provide any - */ + /* + * Allocate domain device by ourselves as libsas is not going to + * provide any. + */ dev = kzalloc(sizeof(struct domain_device), GFP_ATOMIC); if (!dev) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); pm8001_dbg(pm8001_ha, FAIL, "Domain device cannot be allocated\n"); return; @@ -1861,11 +1845,13 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, task->dev = dev; task->dev->lldd_dev = pm8001_ha_dev; - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_ha_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); + if (!ccb) { + sas_free_task(task); + kfree(dev); + return; + } + pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; @@ -1880,7 +1866,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, fis.lbal = 0x10; fis.sector_count = 0x1; - sata_cmd.tag = cpu_to_le32(ccb_tag); + sata_cmd.tag = cpu_to_le32(ccb->ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); sata_cmd.ncqtag_atap_dir_m_dad = cpu_to_le32(((0x1 << 7) | (0x5 << 9))); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); @@ -1890,7 +1876,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, pm8001_dbg(pm8001_ha, FAIL, "Executing read log end\n"); if (res) { sas_free_task(task); - pm8001_tag_free(pm8001_ha, ccb_tag); + pm8001_ccb_free(pm8001_ha, ccb); kfree(dev); } } @@ -4834,7 +4820,7 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, u32 stp_sspsmp_sata = 0x4; struct inbound_queue_table *circularQ; u32 linkrate, phy_id; - int rc, tag = 0xdeadbeef; + int rc; struct pm8001_ccb_info *ccb; u8 retryFlag = 0x1; u16 firstBurstSize = 0; @@ -4845,13 +4831,11 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) - return rc; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->device = pm8001_dev; - ccb->ccb_tag = tag; - payload.tag = cpu_to_le32(tag); + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); + if (!ccb) + return -SAS_QUEUE_FULL; + + payload.tag = cpu_to_le32(ccb->ccb_tag); if (flag == 1) { stp_sspsmp_sata = 0x02; /*direct attached sata */ @@ -4888,7 +4872,7 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); if (rc) - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); return rc; } From patchwork Sun Feb 20 03:18:06 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: 12752542 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 6D0ADC433EF for ; Sun, 20 Feb 2022 03:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243439AbiBTDTo (ORCPT ); Sat, 19 Feb 2022 22:19:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243309AbiBTDT3 (ORCPT ); Sat, 19 Feb 2022 22:19:29 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51DC0340DA for ; Sat, 19 Feb 2022 19:18: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=1645327137; x=1676863137; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RgVX2D4WNVM4UjW8GozK4WDh6xFHzxqRq0/+exkDXLc=; b=ErYGYSltoJyAVMZXW0hZn5FNBSjZ5IpfFlpAzb0MV62gp8f11GMury4p xm5IceuyIt7heWAOQUAQFmoePYhwbuTrYlnim7T062JmByn0HdknwVUDG MCdAidJb8Y+EebWwWphNtJCJV6l9ba7EFPO6ANPbNWT/Stc2TqKjg/ciE IXRcuhmvQDD31R5jVGo2FUqX6L718xUjC5cI4MAKw+Y/NV2SjUw8vbaKE Ee6HEICsmYYk9t1MgHoKwUfDsEv9TaJ6hTbGYPyzGLuuyjkza7E0cbQxe fDC2ScQ33BEYSPhAcv+sHHmTaj184M/1HsCHKDbO70czgU7yctab0O5kg Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="198231410" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:57 +0800 IronPort-SDR: UOgv+NfvySM60/ZytPwdFEnrEy7dBY6CxE33c1wEpDxVU2+GJZ7p9RpSSPXjbmDCkkmL297pJY YOpmLr1WGjraHtbc57OOaQKWa3mdP2T4fCefUYKpOyR2BF82crIJPbpHAGnIR4BPWiQfJhFUiz 8G4VO0hqqRtgIpV1IyvsqMfq64r0nYRVwXQ16qEIvlLl50pyXCKW8V2rB8Ba514Iwf9qPaUP/R Jih17w7TBRnsg+PomFL3dTH23lKJpCCn+QGQPiwcgg3qCMADhm8YrMxDL9WWlz84dWobwZsRg2 VcddQInkSmlEAJwQWWNbIX6T Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:32 -0800 IronPort-SDR: PCFn5R+ToNtCxPxl5JTp7aAE7LT96dYpsQexOWpEr1Wy/Qy5MdAfVMY+shrBYpgGog2lLZfPUh wCZ/D7LQ1OQGuqueVuGf3j+5C7x6B58GTR9vCRLsf5enhQNL6/qJvnuX6h7sgRTTKWvRcVfjWN LN4MuINQspIdVo2eeXHN+K6S1AioT/lVrTpGD4Xf+dBAPuHgYfXXpIIkw2WgPkbn022NwaUITl bcLHBWXoilY3/+13/cq/Gh/Vv81rmhouxKkH5hWzq9hg3xSCO0kGxnq8c3UmfaipKMPYYMr+5c y1s= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1VyT08Pcz1SVp7 for ; Sat, 19 Feb 2022 19:18: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=1645327133; x=1647919134; bh=RgVX2D4WNVM4UjW8Go zK4WDh6xFHzxqRq0/+exkDXLc=; b=nZFFbzcWpO1NKTxWVWY7J/RXkT7HR86aRx 7yhs+siltUJw7OuGbMQRtD54nKSjpYmHaRXm2z9aJWIUC2DPDS4NPWj43oUpiz0W f+U51Mx2FrlVpaA9EajLalsdqEBLRIVBg5OrTlqcfh7SwOWD6UE/5Y4oJgKngZkn P1NSjwqCXzeyF+ttQ3/7Hf4yiG+1mBkMf8UhwSoxh9Q/JkCxvhwThljKv7WVU1JX ca95huCTLTLUbSN76XrgyBMgR52koABhA3akI53LppburdClfFhmLos8bN/ZaRA7 pTX4EdUGwf2PFXTV5S8dE4NTrpGfBbWiCGQ/eMZ6/9T8lZSF8oOg== 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 L48rOlHg1jEO for ; Sat, 19 Feb 2022 19:18: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 4K1VyM5TH3z1Rwrw; Sat, 19 Feb 2022 19:18:51 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 27/31] scsi: pm8001: Simplify pm8001_mpi_build_cmd() interface Date: Sun, 20 Feb 2022 12:18:06 +0900 Message-Id: <20220220031810.738362-28-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There is no need to pass a pointer to a struct inbound_queue_table to pm8001_mpi_build_cmd(). Passing the start index in the inbound queue table of the adapter is enough. This change allows avoiding the declaration of a struct inbound_queue_table pointer (circularQ variables) in many functions, simplifying the code. While at it, blank lines are added i(e.g. after local variable declarations) to make the code more readable. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 154 +++++++++++-------------------- drivers/scsi/pm8001/pm8001_sas.h | 3 +- drivers/scsi/pm8001/pm80xx_hwi.c | 98 +++++++------------- 3 files changed, 89 insertions(+), 166 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index d45765aac148..eb6e09696b8b 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1309,21 +1309,20 @@ int pm8001_mpi_msg_free_get(struct inbound_queue_table *circularQ, * pm8001_mpi_build_cmd- build the message queue for transfer, update the PI to * FW to tell the fw to get this message from IOMB. * @pm8001_ha: our hba card information - * @circularQ: the inbound queue we want to transfer to HBA. + * @q_index: the index in the inbound queue we want to transfer to HBA. * @opCode: the operation code represents commands which LLDD and fw recognized. * @payload: the command payload of each operation command. * @nb: size in bytes of the command payload * @responseQueue: queue to interrupt on w/ command response (if any) */ int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha, - struct inbound_queue_table *circularQ, - u32 opCode, void *payload, size_t nb, + u32 q_index, u32 opCode, void *payload, size_t nb, u32 responseQueue) { u32 Header = 0, hpriority = 0, bc = 1, category = 0x02; void *pMessage; unsigned long flags; - int q_index = circularQ - pm8001_ha->inbnd_q_tbl; + struct inbound_queue_table *circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; int rv; u32 htag = le32_to_cpu(*(__le32 *)payload); @@ -1752,7 +1751,6 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct task_abort_req task_abort; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SATA_ABORT; int ret; @@ -1775,15 +1773,13 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, return; } - circularQ = &pm8001_ha->inbnd_q_tbl[0]; - memset(&task_abort, 0, sizeof(task_abort)); task_abort.abort_all = cpu_to_le32(1); task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); task_abort.tag = cpu_to_le32(ccb->ccb_tag); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, - sizeof(task_abort), 0); + ret = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &task_abort, + sizeof(task_abort), 0); if (ret) { sas_free_task(task); pm8001_ccb_free(pm8001_ha, ccb); @@ -1799,11 +1795,9 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, struct sas_task *task = NULL; struct host_to_dev_fis fis; struct domain_device *dev; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SATA_HOST_OPSTART; task = sas_alloc_slow_task(GFP_ATOMIC); - if (!task) { pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task !!!\n"); return; @@ -1834,9 +1828,6 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; - memset(&sata_cmd, 0, sizeof(sata_cmd)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; - /* construct read log FIS */ memset(&fis, 0, sizeof(struct host_to_dev_fis)); fis.fis_type = 0x27; @@ -1845,13 +1836,14 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, fis.lbal = 0x10; fis.sector_count = 0x1; + memset(&sata_cmd, 0, sizeof(sata_cmd)); sata_cmd.tag = cpu_to_le32(ccb->ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); sata_cmd.ncqtag_atap_dir_m = cpu_to_le32((0x1 << 7) | (0x5 << 9)); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); - res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, - sizeof(sata_cmd), 0); + res = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &sata_cmd, + sizeof(sata_cmd), 0); if (res) { sas_free_task(task); pm8001_ccb_free(pm8001_ha, ccb); @@ -3261,17 +3253,14 @@ static void pm8001_hw_event_ack_req(struct pm8001_hba_info *pm8001_ha, struct hw_event_ack_req payload; u32 opc = OPC_INB_SAS_HW_EVENT_ACK; - struct inbound_queue_table *circularQ; - memset((u8 *)&payload, 0, sizeof(payload)); - circularQ = &pm8001_ha->inbnd_q_tbl[Qnum]; payload.tag = cpu_to_le32(1); payload.sea_phyid_portid = cpu_to_le32(((SEA & 0xFFFF) << 8) | ((phyId & 0x0F) << 4) | (port_id & 0x0F)); payload.param0 = cpu_to_le32(param0); payload.param1 = cpu_to_le32(param1); - pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + pm8001_mpi_build_cmd(pm8001_ha, Qnum, opc, &payload, sizeof(payload), 0); } static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, @@ -4103,7 +4092,6 @@ static int pm8001_chip_smp_req(struct pm8001_hba_info *pm8001_ha, u32 req_len, resp_len; struct smp_req smp_cmd; u32 opc; - struct inbound_queue_table *circularQ; memset(&smp_cmd, 0, sizeof(smp_cmd)); /* @@ -4129,7 +4117,6 @@ static int pm8001_chip_smp_req(struct pm8001_hba_info *pm8001_ha, } opc = OPC_INB_SMP_REQUEST; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; smp_cmd.tag = cpu_to_le32(ccb->ccb_tag); smp_cmd.long_smp_req.long_req_addr = cpu_to_le64((u64)sg_dma_address(&task->smp_task.smp_req)); @@ -4140,8 +4127,8 @@ static int pm8001_chip_smp_req(struct pm8001_hba_info *pm8001_ha, smp_cmd.long_smp_req.long_resp_size = cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_resp)-4); build_smp_cmd(pm8001_dev->device_id, smp_cmd.tag, &smp_cmd); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, - &smp_cmd, sizeof(smp_cmd), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, + &smp_cmd, sizeof(smp_cmd), 0); if (rc) goto err_out_2; @@ -4169,9 +4156,7 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_dev = dev->lldd_dev; struct ssp_ini_io_start_req ssp_cmd; u32 tag = ccb->ccb_tag; - int ret; u64 phys_addr; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SSPINIIOSTART; memset(&ssp_cmd, 0, sizeof(ssp_cmd)); memcpy(ssp_cmd.ssp_iu.lun, task->ssp_task.LUN, 8); @@ -4187,7 +4172,6 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7); memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cmd->cmnd, task->ssp_task.cmd->cmd_len); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; /* fill in PRD (scatter/gather) table, if any */ if (task->num_scatter > 1) { @@ -4208,9 +4192,9 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.len = cpu_to_le32(task->total_xfer_len); ssp_cmd.esgl = 0; } - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &ssp_cmd, - sizeof(ssp_cmd), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &ssp_cmd, + sizeof(ssp_cmd), 0); } static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, @@ -4220,17 +4204,15 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, struct domain_device *dev = task->dev; struct pm8001_device *pm8001_ha_dev = dev->lldd_dev; u32 tag = ccb->ccb_tag; - int ret; struct sata_start_req sata_cmd; u32 hdr_tag, ncg_tag = 0; u64 phys_addr; u32 ATAP = 0x0; u32 dir; - struct inbound_queue_table *circularQ; unsigned long flags; u32 opc = OPC_INB_SATA_HOST_OPSTART; + memset(&sata_cmd, 0, sizeof(sata_cmd)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { ATAP = 0x04; /* no data*/ @@ -4316,9 +4298,8 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, } } - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, - sizeof(sata_cmd), 0); - return ret; + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &sata_cmd, + sizeof(sata_cmd), 0); } /** @@ -4330,11 +4311,9 @@ static int pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) { struct phy_start_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 tag = 0x01; u32 opcode = OPC_INB_PHYSTART; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(tag); /* @@ -4351,9 +4330,9 @@ pm8001_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) memcpy(payload.sas_identify.sas_addr, pm8001_ha->sas_addr, SAS_ADDR_SIZE); payload.sas_identify.phy_id = phy_id; - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opcode, &payload, + sizeof(payload), 0); } /** @@ -4365,17 +4344,15 @@ static int pm8001_chip_phy_stop_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) { struct phy_stop_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 tag = 0x01; u32 opcode = OPC_INB_PHYSTOP; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(tag); payload.phy_id = cpu_to_le32(phy_id); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opcode, &payload, + sizeof(payload), 0); } /* @@ -4387,7 +4364,6 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, struct reg_dev_req payload; u32 opc; u32 stp_sspsmp_sata = 0x4; - struct inbound_queue_table *circularQ; u32 linkrate, phy_id; int rc; struct pm8001_ccb_info *ccb; @@ -4397,7 +4373,6 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, struct domain_device *dev = pm8001_dev->sas_device; struct domain_device *parent_dev = dev->parent; struct pm8001_port *port = dev->port->lldd_port; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); @@ -4431,8 +4406,9 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, cpu_to_le32(ITNT | (firstBurstSize * 0x10000)); memcpy(payload.sas_addr, pm8001_dev->sas_device->sas_addr, SAS_ADDR_SIZE); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); if (rc) pm8001_ccb_free(pm8001_ha, ccb); @@ -4447,18 +4423,15 @@ int pm8001_chip_dereg_dev_req(struct pm8001_hba_info *pm8001_ha, { struct dereg_dev_req payload; u32 opc = OPC_INB_DEREG_DEV_HANDLE; - int ret; - struct inbound_queue_table *circularQ; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(1); payload.device_id = cpu_to_le32(device_id); pm8001_dbg(pm8001_ha, MSG, "unregister device device_id = %d\n", device_id); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); } /** @@ -4471,17 +4444,15 @@ static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, u32 phyId, u32 phy_op) { struct local_phy_ctl_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 opc = OPC_INB_LOCAL_PHY_CONTROL; + memset(&payload, 0, sizeof(payload)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(1); payload.phyop_phyid = cpu_to_le32(((phy_op & 0xff) << 8) | (phyId & 0x0F)); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); } static u32 pm8001_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha) @@ -4519,9 +4490,7 @@ static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc, u32 dev_id, u8 flag, u32 task_tag, u32 cmd_tag) { struct task_abort_req task_abort; - struct inbound_queue_table *circularQ; - int ret; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&task_abort, 0, sizeof(task_abort)); if (ABORT_SINGLE == (flag & ABORT_MASK)) { task_abort.abort_all = 0; @@ -4533,9 +4502,9 @@ static int send_task_abort(struct pm8001_hba_info *pm8001_ha, u32 opc, task_abort.device_id = cpu_to_le32(dev_id); task_abort.tag = cpu_to_le32(cmd_tag); } - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, - sizeof(task_abort), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &task_abort, + sizeof(task_abort), 0); } /* @@ -4575,9 +4544,7 @@ int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha, struct domain_device *dev = task->dev; struct pm8001_device *pm8001_dev = dev->lldd_dev; u32 opc = OPC_INB_SSPINITMSTART; - struct inbound_queue_table *circularQ; struct ssp_ini_tm_start_req sspTMCmd; - int ret; memset(&sspTMCmd, 0, sizeof(sspTMCmd)); sspTMCmd.device_id = cpu_to_le32(pm8001_dev->device_id); @@ -4587,10 +4554,9 @@ int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha, sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag); if (pm8001_ha->chip_id != chip_8001) sspTMCmd.ds_ads_m = cpu_to_le32(0x08); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd, - sizeof(sspTMCmd), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &sspTMCmd, + sizeof(sspTMCmd), 0); } int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, @@ -4600,7 +4566,6 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, u32 nvmd_type; int rc; struct pm8001_ccb_info *ccb; - struct inbound_queue_table *circularQ; struct get_nvm_data_req nvmd_req; struct fw_control_ex *fw_control_context; struct pm8001_ioctl_payload *ioctl_payload = payload; @@ -4611,7 +4576,6 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, return -ENOMEM; fw_control_context->usrAddr = (u8 *)ioctl_payload->func_specific; fw_control_context->len = ioctl_payload->rd_length; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&nvmd_req, 0, sizeof(nvmd_req)); ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); @@ -4678,8 +4642,9 @@ int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, default: break; } - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req, - sizeof(nvmd_req), 0); + + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &nvmd_req, + sizeof(nvmd_req), 0); if (rc) { kfree(fw_control_context); pm8001_ccb_free(pm8001_ha, ccb); @@ -4694,7 +4659,6 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, u32 nvmd_type; int rc; struct pm8001_ccb_info *ccb; - struct inbound_queue_table *circularQ; struct set_nvm_data_req nvmd_req; struct fw_control_ex *fw_control_context; struct pm8001_ioctl_payload *ioctl_payload = payload; @@ -4703,7 +4667,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, fw_control_context = kzalloc(sizeof(struct fw_control_ex), GFP_KERNEL); if (!fw_control_context) return -ENOMEM; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memcpy(pm8001_ha->memoryMap.region[NVMD].virt_ptr, &ioctl_payload->func_specific, ioctl_payload->wr_length); @@ -4762,7 +4726,8 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, default: break; } - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req, + + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &nvmd_req, sizeof(nvmd_req), 0); if (rc) { kfree(fw_control_context); @@ -4783,12 +4748,9 @@ pm8001_chip_fw_flash_update_build(struct pm8001_hba_info *pm8001_ha, { struct fw_flash_Update_req payload; struct fw_flash_updata_info *info; - struct inbound_queue_table *circularQ; - int ret; u32 opc = OPC_INB_FW_FLASH_UPDATE; memset(&payload, 0, sizeof(struct fw_flash_Update_req)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; info = fw_flash_updata_info; payload.tag = cpu_to_le32(tag); payload.cur_image_len = cpu_to_le32(info->cur_image_len); @@ -4799,9 +4761,9 @@ pm8001_chip_fw_flash_update_build(struct pm8001_hba_info *pm8001_ha, cpu_to_le32(lower_32_bits(le64_to_cpu(info->sgl.addr))); payload.sgl_addr_hi = cpu_to_le32(upper_32_bits(le64_to_cpu(info->sgl.addr))); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); } int @@ -4936,7 +4898,6 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_dev, u32 state) { struct set_dev_state_req payload; - struct inbound_queue_table *circularQ; struct pm8001_ccb_info *ccb; int rc; u32 opc = OPC_INB_SET_DEVICE_STATE; @@ -4947,13 +4908,12 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, if (!ccb) return -SAS_QUEUE_FULL; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(ccb->ccb_tag); payload.device_id = cpu_to_le32(pm8001_dev->device_id); payload.nds = cpu_to_le32(state); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); if (rc) pm8001_ccb_free(pm8001_ha, ccb); @@ -4964,7 +4924,6 @@ static int pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha) { struct sas_re_initialization_req payload; - struct inbound_queue_table *circularQ; struct pm8001_ccb_info *ccb; int rc; u32 opc = OPC_INB_SAS_RE_INITIALIZE; @@ -4975,14 +4934,13 @@ pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha) if (!ccb) return -SAS_QUEUE_FULL; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(ccb->ccb_tag); payload.SSAHOLT = cpu_to_le32(0xd << 25); payload.sata_hol_tmo = cpu_to_le32(80); payload.open_reject_cmdretries_data_retries = cpu_to_le32(0xff00ff); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); if (rc) pm8001_ccb_free(pm8001_ha, ccb); diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 00b4470634bd..9f5d6abba785 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -662,8 +662,7 @@ int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr, void pm8001_chip_iounmap(struct pm8001_hba_info *pm8001_ha); int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha, - struct inbound_queue_table *circularQ, - u32 opCode, void *payload, size_t nb, + u32 q_index, u32 opCode, void *payload, size_t nb, u32 responseQueue); int pm8001_mpi_msg_free_get(struct inbound_queue_table *circularQ, u16 messageSize, void **messagePtr); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 57ea933dab66..ce19aa361d26 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1182,7 +1182,6 @@ int pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) { struct set_ctrl_cfg_req payload; - struct inbound_queue_table *circularQ; int rc; u32 tag; u32 opc = OPC_INB_SET_CONTROLLER_CONFIG; @@ -1193,7 +1192,6 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) if (rc) return rc; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); if (IS_SPCV_12G(pm8001_ha->pdev)) @@ -1211,7 +1209,7 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) "Setting up thermal config. cfg_pg 0 0x%x cfg_pg 1 0x%x\n", payload.cfg_pg[0], payload.cfg_pg[1]); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); @@ -1228,7 +1226,6 @@ static int pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) { struct set_ctrl_cfg_req payload; - struct inbound_queue_table *circularQ; SASProtocolTimerConfig_t SASConfigPage; int rc; u32 tag; @@ -1238,11 +1235,9 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) memset(&SASConfigPage, 0, sizeof(SASProtocolTimerConfig_t)); rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) return rc; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); SASConfigPage.pageCode = cpu_to_le32(SAS_PROTOCOL_TIMER_CONFIG_PAGE); @@ -1284,7 +1279,7 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) memcpy(&payload.cfg_pg, &SASConfigPage, sizeof(SASProtocolTimerConfig_t)); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); @@ -1390,7 +1385,6 @@ pm80xx_get_encrypt_info(struct pm8001_hba_info *pm8001_ha) static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) { struct kek_mgmt_req payload; - struct inbound_queue_table *circularQ; int rc; u32 tag; u32 opc = OPC_INB_KEK_MANAGEMENT; @@ -1400,7 +1394,6 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) if (rc) return rc; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); /* Currently only one key is used. New KEK index is 1. * Current KEK index is 1. Store KEK to NVRAM is 1. @@ -1413,7 +1406,7 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) "Saving Encryption info to flash. payload 0x%x\n", le32_to_cpu(payload.new_curidx_ksop)); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); @@ -1770,7 +1763,6 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb; struct sas_task *task = NULL; struct task_abort_req task_abort; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SATA_ABORT; int ret; @@ -1794,15 +1786,13 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, return; } - circularQ = &pm8001_ha->inbnd_q_tbl[0]; - memset(&task_abort, 0, sizeof(task_abort)); task_abort.abort_all = cpu_to_le32(1); task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); task_abort.tag = cpu_to_le32(ccb->ccb_tag); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, - sizeof(task_abort), 0); + ret = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &task_abort, + sizeof(task_abort), 0); pm8001_dbg(pm8001_ha, FAIL, "Executing abort task end\n"); if (ret) { sas_free_task(task); @@ -1819,11 +1809,9 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, struct sas_task *task = NULL; struct host_to_dev_fis fis; struct domain_device *dev; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SATA_HOST_OPSTART; task = sas_alloc_slow_task(GFP_ATOMIC); - if (!task) { pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task !!!\n"); return; @@ -1856,7 +1844,6 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; memset(&sata_cmd, 0, sizeof(sata_cmd)); - circularQ = &pm8001_ha->inbnd_q_tbl[0]; /* construct read log FIS */ memset(&fis, 0, sizeof(struct host_to_dev_fis)); @@ -1871,8 +1858,8 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, sata_cmd.ncqtag_atap_dir_m_dad = cpu_to_le32(((0x1 << 7) | (0x5 << 9))); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); - res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, - sizeof(sata_cmd), 0); + res = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &sata_cmd, + sizeof(sata_cmd), 0); pm8001_dbg(pm8001_ha, FAIL, "Executing read log end\n"); if (res) { sas_free_task(task); @@ -3209,17 +3196,15 @@ static void pm80xx_hw_event_ack_req(struct pm8001_hba_info *pm8001_ha, struct hw_event_ack_req payload; u32 opc = OPC_INB_SAS_HW_EVENT_ACK; - struct inbound_queue_table *circularQ; - memset((u8 *)&payload, 0, sizeof(payload)); - circularQ = &pm8001_ha->inbnd_q_tbl[Qnum]; payload.tag = cpu_to_le32(1); payload.phyid_sea_portid = cpu_to_le32(((SEA & 0xFFFF) << 8) | ((phyId & 0xFF) << 24) | (port_id & 0xFF)); payload.param0 = cpu_to_le32(param0); payload.param1 = cpu_to_le32(param1); - pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + pm8001_mpi_build_cmd(pm8001_ha, Qnum, opc, &payload, + sizeof(payload), 0); } static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, @@ -4198,7 +4183,6 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, u32 req_len, resp_len; struct smp_req smp_cmd; u32 opc; - struct inbound_queue_table *circularQ; u32 i, length; u8 *payload; u8 *to; @@ -4227,7 +4211,6 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, } opc = OPC_INB_SMP_REQUEST; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; smp_cmd.tag = cpu_to_le32(ccb->ccb_tag); length = sg_req->length; @@ -4295,8 +4278,8 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, kunmap_atomic(to); build_smp_cmd(pm8001_dev->device_id, smp_cmd.tag, &smp_cmd, pm8001_ha->smp_exp_mode, length); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &smp_cmd, - sizeof(smp_cmd), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &smp_cmd, + sizeof(smp_cmd), 0); if (rc) goto err_out_2; return 0; @@ -4356,10 +4339,8 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_dev = dev->lldd_dev; struct ssp_ini_io_start_req ssp_cmd; u32 tag = ccb->ccb_tag; - int ret; u64 phys_addr, end_addr; u32 end_addr_high, end_addr_low; - struct inbound_queue_table *circularQ; u32 q_index, cpu_id; u32 opc = OPC_INB_SSPINIIOSTART; @@ -4383,7 +4364,6 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, task->ssp_task.cmd->cmd_len); cpu_id = smp_processor_id(); q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num); - circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; /* Check if encryption is set */ if (pm8001_ha->chip->encrypt && @@ -4500,9 +4480,9 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.esgl = 0; } } - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, - &ssp_cmd, sizeof(ssp_cmd), q_index); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, q_index, opc, &ssp_cmd, + sizeof(ssp_cmd), q_index); } static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, @@ -4513,7 +4493,6 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev = dev->lldd_dev; struct ata_queued_cmd *qc = task->uldd_task; u32 tag = ccb->ccb_tag; - int ret; u32 q_index, cpu_id; struct sata_start_req sata_cmd; u32 hdr_tag, ncg_tag = 0; @@ -4521,13 +4500,11 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, u32 end_addr_high, end_addr_low; u32 ATAP = 0x0; u32 dir; - struct inbound_queue_table *circularQ; unsigned long flags; u32 opc = OPC_INB_SATA_HOST_OPSTART; memset(&sata_cmd, 0, sizeof(sata_cmd)); cpu_id = smp_processor_id(); q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num); - circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { ATAP = 0x04; /* no data*/ @@ -4742,9 +4719,8 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, ccb->ccb_tag, opc, qc ? qc->tf.command : 0, // ata opcode ccb->device ? atomic_read(&ccb->device->running_req) : 0); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, - &sata_cmd, sizeof(sata_cmd), q_index); - return ret; + return pm8001_mpi_build_cmd(pm8001_ha, q_index, opc, &sata_cmd, + sizeof(sata_cmd), q_index); } /** @@ -4756,11 +4732,9 @@ static int pm80xx_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) { struct phy_start_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 tag = 0x01; u32 opcode = OPC_INB_PHYSTART; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(tag); @@ -4782,9 +4756,9 @@ pm80xx_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) memcpy(payload.sas_identify.sas_addr, &pm8001_ha->sas_addr, SAS_ADDR_SIZE); payload.sas_identify.phy_id = phy_id; - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opcode, &payload, + sizeof(payload), 0); } /** @@ -4796,17 +4770,15 @@ static int pm80xx_chip_phy_stop_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) { struct phy_stop_req payload; - struct inbound_queue_table *circularQ; - int ret; u32 tag = 0x01; u32 opcode = OPC_INB_PHYSTOP; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + memset(&payload, 0, sizeof(payload)); payload.tag = cpu_to_le32(tag); payload.phy_id = cpu_to_le32(phy_id); - ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, - sizeof(payload), 0); - return ret; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opcode, &payload, + sizeof(payload), 0); } /* @@ -4818,7 +4790,6 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, struct reg_dev_req payload; u32 opc; u32 stp_sspsmp_sata = 0x4; - struct inbound_queue_table *circularQ; u32 linkrate, phy_id; int rc; struct pm8001_ccb_info *ccb; @@ -4828,7 +4799,6 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, struct domain_device *dev = pm8001_dev->sas_device; struct domain_device *parent_dev = dev->parent; struct pm8001_port *port = dev->port->lldd_port; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; memset(&payload, 0, sizeof(payload)); ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); @@ -4869,7 +4839,7 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, memcpy(payload.sas_addr, pm8001_dev->sas_device->sas_addr, SAS_ADDR_SIZE); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_ccb_free(pm8001_ha, ccb); @@ -4889,18 +4859,18 @@ static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, u32 tag; int rc; struct local_phy_ctl_req payload; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_LOCAL_PHY_CONTROL; + memset(&payload, 0, sizeof(payload)); rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) return rc; - circularQ = &pm8001_ha->inbnd_q_tbl[0]; + payload.tag = cpu_to_le32(tag); payload.phyop_phyid = cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF)); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); @@ -4946,7 +4916,6 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, u32 tag, i, j = 0; int rc; struct set_phy_profile_req payload; - struct inbound_queue_table *circularQ; u32 opc = OPC_INB_SET_PHY_PROFILE; memset(&payload, 0, sizeof(payload)); @@ -4956,7 +4925,6 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, return; } - circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); payload.ppc_phyid = cpu_to_le32(((operation & 0xF) << 8) | (phyid & 0xFF)); @@ -4967,8 +4935,8 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha, payload.reserved[j] = cpu_to_le32(*((u32 *)buf + i)); j++; } - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); } @@ -4992,7 +4960,6 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, u32 tag, opc; int rc, i; struct set_phy_profile_req payload; - struct inbound_queue_table *circularQ; memset(&payload, 0, sizeof(payload)); @@ -5002,7 +4969,6 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, return; } - circularQ = &pm8001_ha->inbnd_q_tbl[0]; opc = OPC_INB_SET_PHY_PROFILE; payload.tag = cpu_to_le32(tag); @@ -5013,7 +4979,7 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, for (i = 0; i < length; i++) payload.reserved[i] = cpu_to_le32(*(buf + i)); - rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + rc = pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); if (rc) pm8001_tag_free(pm8001_ha, tag); From patchwork Sun Feb 20 03:18:07 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: 12752535 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 05D2DC433FE for ; Sun, 20 Feb 2022 03:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243429AbiBTDTd (ORCPT ); Sat, 19 Feb 2022 22:19:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241942AbiBTDT3 (ORCPT ); Sat, 19 Feb 2022 22:19:29 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9464D340D6 for ; Sat, 19 Feb 2022 19:18: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=1645327137; x=1676863137; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/k056LJjkDyJjxsjZ3Istng857ZtYijGwscrCmLzu0c=; b=P4cigfDFbjCx7lIrodTSDbLcvELcPSU8sqPUlLgSndYR4YYmjyjqC/0X bzdJkS3QygWB+RsY1xWFmduCEKMJQCJTjLr2InRlpkXZLWALFiPN5W+nm RW0MCTOLF+T2BQZ8Bo9xPG/xItEgv8xNwiXb86vcGwiP2J5TbvdXqodvd QMadyAHwleiae5KarlgDZnpKg8nMi8UqtJTW3iKnSvF12YFqtIpAARxn1 0kwZJgoH+ijZaI41jeeeDZ4h0aH3svmD85tmnySmFHOCUXnvrb+Yfiwaa Mk4J4vUXpdZPynCebNucS5fXTXoSEFIUwFf16ZWjBw1rOMJbTuUYs7boc Q==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405824" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:56 +0800 IronPort-SDR: QPnlRVCqbNWrkJj2zsC9SzLyu+inFuT/wiBWUu3hi5S52rGUZL8imaD8PDa/Wh17iieq+5jRGW eNipAziFVHZxruUQIOurmnkPt6f3pkef12ysBmMY+z1WcKZHYozeJdjlyQAr2OWpxnEk9YPx/o uahSh34VWWA2NL4zdoR5CluTZwKZFtLEVmAb79LoYaHLAUnUjwFjMWpAHcufLQWYeFu4zfTgkC IuTCLg2A7rAPNyeA4L/VVzgEX65OBCv7g3Zrp7Are6WvSVRe/0kDTmmi1WinYSkhTg3mcJpFrr caWpvnW3/HuQobsdkCS1qRew Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:32 -0800 IronPort-SDR: 68LroUA6efOCsgcECL2rCxpp9lHts5eWiOGUPlzfXlnru/IkS0ZyWB6dkDUfki23FpEF1kSQmT ji4EY61gA7176c9MVJwkRwN3KM35zpldsogS5esr7V9HHxBgo2KTKvh8t4cX7OJTPInKpUlrCY k48mkAKxssXWRsWrBGRwWf2XBjtDqTgn7JXLxKRxQ1xiWpsMxZqWaLelpplA3AZhkcxZS3KhKL V+tes5zr8jubsdnJ4N6GdpCOhTEl8fFgLnPKicY3Er9nn4zTsSC7GOGnVHzISLBAl1bqhaerRX eMs= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1VyS753cz1SVp6 for ; Sat, 19 Feb 2022 19:18: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=1645327135; x=1647919136; bh=/k056LJjkDyJjxsjZ3 Istng857ZtYijGwscrCmLzu0c=; b=uqy5314ab+TMKB/MTFKDoNF1hE8sL1xU/p FpBcGamJOARkoI9KFrAjHXytnfAGee49timVyMStZaFSvBKHXEZVoP5BA7pCFfpi cuBOPzbT70fEY7pI3XfgQ2rkFE8M9xaJh0tpo0PbJcbrM4eJwVYlTS0Aqbw8wjy6 eru4xBLpF+yXh65vzSNLxMzPsSLWGHCsZLzQ+4LrzGZz1AbvDI3Z58NbMKys64RB voFETXl3bynr32IDGPuwlCXCtX7jVYQ9Y9I0o1oOxszrplGHgFaijj69aYTIKVyq K6QFJ8EW70nacyQCkf7zVJDx+tgja2vg3qm8PwBQ7siEDog+iz8w== 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 lsukjGn5p-MH for ; Sat, 19 Feb 2022 19:18: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 4K1VyP5nz9z1Rvlx; Sat, 19 Feb 2022 19:18:53 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 28/31] scsi: pm8001: Simplify pm8001_task_exec() Date: Sun, 20 Feb 2022 12:18:07 +0900 Message-Id: <20220220031810.738362-29-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The main part of the pm8001_task_exec() function uses a do {} while(0) loop that is useless and only makes the code harder to read. Remove this loop. The unnecessary local variable t is also removed. Additionally, avoid repeatedly declaring "struct task_status_struct *ts" to handle error cases by declaring this variable for the entire function scope. This allows simplifying the error cases, and together with the addition of blank lines make the code more readable. Finally, handling of the running_req counter is fixed to avoid decrementing it without a corresponding incrementation in the case of an invalid task protocol. Signed-off-by: Damien Le Moal Reviewed-by: John Garry Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_sas.c | 170 ++++++++++++++----------------- 1 file changed, 78 insertions(+), 92 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 6e5d1af12230..ecd5cca2bb57 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -375,128 +375,114 @@ static int sas_find_local_port_id(struct domain_device *dev) */ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags) { + struct task_status_struct *ts = &task->task_status; + enum sas_protocol task_proto = task->task_proto; struct domain_device *dev = task->dev; + struct pm8001_device *pm8001_dev = dev->lldd_dev; struct pm8001_hba_info *pm8001_ha; - struct pm8001_device *pm8001_dev; struct pm8001_port *port = NULL; - struct sas_task *t = task; struct pm8001_ccb_info *ccb; - u32 rc = 0, n_elem = 0; - unsigned long flags = 0; - enum sas_protocol task_proto = t->task_proto; struct sas_tmf_task *tmf = task->tmf; int is_tmf = !!task->tmf; + unsigned long flags; + u32 n_elem = 0; + int rc = 0; if (!dev->port) { - struct task_status_struct *tsm = &t->task_status; - tsm->resp = SAS_TASK_UNDELIVERED; - tsm->stat = SAS_PHY_DOWN; + ts->resp = SAS_TASK_UNDELIVERED; + ts->stat = SAS_PHY_DOWN; if (dev->dev_type != SAS_SATA_DEV) - t->task_done(t); + task->task_done(task); return 0; } - pm8001_ha = pm8001_find_ha_by_dev(task->dev); - if (pm8001_ha->controller_fatal_error) { - struct task_status_struct *ts = &t->task_status; + pm8001_ha = pm8001_find_ha_by_dev(dev); + if (pm8001_ha->controller_fatal_error) { ts->resp = SAS_TASK_UNDELIVERED; - t->task_done(t); + task->task_done(task); return 0; } + pm8001_dbg(pm8001_ha, IO, "pm8001_task_exec device\n"); + spin_lock_irqsave(&pm8001_ha->lock, flags); - do { - dev = t->dev; - pm8001_dev = dev->lldd_dev; - port = &pm8001_ha->port[sas_find_local_port_id(dev)]; - if (DEV_IS_GONE(pm8001_dev) || !port->port_attached) { - if (sas_protocol_ata(task_proto)) { - struct task_status_struct *ts = &t->task_status; - ts->resp = SAS_TASK_UNDELIVERED; - ts->stat = SAS_PHY_DOWN; - spin_unlock_irqrestore(&pm8001_ha->lock, flags); - t->task_done(t); - spin_lock_irqsave(&pm8001_ha->lock, flags); - continue; - } else { - struct task_status_struct *ts = &t->task_status; - ts->resp = SAS_TASK_UNDELIVERED; - ts->stat = SAS_PHY_DOWN; - t->task_done(t); - continue; - } - } + pm8001_dev = dev->lldd_dev; + port = &pm8001_ha->port[sas_find_local_port_id(dev)]; - ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, t); - if (!ccb) { - rc = -SAS_QUEUE_FULL; - goto err_out; + if (DEV_IS_GONE(pm8001_dev) || !port->port_attached) { + ts->resp = SAS_TASK_UNDELIVERED; + ts->stat = SAS_PHY_DOWN; + if (sas_protocol_ata(task_proto)) { + spin_unlock_irqrestore(&pm8001_ha->lock, flags); + task->task_done(task); + spin_lock_irqsave(&pm8001_ha->lock, flags); + } else { + task->task_done(task); } + rc = -ENODEV; + goto err_out; + } - if (!sas_protocol_ata(task_proto)) { - if (t->num_scatter) { - n_elem = dma_map_sg(pm8001_ha->dev, - t->scatter, - t->num_scatter, - t->data_dir); - if (!n_elem) { - rc = -ENOMEM; - goto err_out_ccb; - } + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, task); + if (!ccb) { + rc = -SAS_QUEUE_FULL; + goto err_out; + } + + if (!sas_protocol_ata(task_proto)) { + if (task->num_scatter) { + n_elem = dma_map_sg(pm8001_ha->dev, task->scatter, + task->num_scatter, task->data_dir); + if (!n_elem) { + rc = -ENOMEM; + goto err_out_ccb; } - } else { - n_elem = t->num_scatter; } + } else { + n_elem = task->num_scatter; + } - t->lldd_task = ccb; - ccb->n_elem = n_elem; + task->lldd_task = ccb; + ccb->n_elem = n_elem; - switch (task_proto) { - case SAS_PROTOCOL_SMP: - atomic_inc(&pm8001_dev->running_req); - rc = pm8001_task_prep_smp(pm8001_ha, ccb); - break; - case SAS_PROTOCOL_SSP: - atomic_inc(&pm8001_dev->running_req); - if (is_tmf) - rc = pm8001_task_prep_ssp_tm(pm8001_ha, - ccb, tmf); - else - rc = pm8001_task_prep_ssp(pm8001_ha, ccb); - break; - case SAS_PROTOCOL_SATA: - case SAS_PROTOCOL_STP: - atomic_inc(&pm8001_dev->running_req); - rc = pm8001_task_prep_ata(pm8001_ha, ccb); - break; - default: - dev_printk(KERN_ERR, pm8001_ha->dev, - "unknown sas_task proto: 0x%x\n", task_proto); - rc = -EINVAL; - break; - } + atomic_inc(&pm8001_dev->running_req); - if (rc) { - pm8001_dbg(pm8001_ha, IO, "rc is %x\n", rc); - atomic_dec(&pm8001_dev->running_req); - goto err_out_ccb; - } - /* TODO: select normal or high priority */ - } while (0); - rc = 0; - goto out_done; + switch (task_proto) { + case SAS_PROTOCOL_SMP: + rc = pm8001_task_prep_smp(pm8001_ha, ccb); + break; + case SAS_PROTOCOL_SSP: + if (is_tmf) + rc = pm8001_task_prep_ssp_tm(pm8001_ha, ccb, tmf); + else + rc = pm8001_task_prep_ssp(pm8001_ha, ccb); + break; + case SAS_PROTOCOL_SATA: + case SAS_PROTOCOL_STP: + rc = pm8001_task_prep_ata(pm8001_ha, ccb); + break; + default: + dev_printk(KERN_ERR, pm8001_ha->dev, + "unknown sas_task proto: 0x%x\n", task_proto); + rc = -EINVAL; + break; + } + if (rc) { + atomic_dec(&pm8001_dev->running_req); + if (!sas_protocol_ata(task_proto) && n_elem) + dma_unmap_sg(pm8001_ha->dev, task->scatter, + task->num_scatter, task->data_dir); err_out_ccb: - pm8001_ccb_free(pm8001_ha, ccb); + pm8001_ccb_free(pm8001_ha, ccb); + err_out: - dev_printk(KERN_ERR, pm8001_ha->dev, "pm8001 exec failed[%d]!\n", rc); - if (!sas_protocol_ata(task_proto)) - if (n_elem) - dma_unmap_sg(pm8001_ha->dev, t->scatter, t->num_scatter, - t->data_dir); -out_done: + pm8001_dbg(pm8001_ha, IO, "pm8001_task_exec failed[%d]!\n", rc); + } + spin_unlock_irqrestore(&pm8001_ha->lock, flags); + return rc; } From patchwork Sun Feb 20 03:18:08 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: 12752541 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 C9132C433FE for ; Sun, 20 Feb 2022 03:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243426AbiBTDTn (ORCPT ); Sat, 19 Feb 2022 22:19:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243375AbiBTDTa (ORCPT ); Sat, 19 Feb 2022 22:19:30 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85618340DD for ; Sat, 19 Feb 2022 19:18: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=1645327139; x=1676863139; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4baZIJMM4uBqIcpGSfWCIseJ7c/gtGRLhWgjKFC85eI=; b=iQUmXTKnxUWop0edy2mjD/bt+9EQrGAagzitLoNm5dzkCD6E2PGNchDZ o8m8Jobf78iQsxf1lG9swUorHjdG21Hpa3Q2ygVVUMtG/4wHBganXg6GO qA73mhP/RHajrmJR1YNsdXaLfc00PfYscJzG03aOd9fhQoetlcqDvGhS9 XOXVGunk3/1xw5oTQ6Tfnl1hYssTCa4pNKk3EHvIiLhySKl1LKP1NcrYM uL+79HwgslRaQrHiu/qzVFJ6SX9RwM2yZz96lSOemdEYdjjSplK/SKOrv jcOhv2QtWzVuFzutktfZgmtvbTkOgN6IvcTJlnlUWot9rdus9OJ6dfAk/ A==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405829" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:58 +0800 IronPort-SDR: arCCaJ8MpPG/q71yBy2Kk4o4U2bsyhvMFR5nZMkTLwqQOunkAnHbJy6lyxcC6ZECSndKDE1Xj0 w6dcR7S0m0zppwXY23dJGnusx3IPoSIGeSejC1dJqwHmJy9tG6I00sgpak2veeqJPLFSSnMgu7 18e/qmtabo8i7s3ypeuwBtQa+Ufe+YXvRL/li1jn+B2zqM7QTEasdhOOuCT7kFDdEuIyu3GXI7 JgMzr9qD56Gc75o+RD5Wb8r6nXu8Qj8IcSSAUrQ8MW0q/SAT0wMRjpyu181SrMywp7Yjr3LoY0 aut/B/QqttQzV+R13+Y2XbOP Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:34 -0800 IronPort-SDR: jyM9gAAxmMMgplojNxBsH54BXkD90lGpnUIOHMM3k1hiaJYMfzBf4nfKmlTeCrzrOBs6wAGlNQ C7sgNtUzluJkytJ5Bmm27J8cGO89Bc7z/9ItMsb5t9fjsjeMfkgaO9tcM3/HpMh2QX9TkuPSt8 Zofx3STcXo2c5FHorusZCPUzpKNCoNBE6wZmKV87o1i6xVQ+qSFc/rb9l7DVZRFEcXoYDHi+AN 88caixQaPAjZgJHpDtlD51yHOTJF0iPrVN/FPfXSgzglaln/kyy8Uk3c9OLDFPzSOHWx9+19jk SbM= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:18: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 4K1VyV6YS5z1SVp0 for ; Sat, 19 Feb 2022 19:18: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=1645327137; x=1647919138; bh=4baZIJMM4uBqIcpGSf WCIseJ7c/gtGRLhWgjKFC85eI=; b=eHlCWUEb94LbBDwgzrwhCpUrgzOMFzR0nx THZCR/oP3eSNmz8PEbvhQ4C1uy3ZfqtxJ30TqIeWkYkc185Tp4S9ykLmbzenAi85 GNPpvHBrEvyzThXrTpdIB8wvQKX841qUQtwKrAvhmvNYbTSdDl2zZu7D33GvtV68 q71xzDsOS6QPxGsYIIh/fM8Pqh84gwMeoauYo5wSyB+imIFltp/iUrbRS5WOzbm9 WXrAqxbvqHeYiuVRtxsp9X54EE/NGaMDqksCiXPkN7t6dM5/ObNzvsw2CaHWgJmB 5PtNpL91ChcnAvSA7GoThaoakUulJtl+iZwtNb4Yg8OoWU3bwNRQ== 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 NVilhxt0AEkq for ; Sat, 19 Feb 2022 19:18: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 4K1VyS1Nh1z1SVp1; Sat, 19 Feb 2022 19:18:55 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 29/31] scsi: pm8001: Simplify pm8001_ccb_task_free() Date: Sun, 20 Feb 2022 12:18:08 +0900 Message-Id: <20220220031810.738362-30-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The task argument of the pm8001_ccb_task_free() function can be infered from the ccb argument ccb_task field. So there is no need to have this argument. Likewise, the ccb_index argument is always equal to the ccb tag field and is not needed either. Remove both arguments and update all call sites. The pm8001_ccb_task_free_done() helper is also modified to match this change. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 42 +++++++++++++++----------------- drivers/scsi/pm8001/pm8001_sas.c | 25 +++++++++---------- drivers/scsi/pm8001/pm8001_sas.h | 12 ++++----- drivers/scsi/pm8001/pm80xx_hwi.c | 35 ++++++++++++-------------- 4 files changed, 52 insertions(+), 62 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index eb6e09696b8b..1569aa483af5 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1564,11 +1564,11 @@ void pm8001_work_fn(struct work_struct *work) spin_unlock_irqrestore(&t->task_state_lock, flags1); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with event 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, pw->handler, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); + pm8001_ccb_task_free(pm8001_ha, ccb); spin_unlock_irqrestore(&pm8001_ha->lock, flags); } else { spin_unlock_irqrestore(&t->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb();/* in order to force CPU ordering */ spin_unlock_irqrestore(&pm8001_ha->lock, flags); t->task_done(t); @@ -1697,8 +1697,7 @@ void pm8001_work_fn(struct work_struct *work) continue; } /*complete sas task and update to top layer */ - pm8001_ccb_task_free(pm8001_ha, task, ccb, - ccb->ccb_tag); + pm8001_ccb_task_free(pm8001_ha, ccb); ts->resp = SAS_TASK_COMPLETE; task->task_done(task); } else if (ccb->ccb_tag != PM8001_INVALID_TAG) { @@ -2084,10 +2083,10 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) spin_unlock_irqrestore(&t->task_state_lock, flags); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb();/* in order to force CPU ordering */ t->task_done(t); } @@ -2251,10 +2250,10 @@ static void mpi_ssp_event(struct pm8001_hba_info *pm8001_ha, void *piomb) spin_unlock_irqrestore(&t->task_state_lock, flags); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with event 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, event, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb();/* in order to force CPU ordering */ t->task_done(t); } @@ -2480,7 +2479,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2496,7 +2495,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2518,7 +2517,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2589,7 +2588,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_DS_NON_OPERATIONAL); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2609,7 +2608,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) IO_DS_IN_ERROR); ts->resp = SAS_TASK_UNDELIVERED; ts->stat = SAS_QUEUE_FULL; - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return; } break; @@ -2639,10 +2638,10 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); } } @@ -2994,12 +2993,10 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) spin_unlock_irqrestore(&t->task_state_lock, flags); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); - mb();/* in order to force CPU ordering */ - t->task_done(t); + pm8001_ccb_task_free_done(pm8001_ha, ccb); } } @@ -3649,7 +3646,7 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) t->task_state_flags &= ~SAS_TASK_STATE_PENDING; t->task_state_flags |= SAS_TASK_STATE_DONE; spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb(); if (pm8001_dev->id & NCQ_ABORT_ALL_FLAG) { @@ -4287,12 +4284,11 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, "task 0x%p resp 0x%x stat 0x%x but aborted by upper layer\n", task, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&task->task_state_lock, flags); - pm8001_ccb_task_free_done(pm8001_ha, task, - ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); return 0; } } diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index ecd5cca2bb57..ac9c40c95070 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -489,22 +489,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: @@ -523,12 +522,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); } @@ -844,11 +843,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 9f5d6abba785..6bbf118f61e7 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -637,7 +637,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); @@ -780,12 +780,12 @@ static inline void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, pm8001_tag_free(pm8001_ha, tag); } -static inline void -pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, - struct sas_task *task, struct pm8001_ccb_info *ccb, - u32 ccb_idx) +static inline void pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, + struct pm8001_ccb_info *ccb) { - pm8001_ccb_task_free(pm8001_ha, task, ccb, ccb_idx); + struct sas_task *task = ccb->task; + + pm8001_ccb_task_free(pm8001_ha, ccb); smp_mb(); /*in order to force CPU ordering*/ task->task_done(task); } diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index ce19aa361d26..b5e1aaa0fd58 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -2157,14 +2157,12 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); if (t->slow_task) complete(&t->slow_task->completion); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); - mb();/* in order to force CPU ordering */ - t->task_done(t); + pm8001_ccb_task_free_done(pm8001_ha, ccb); } } @@ -2340,12 +2338,10 @@ static void mpi_ssp_event(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with event 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, event, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); - mb();/* in order to force CPU ordering */ - t->task_done(t); + pm8001_ccb_task_free_done(pm8001_ha, ccb); } } @@ -2579,7 +2575,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2599,7 +2595,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2627,7 +2623,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2702,7 +2698,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2726,7 +2722,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_QUEUE_FULL; spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); return; @@ -2760,14 +2756,14 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); if (t->slow_task) complete(&t->slow_task->completion); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); spin_unlock_irqrestore(&circularQ->oq_lock, circularQ->lock_flags); - pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); spin_lock_irqsave(&circularQ->oq_lock, circularQ->lock_flags); } @@ -3171,10 +3167,10 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with io_status 0x%x resp 0x%xstat 0x%x but aborted by upper layer!\n", t, status, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); } else { spin_unlock_irqrestore(&t->task_state_lock, flags); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); mb();/* in order to force CPU ordering */ t->task_done(t); } @@ -4702,13 +4698,12 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, "task 0x%p resp 0x%x stat 0x%x but aborted by upper layer\n", task, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, ccb); return 0; } else { spin_unlock_irqrestore(&task->task_state_lock, flags); - pm8001_ccb_task_free_done(pm8001_ha, task, - ccb, tag); + pm8001_ccb_task_free_done(pm8001_ha, ccb); atomic_dec(&pm8001_ha_dev->running_req); return 0; } From patchwork Sun Feb 20 03:18:09 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: 12752539 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 B1A15C433EF for ; Sun, 20 Feb 2022 03:19:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243405AbiBTDTj (ORCPT ); Sat, 19 Feb 2022 22:19:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243423AbiBTDTa (ORCPT ); Sat, 19 Feb 2022 22:19:30 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AAF5340DE for ; Sat, 19 Feb 2022 19:19: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=1645327140; x=1676863140; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2Z+aMqX2UUAp+gMmZBRjOT5kqmxmwBLTUlXWPM74m6U=; b=Qz6jN6z4RfxeiNmUAHzOGsDyPOWpwiXoqXxYdo8HDjXqmDJCLOyjPWOa VlUFWSrhTEnmPww5nQTSaVgD2y2IPtxtjB/AJTweO1m8qHiE3Ft/+x5YV uqFKTFGDE+QIiMMpadqcmMNlJwjLU1ctcTNjAsV9er7uU8rcRZRK/YDzf vYjRdfDTWAt33grV+s4cOg8rqSiakSs54qU2hpVPULT9zP373F6v+PBtT 5Gy+ieI/Ky0HbzUsykZ3dgCrUaSBLFm9uPNxzGxwTrl23lcdHvtNBb+or gflOztXTp+f/mWhEqZHX7xwwrqkIQdGby1hvVEC6xEG0Ou4WnZPmKFrhF A==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405830" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:18:59 +0800 IronPort-SDR: 5LK7X7iOcmDJsOsFCKqbULazvf2FEALzZ5vnx6wmi4w9b3ETNpKQX9mH9PIhJXPTsnb7mXKHf2 +Vjh0fQ6Eu1nWd3iV7BDWk6jw/YR3rPTn1ngDKT9izrUHGy+OYgTTNybDhvOY62nayn8cSHoBY M4rk9XDJdCDo5OIjJ+7oumUBoy3xnRZkjAkhKGfWVizgJBGCgJLZ4ZSBXAYEAeXfOxTTSyy+fq R2XMeRsyoOdIeajqeGxkthMGOyTbkzm0021JZfDsiOe6m93BaXFJkNrmJ7pMpQncs6xPkmogHz FzgXRhuFTE4LKiX3OS1FhsGp Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:35 -0800 IronPort-SDR: wG6djnmun8EVzdRJr8xudpNPoQm2yEiiSMVYBUii13i+QK1uLuHMnHLCXGqrJNlECk2y2J7AJE 6YwtaLlqNbp3imiJfTIImGyZd2ezducacUw1q0twGZDTzQr7eFaXGkkFbNoYSw+FZu0bRTCClD NEukwX+rSgQNdN0SoQACrsXFNFyNTldo/MtnQt9aCT2by4qlmFLZ+WB+sZjGPGSLNETThp8kI/ KzeKHhuO8fdVazFRmDgwUDBubms/RliPHQrL67diPvCP5+qA4NQWI9PoxrR/ZXxgDjhVt48DnE mBc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:19: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 4K1VyX02LKz1SVp2 for ; Sat, 19 Feb 2022 19:19: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=1645327139; x=1647919140; bh=2Z+aMqX2UUAp+gMmZB RjOT5kqmxmwBLTUlXWPM74m6U=; b=f/Qp/gWy1506/wPkRVA4LFH9d3ZPlVeOzG 1DAXNTvKStoCvtiqrhwrxf0SZweJZUd62YK9a62OwX6yfal22qcuuD71ISKBlEZ7 mgdUsAl471jTAzCp/MwztV1wjYGHGjpsCAiFf1/aAT/nKDgnFsMpbdfDTHJGu+GD FKRA3Su5HNMecAnhGXip501P4mL8kLq9IWJ03P4N7JMJq0ksNfkRFGVxHzlKhcLT 7kffF0166XIKCQQPfOdhCldYRP3iRPdU6EKJ3Izd7CE55DE0y97Wd6EWB1yx2yg3 EnfJXI9ak8EB3AvQNSb3D+/MrqwRYwAvTdEmIKtzSCodveb538zA== 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 rEb_fW6S3YNI for ; Sat, 19 Feb 2022 19:18: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 4K1VyT6Q5Jz1Rvlx; Sat, 19 Feb 2022 19:18:57 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 30/31] scsi: pm8001: improve pm80XX_send_abort_all() Date: Sun, 20 Feb 2022 12:18:09 +0900 Message-Id: <20220220031810.738362-31-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Both pm8001_send_abort_all() and pm80xx_send_abort_all() are called only for a non null device with the NCQ_READ_LOG_FLAG set, so remove the device check on entry of these functions. Furthermore, setting the NCQ_ABORT_ALL_FLAG device id flag and clearing the NCQ_READ_LOG_FLAG is always done before calling these functions. Move these operations inside the functions. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_hwi.c | 14 ++++---------- drivers/scsi/pm8001/pm80xx_hwi.c | 16 ++++------------ 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 1569aa483af5..048ff41852c9 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1748,15 +1748,13 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev) { struct pm8001_ccb_info *ccb; - struct sas_task *task = NULL; + struct sas_task *task; struct task_abort_req task_abort; u32 opc = OPC_INB_SATA_ABORT; int ret; - if (!pm8001_ha_dev) { - pm8001_dbg(pm8001_ha, FAIL, "dev is null\n"); - return; - } + pm8001_ha_dev->id |= NCQ_ABORT_ALL_FLAG; + pm8001_ha_dev->id &= ~NCQ_READ_LOG_FLAG; task = sas_alloc_slow_task(GFP_ATOMIC); if (!task) { @@ -2358,11 +2356,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) ts->stat = SAS_SAM_STAT_GOOD; /* check if response is for SEND READ LOG */ if (pm8001_dev && - (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { - /* set new bit for abort_all */ - pm8001_dev->id |= NCQ_ABORT_ALL_FLAG; - /* clear bit for read log */ - pm8001_dev->id = pm8001_dev->id & 0x7FFFFFFF; + (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { pm8001_send_abort_all(pm8001_ha, pm8001_dev); /* Free the tag */ pm8001_tag_free(pm8001_ha, tag); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index b5e1aaa0fd58..9bb31f66db85 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1761,23 +1761,19 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, struct pm8001_device *pm8001_ha_dev) { struct pm8001_ccb_info *ccb; - struct sas_task *task = NULL; + struct sas_task *task; struct task_abort_req task_abort; u32 opc = OPC_INB_SATA_ABORT; int ret; - if (!pm8001_ha_dev) { - pm8001_dbg(pm8001_ha, FAIL, "dev is null\n"); - return; - } + pm8001_ha_dev->id |= NCQ_ABORT_ALL_FLAG; + pm8001_ha_dev->id &= ~NCQ_READ_LOG_FLAG; task = sas_alloc_slow_task(GFP_ATOMIC); - if (!task) { pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task\n"); return; } - task->task_done = pm8001_task_done; ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); @@ -2446,11 +2442,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, ts->stat = SAS_SAM_STAT_GOOD; /* check if response is for SEND READ LOG */ if (pm8001_dev && - (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { - /* set new bit for abort_all */ - pm8001_dev->id |= NCQ_ABORT_ALL_FLAG; - /* clear bit for read log */ - pm8001_dev->id = pm8001_dev->id & 0x7FFFFFFF; + (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { pm80xx_send_abort_all(pm8001_ha, pm8001_dev); /* Free the tag */ pm8001_tag_free(pm8001_ha, tag); From patchwork Sun Feb 20 03:18:10 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: 12752540 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 9A446C433EF for ; Sun, 20 Feb 2022 03:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237791AbiBTDTl (ORCPT ); Sat, 19 Feb 2022 22:19:41 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243426AbiBTDTa (ORCPT ); Sat, 19 Feb 2022 22:19:30 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82A4F340DF for ; Sat, 19 Feb 2022 19:19: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=1645327141; x=1676863141; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2A6Xvm2+8LayS7L2VYBx1aN5agZihl1mgosK4OO3c78=; b=jolg8J7DIkDJEtEOn/jI5lmMZn3KHuLrVfgxWrDy1IVlYQ9+1qgdHSZX w57jkaA4HZsKsGalHVcaLYewkcveLERhC1qvy5J70KpfxFtzlnmB3jBsC cALCNR/p600BUFfkpFiY3C3n6lIyvT7N7kultWRrj3vRbPztK1xbtyfbU nX0Awft+e6z4gFVaMPa4xboZuvpo6BMGjH+sCrDHY8yAkf4knpg53XA4Q VUTjuUgugjhrWbEszixR6vIUvHF9abqeuk2pKR6tESb8q01PUR5zm8uDT XtxDEDuX9QLX8EsWvvWqGluhguYjVeWCEkTn+l4W4kTDLy3e50CXndgN8 g==; X-IronPort-AV: E=Sophos;i="5.88,382,1635177600"; d="scan'208";a="193405832" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2022 11:19:00 +0800 IronPort-SDR: q+SWtaZ7DAAK0ygggBy4w/IqEzScujbwT2QRkinp1YZVp4y9iTV7TOIcTsJkYTFcYib+jOj/2b rS0DjxDWWuBuN50p8DXYWYi36MQy7lNU7l08+sZvUFrPMuIB4Fd+KqdENT/jFGHpAUXNxqktqN nZ+QLR0kTJfstQkESh8+bUTQBPHtyY7vNwhFEBK/oeOPhmlLEsfXNYm2sgDZ7uEnv7OIORMHaD l4zmeXuk9vlwpmrggOGIsEZIzSGI/pTA9JeM1G6M7EZ/9wgE4zhhAWAIw5z9xj//Xwl1H/ZeL8 96EUl8FhYel2eM+/kQ2GcdUD Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 18:50:36 -0800 IronPort-SDR: UUR6c5dcVfMsIxwMqaFSq7rCfAyR32g/xoA/QOc6bXQjjEbZvx4e8BaQI2d9vUf2nqTVVAZlU2 vd8/rhmVTcU5YC+YffuJd3E+SgWrPjXkytoFiwHj9cyH4tvjVs8dw/DjEmQR1fw7NCY7HJD/pw WteOXr30kRcD/yEvadYv0Vk2rRTKdhL6wNNbsZr8Rhoh4MT3p/3/o21QjWwYOCTO41g+RlwEKn w0pF5oHisgkvafH/6IqC2qkS0RaclO1brlU6oEXp9anQBXJ/H8vma2vynPIzzOEWXQKhB8yOb+ Lds= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 19:19:01 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4K1VyY0kS9z1Rvlx for ; Sat, 19 Feb 2022 19:19: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=1645327140; x=1647919141; bh=2A6Xvm2+8LayS7L2VY Bx1aN5agZihl1mgosK4OO3c78=; b=PA/masRTjpexVx74NyHFhMEM8kiuf+Ty3M 47Cw3IkBk43RFuTrAu/jKS2O2Cd+hWF6UwLfhT6nHcHRlkVgKASnEXyJYpse5z3x AzbnbMObriOtrKpcbCKhaoXvhUON81o2+GBXd+nMhkMt7nJ4r9FUvVMRTyH+M2Bg v7dDf6wiUO65h/bpDev29tc+AAeaIfo+7yBzPQMyKwAHPM649bMh1CP2pyZA8I6V Ihjgw+frywsKq9HTa8JCvMnHJAcj0t72hVkxNJejKSwKxXTs2YxHJXRk8bxE9g1c 5ilO51Z92fI2GrdZowjdR0KFPojKAqjxbb7VYfkmM85A8wqTB4lA== 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 AKfEIDtuwtgg for ; Sat, 19 Feb 2022 19:19:00 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4K1VyW4grwz1Rwrw; Sat, 19 Feb 2022 19:18:59 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jack Wang , John Garry Cc: Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v6 31/31] scsi: pm8001: Fix pm8001_info() message format Date: Sun, 20 Feb 2022 12:18:10 +0900 Message-Id: <20220220031810.738362-32-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> References: <20220220031810.738362-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make the driver messages more readable by adding a space after the message prefix ":" and removing the extra space between function name and line number. Signed-off-by: Damien Le Moal Reviewed-by: Jack Wang --- drivers/scsi/pm8001/pm8001_sas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index 6bbf118f61e7..d522bd0bb46b 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -71,7 +71,7 @@ #define PM8001_IOERR_LOGGING 0x200 /* development io err message logging */ #define pm8001_info(HBA, fmt, ...) \ - pr_info("%s:: %s %d:" fmt, \ + pr_info("%s:: %s %d: " fmt, \ (HBA)->name, __func__, __LINE__, ##__VA_ARGS__) #define pm8001_dbg(HBA, level, fmt, ...) \