From patchwork Fri Feb 11 07:36: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: 542044 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 27104C433F5 for ; Fri, 11 Feb 2022 07:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347704AbiBKHhK (ORCPT ); Fri, 11 Feb 2022 02:37:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347699AbiBKHhJ (ORCPT ); Fri, 11 Feb 2022 02:37:09 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9446510D6 for ; Thu, 10 Feb 2022 23:37:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644565027; x=1676101027; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=V82tCpFaYvpcK1xKWfEXtOUXB3QC/wmQbMrXpEthOUo=; b=BtXlT71pSXjjY6gRNGGcG+fnVDKQDVDEIDUw/uLP0ymkrJ8yqK6xovZ6 8fyysmzWUrRM1d9oU7Mkqvm4xGbXgMLDbf6gkFYFwi07QnGvgJqOX8RCc 0XZXwo4tGdQVXxb+rGVFWt+QjTEc99SdDimM64Sba64ny2qBpRoAjij+U yApczkfEov3+/UycnBv31fTXs+ZS01Qdlivm+R1U2glJha09kOtvX2P1I 5i08Vgv0Oi5WkgNE1hAXqHKGCx8yrQkBRw+S5aXESp4tfqmmHmQqO4+gE GbJi0uxgqs15B02SXHaRMKpaufmg8JPKSPlqHCi7x1ZLk7Zow+Pcp08At g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675111" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:06 +0800 IronPort-SDR: 6G/jW7sFYD+hJiozLBc3cqSB9HscPzVpM9dj3kbT99i6YHXglM+RdTA0siNpmRNJSC/cFSotzl B3YT7IvfiRzsrP6OpTJ2/d/RaxEH1zyJfyC0iV5HEeceJHVHgDHcq149C8cnenjzJbK76WdHkK SEcCcXBiIHX3LHFvHdtg+OMVZ/5zLfm0Gr+HrScaoV9oHHyKUYImnjsozQHEZKOxAOTU5C/Mla GAbNw4yDms3JXbnWJDx5utLxOyPYcI/t7/hkLJ3Xm0iEOwW5tpSTUlB+15WLjsaH7KADcbrK1t rfiUMo8zXHRfi5GcPxNI9ZFV Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:08:55 -0800 IronPort-SDR: TDveD8tKKOIxbpud9ntwLZZooAojR2N0pWaJlXSRZ0CI+Qr2nrHVi3DYcqFnF91BSEcGG40zwP Q0FOtDPjwiX54SoDObKAR5ShGzs6L4Mp8CbB6xW3LvP+92vk7srGEXcVz7viZGyeTIkbPlKEBr TLcuHNyHQuxCZjDiMJ4b4CwVZmKuU4inGYunapjxFnV2aDzt9TCnBJ5IZelR1Cr5grg4MLqvn/ ewsukR8l3c4eU5fnIT9HODpmzeW/KBDWA2hAsK3qmukaV459ie9TleTWOyj6nW6xmHC8IFxZdu J/w= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:09 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw56X3PkPz1SVny for ; Thu, 10 Feb 2022 23:37:08 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565028; x=1647157029; bh=V82tCpFaYvpcK1xKWf EXtOUXB3QC/wmQbMrXpEthOUo=; b=I5HA9iQd1+3J25KeWE0eoK0Cpl90vjTHih 6ZOziJ10+5y26Nk4wrwbWDxLyEf87PqJuDHp7OfF1vU7RGCDsV51JJWrlDUXcrzY ds61XfV/j1E1bvS+asyh3W1m9hTQ2CVbh9wEa+FLvbuToB+GqM5PJ5Pdjj+20fwK Qv0qtcSrPjCO/mcsBqSUF+lVnEMfp2wp9xgVMZvs6t3zzd2FXI/HLgU8tuA5SQ2b fObCFHR5zoHpgYd+/ZXKHvRwsjWiq3tO1ML/o+BE0GmDYay0afgOTDs0d1OtmL2h Ut5DVe9QfYb+XDDhDvLhNpNR/iSP751YQn1cCGSjMyMj9W0aQGwg== 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 gD7IYj5zDaqr for ; Thu, 10 Feb 2022 23:37:08 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56W0km9z1SHwl; Thu, 10 Feb 2022 23:37:06 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 01/24] scsi: libsas: fix sas_ata_qc_issue() handling of NCQ NON DATA commands Date: Fri, 11 Feb 2022 16:36:41 +0900 Message-Id: <20220211073704.963993-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect for the DMA_NONE (no data transfer) DMA direction, sas_ata_qc_issue() tests if the command protocol is ATA_PROT_NODATA. This test does not include the ATA_CMD_NCQ_NON_DATA command as this command protocol is defined as ATA_PROT_NCQ_NODATA (equal to ATA_PROT_FLAG_NCQ) and not as ATA_PROT_NODATA. To include both NCQ and non-NCQ commands when testing for the DMA_NONE DMA direction, use "!ata_is_data()". Fixes: 176ddd89171d ("scsi: libsas: Reset num_scatter if libata marks qc as NODATA") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal --- drivers/scsi/libsas/sas_ata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index a315715b3622..7e0cde710fc3 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -197,7 +197,7 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) task->total_xfer_len = qc->nbytes; task->num_scatter = qc->n_elem; task->data_dir = qc->dma_dir; - } else if (qc->tf.protocol == ATA_PROT_NODATA) { + } else if (!ata_is_data(qc->tf.protocol)) { task->data_dir = DMA_NONE; } else { for_each_sg(qc->sg, sg, qc->n_elem, si) From patchwork Fri Feb 11 07:36: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: 542320 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 383F1C433EF for ; Fri, 11 Feb 2022 07:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347707AbiBKHhT (ORCPT ); Fri, 11 Feb 2022 02:37:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347705AbiBKHhK (ORCPT ); Fri, 11 Feb 2022 02:37:10 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 373C710B1 for ; Thu, 10 Feb 2022 23:37:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644565028; x=1676101028; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=62dKy7FJi/LOczLf/foDrU5lssulm4RAJbK5vqkwQOQ=; b=T9z5/AS099YLB8/mDkcvsHIoekEkebYPXD2Ua1K3TRrOm0pEZ55UNYRM 0Y9PtjDAGvm4qoQ9lPH1pjS1hBbeRQitrYndsNoWxIaTjjgW4hMJQR8Nv 10B+vr7Ij1o4jRbPYuIPNml8arn3/PyL3sQVVcqhdl2ZDG4MahNtpyWUK ZLQwp5RygLlXrczn+JHCq+GsG2QCwymK3TUtfXgG89aMxzkFS9wA6RWAb 2gKPALXl6WJ5ieNjpehiNfhxkWc2LgGSZtqrwjBYICcWK1yOBkhan8qru 9/fbiY/4aQl0cbNsoCo3WdctQLzOdgSsxaOEHxxziPG9I2SZLFncMP2hV g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675114" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:08 +0800 IronPort-SDR: uLrAk+c1wl8cNxoWKLJTEA0XQLJw9vbZVOqIKZkfrKb+2wbJAQceBmgPN6X40cKJd3hVKb3Ajq /vGiXzPFtDpGuRanUiaGfngnuF8AufdppPISRk4Ieald2CxPGTprFfyMOkRkLiH7BlLNHj2upl KKNkccp+Wp9SO7FXyUZ4CDOdPVSrNeC2xpZ7PJFFZRDIDyql1QltcjEHz0CgyRJDjVZUWPDT+M vFrzWCp45tBWrGEfhrdTfVu4vR47FULiGWh0Tyxo2G7EmSdDOnxrOrWaCTdAhOz/fvvbEYvzb4 IAicpwppai99FB7r9CSW0Fy6 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:08:56 -0800 IronPort-SDR: R7b8/x9zVGeMdtlr2kwaNoIe4r63MfmBNi4EFyUmtvefPEqL2U4Nnc3LPigC0FuLcnjvs40fcA PsFS5d5I2TDwkuli0zjv32yal62h/RDvnD510sqvjfC7VwXqYoYoR6TYetSe2uPUf7fuCRRAiR 00n0tjE7ebbh/rFJv77X7y6staIg7Njl0lMsCE2JqUc/cutOqnmbZ+LF1AMCRvlimj0otQz8sl 48Py42knjMrOAiiHMZtt0etAcfTJULPuszkZLwPGBO+yvXXulZeEwpdwcCLk6G7G4aZJhC11AI 7i0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:10 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw56Y5gJjz1SVp1 for ; Thu, 10 Feb 2022 23:37:09 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565029; x=1647157030; bh=62dKy7FJi/LOczLf/f oDrU5lssulm4RAJbK5vqkwQOQ=; b=uDeAXfYx3RwHrSl/Rz8PdWbkQ8cwSsppLk XB2jfDE325GcPDbeZbiihKRVml2gkRsCH8sMBZOR5CMoksc6dreoSNxVGa8mXQch NULZwfslTkLYjdUuMleG3x1js18jXtRc6E3+9Cc62aoxTa//0FKDkgwCBSfxJjSe un6FuA4YVhLEPCYJgz97pX4V/TgDE3bkMiBXBF/RLAccE4KTDyLSlQq34jcf7Ldz 6ap/NYHSbbD765wulRZlf2jLaJFn52Rl+7c+lZB9b7KJ/y07uyKTqwg2KhL2FzrO cvoCFWBjJK2YV1avV/C8AgcA+C3t4pHyE0HFs4LNNtyKcRf6in/w== 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 C-yaX5OlT9Qe for ; Thu, 10 Feb 2022 23:37:09 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56X2Ncjz1Rwrw; Thu, 10 Feb 2022 23:37:08 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 02/24] scsi: libsas: simplify sas_ata_qc_issue() detection of NCQ commands Date: Fri, 11 Feb 2022 16:36:42 +0900 Message-Id: <20220211073704.963993-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect if a command is NCQ, there is no need to test all possible NCQ command codes. Instead, use ata_is_ncq() to test the command protocol. Signed-off-by: Damien Le Moal --- drivers/scsi/libsas/sas_ata.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 7e0cde710fc3..99549862c9c7 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -181,14 +181,9 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) task->task_proto = SAS_PROTOCOL_STP; task->task_done = sas_ata_task_done; - if (qc->tf.command == ATA_CMD_FPDMA_WRITE || - qc->tf.command == ATA_CMD_FPDMA_READ || - qc->tf.command == ATA_CMD_FPDMA_RECV || - qc->tf.command == ATA_CMD_FPDMA_SEND || - qc->tf.command == ATA_CMD_NCQ_NON_DATA) { - /* Need to zero out the tag libata assigned us */ + /* For NCQ commands, zero out the tag libata assigned us */ + if (ata_is_ncq(qc->tf.protocol)) qc->tf.nsect = 0; - } ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, (u8 *)&task->ata_task.fis); task->uldd_task = qc; From patchwork Fri Feb 11 07:36: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: 542042 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 EAABCC433EF for ; Fri, 11 Feb 2022 07:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347721AbiBKHhW (ORCPT ); Fri, 11 Feb 2022 02:37:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347699AbiBKHhL (ORCPT ); Fri, 11 Feb 2022 02:37:11 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72CEF10B1 for ; Thu, 10 Feb 2022 23:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644565029; x=1676101029; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=ZTSQF503bBL6mXectoHacnuN4dK31inuZeg8aphpWpY=; b=pa3RywprcIvHwaoAf6GMstDlrZA4hz5h6u7su4isrBXvguVECV/2x/ax nnnGOsRJTeER2iNHuGrRpVJ36WotoU0ihmmAkk+Scqmy/e8MNUEvXReg3 ZMuSk0LqwsTX8G1I2KYjopO82MTLtwUthbAt1hLWymL8b1t0NpLg3pzTZ aTRE5vzKxMT4w6XqDTulU+HsSP7oBe7aDRQ3j0+hKEq1m4/kqbrHb/G9t +Luv3obTTWmHgmSaBRA7ROsgbfKvh5OOjUoxqKXJp89iOKtQ3X02Q/QyS 4kmIYLiiw5YxfG8SmHDRAa7CsAYrjaXIsUvTQBy7bfpvt/Tz74lkhXC7C w==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675119" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:09 +0800 IronPort-SDR: c+K+HrXBAvyElHBYBFirYzA/GlBhuBPxkz9B/ylXrRM5vmNN2c+0sHfJj1ExrYvpr18UYLcAQs ZQY5pRZiYD+hBGu4dC6sWxwMwyxxEH6NgLnmEdIaJFDqCO5vcy1cspj920CrrAuf5tAUJdUrrh 7HG3xkJm5w2sLfQEjntUMJhnBT+reOAGq5NUaEdaOC2T1bxm/I64gTLLCM02qUlmco4XUvPphN N7TEc/U225nX03B8JIPLBgBwOi+z8L2cKYHnRcO809f7djUPACKLwtAa8x0WskdTLDm8R0zedM RvkWLXguchzXNTaSwe8Vljft Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:08:57 -0800 IronPort-SDR: mp59CLTI+bBVwSreyrYssN32vQwkqXEScUc6MBb9yj5vwQQ+hWD2/5D4+3/pCM++5DhB0bwZSV PsnJ8EdcuiUR4O2uKQ+W3qbWcUXaoh1RcqTn28A1LkfTlmt8AQNdQhGijn7rhgKjpmuEd3q+ZZ WG9OTSPrbcIt9Z9BXhWdj+v7wsBhhB77cLpWxa3OYiLt79nvcp42Q4Y5xQyYgDnpp81hRA1rdk 4qYzBP46CMMa2iOvQWzmBuofb98gLu3zvikSVkA89wcPrs+wI5QdvwZ4QutFW8H4V49Wehwyph N6Q= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:12 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw56b00pQz1SVp3 for ; Thu, 10 Feb 2022 23:37:10 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565030; x=1647157031; bh=ZTSQF503bBL6mXecto HacnuN4dK31inuZeg8aphpWpY=; b=N8bt9En1Ls6B3IOWXNskQvH6OEbtLtqL2A fXe2YWJ0XCD37ZzFaajLyjL4M5mexAQ0fMPgOIurht9rtN0o/wFP3VKAr7ZF0cO9 62J10M6ro+rGbHQ2H2lAs4Rg9kqu1EDUkPajkpw7drWjAFEeQCrraTkm0UD0hscc z/GMGIIq11flvzl8KYvx/1XaM8hmQHTFZ0qn55ptOl3EUjVRhujVdlJdxe5otJBf ELKPZApSJChkxH6dEiTuVlj7TjPKyTB+NC8gVpRMZ89hMyM6CPg84XoQ5EkZ6s+y w97p9MNTWMSeDUhYOvnCcCIldpm+qPEjxNucm+FXY1HnlKL9dGkw== 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 m54BHDL6EINr for ; Thu, 10 Feb 2022 23:37:10 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56Y3kKvz1SHwl; Thu, 10 Feb 2022 23:37:09 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 03/24] scsi: libsas: Remove unnecessary initialization in sas_ata_qc_issue() Date: Fri, 11 Feb 2022 16:36:43 +0900 Message-Id: <20220211073704.963993-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org sas_task_alloc() sets the state flag SAS_TASK_STATE_PENDING for any new task allocated. So there is no need to set this flag again in sas_ata_qc_issue() after the task allocation. Reviewed-by: John Garry Signed-off-by: Damien Le Moal --- drivers/scsi/libsas/sas_ata.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 99549862c9c7..a03a841921db 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -204,7 +204,6 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) } task->scatter = qc->sg; task->ata_task.retry_count = 1; - task->task_state_flags = SAS_TASK_STATE_PENDING; qc->lldd_task = task; task->ata_task.use_ncq = ata_is_ncq(qc->tf.protocol); From patchwork Fri Feb 11 07:36: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: 542318 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 CC152C433F5 for ; Fri, 11 Feb 2022 07:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347716AbiBKHhV (ORCPT ); Fri, 11 Feb 2022 02:37:21 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347706AbiBKHhM (ORCPT ); Fri, 11 Feb 2022 02:37:12 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FA2A10E1 for ; Thu, 10 Feb 2022 23:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644565030; x=1676101030; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=ezAlBnqNea2WEn5Uj/GbU8n5xAcCJpcaHqkuq8Sgjec=; b=hf1r0BdfqAKuOJq7JCAjtNzF5BLA1AtIYU8I39jDH/0nkp3VkLeADxse 1EYGo2GCBOoAc4za0NjC2S+5qMSSxlCwhYnpRTu1nsnQXgpbark3teGJm sW0d8fJ1GsJLCiSdftCEz1fMObGJ4M3ngpjEAcSwdZtZb0i7pFHp8QvwJ tiCNAva4LNhsrqjAb+jVL7Qw/yJlZqMFtuHpllpzHmvY3C+vQUADE5e5P m04mpLkH5yowChYs80J4A17FlOG3Av87QYHjwfelQR5BOYNyIG3C3/X5E 9A6JyblDnsLv5sLHV/X9AiE1XnP2+GpT/xt/v9eJ+iLS/ewbBZ6df+vZm g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675121" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:10 +0800 IronPort-SDR: D0R3uMwZKHXrt87CzCE6/e8auuN74dYSRrB4AAYoYFkJ64H3CxOL/ZSlfw/aPg3ckGXOZGp6pt dYc8JGbgaxbczggiYOcNj8yRvLhfcfWEHz6DDGee4uv7ETtontcyupHqDRr5yojIbOxy/lyTyg vSR0ZFYbXFR+H7lE+Wywr+CpHlA2khTThsEVhfzjCLyenaEO2VPwSbvi8fqRQlRYfMtssRUAFj rTNUPQbYU5XpTgXnDwqsZzpxjS5IuO1dl2CYLrNAd4WYzmPXYRCMQXA/t4A+LTptZfUXr/8xnc /M10VEfJZPdG12bTay34ZqTu Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:08:58 -0800 IronPort-SDR: jV6ZXYJUK7cGXv3ON7wUrqcEIOPxDVxiwH4DTZOEBqx8jXGkQg3wbaJaTGBtmJJaq197la0W03 tjwyPl4kB/OX/Ru2IURxcYlJQXGxa55kZfWejHD0ejyvu+rsMK6t0k0Nj9wa8Iaa9UbrI9YmcH wbQHJrTwMsO8ACsmIB4qACRgCB1d8aZlVn4Lj1sMuWKqoyo7u4Gzn5ppm3MWH8iwon1aPUS8z4 LXuWlZYe1o7n+swpyMfKN4uoksofTVFVbum/41wOPd6eMpq9oieERMdcbU+rKjKUKepyd236lk 9L4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:13 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw56c0ZzBz1SVny for ; Thu, 10 Feb 2022 23:37:12 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565031; x=1647157032; bh=ezAlBnqNea2WEn5Uj/ GbU8n5xAcCJpcaHqkuq8Sgjec=; b=PLTETIK0XOIAM16rrs+LeIHQcenpFq0rbN UWnBKmFd56bCaAJ0DHRFKwlxnU73jIJe1RIQS8l3xHLozDV5FFzpx4cIeTbR7Ui/ 3xL9RQdOpdos6cbJ8tM0Vpwb4hpbsy23Yju0J5LlkkNEBs7xmnze5ISpwNCCU1Ns 6/2PZadVF5ZVZ3ypHB1oMaxU6VwMJ7PA08d/KkLUiYSNl+J8Ii6/vr1WFBGuQV1t xG3BJSZXJc0RZu0XyL3iDu9CFssbj7AfLrQ5sqIlVvKbYv7QVnOoOuqH3KhqD33h 4a5J4dKrjOo23JIjANCtKJIpCA53bDXZH5RODCUmXL7q/Qn4EP6A== 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 HgqXKda3EjJx for ; Thu, 10 Feb 2022 23:37:11 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56Z5LWBz1Rwrw; Thu, 10 Feb 2022 23:37:10 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 04/24] scsi: pm8001: fix __iomem pointer use in pm8001_phy_control() Date: Fri, 11 Feb 2022 16:36:44 +0900 Message-Id: <20220211073704.963993-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Avoid the sparse warning "warning: cast removes address space '__iomem' of expression" by declaring the qp pointer as "u32 __iomem *". Accordingly, change the accesses to the qp array to use readl(). Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_sas.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 32edda3e55c6..60a56a18e60a 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -234,14 +234,13 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, } { struct sas_phy *phy = sas_phy->phy; - uint32_t *qp = (uint32_t *)(((char *) - pm8001_ha->io_mem[2].memvirtaddr) - + 0x1034 + (0x4000 * (phy_id & 3))); - - phy->invalid_dword_count = qp[0]; - phy->running_disparity_error_count = qp[1]; - phy->loss_of_dword_sync_count = qp[3]; - phy->phy_reset_problem_count = qp[4]; + u32 __iomem *qp = pm8001_ha->io_mem[2].memvirtaddr + + 0x1034 + (0x4000 * (phy_id & 3)); + + phy->invalid_dword_count = readl(qp); + phy->running_disparity_error_count = readl(&qp[1]); + phy->loss_of_dword_sync_count = readl(&qp[3]); + phy->phy_reset_problem_count = readl(&qp[4]); } if (pm8001_ha->chip_id == chip_8001) pm8001_bar4_shift(pm8001_ha, 0); From patchwork Fri Feb 11 07:36: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: 542043 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 6C5A7C43219 for ; Fri, 11 Feb 2022 07:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347711AbiBKHhT (ORCPT ); Fri, 11 Feb 2022 02:37:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347708AbiBKHhO (ORCPT ); Fri, 11 Feb 2022 02:37:14 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18991107 for ; Thu, 10 Feb 2022 23:37:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644565031; x=1676101031; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=xiP1M0lFxhMkb2FeSA/f5haQvFI94F08NJluHNNUbzw=; b=H6YceNxEjrDJ757efQ5SwJkREnnEVhdQZGZ0FRlijDyqcIdD5ZO/Zkka neaYgM/D/zjgnO58dfi5O9XryPojQmQsUhSdDeBIIPaKB2MMxMhM/sFI0 K+S7YfIZIKYcRZVnB01r6CMV0V7JAo/nye0gvuzZjuoJ8UuI1fgymb+sC JHK3gFKbzG0r/BaeOwFKISVIuQk3TyT9pQYOXvuMcRrQojU/Pc7jRse4y MbkMJK82wnPZIHlh5vcIzFG0uA7nFqp7wJN/e4sD6VatuHXlgLV4ovAXQ FtnlmfuGfa44pRPDh0mDyKiobfXalS638OZmCyMa20HY1SSiC035uO/bO Q==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675123" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:11 +0800 IronPort-SDR: iJZhJ1ehsbcpf2YCeZEPnUPi3rDFvZYblIm5I/34yLOkA1vWlTuQRLXkzEMMcD2CE/urFXmuhh WZEMjOLattv7R3Br6e1D1JBMFS9wI2aiTOO7Ew0h9LCTvDFdejlSX9cisvPXB8txBswDCkqfJ3 MTjUbMiHntcMZp09May6I38+O4v2XID7JGLKBbJ9P4ED2Q29UMlXSyoX8/dWLGB+EaGG/gbu6K fQxIJ5gqsOeScL2h7NMfCL+bNmckD4jdNrLZOxDIUkA2y5D/9kh3RFVZX+kxc9a6WMiuwBCfIx PNZyUqYSMU8lR8Pa40Z08K7w Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:00 -0800 IronPort-SDR: yE8nsoLMWS8iC1MDmK2MlZnpjkDj3p+PM3zPlEhRMEII5V11Ox9wVkQkh8TigP10NQhl0/uj2H wrAvBbd6B6ql5fo3RRNUCxPipvPXQ0KJa4wBMOinROjnv7ZDiBIKiz0Zx+DV28ukAH9RWgVaBY vTpfLsZq5AFMV0D0PMCZqmzRy7tmprCXCMkVoAMhfFFD8GG1Zmn0Gtf5gHpK/2Sng3Z+fT2Bha 7j3c7BXqEaHwhcj0+EiU2Nu8KXdrpWnhdswmFlvMxaag2yRava9i5WemQpkivblap1bpTODM/A L8I= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:14 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw56d2x1rz1SVp3 for ; Thu, 10 Feb 2022 23:37:13 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565032; x=1647157033; bh=xiP1M0lFxhMkb2FeSA /f5haQvFI94F08NJluHNNUbzw=; b=PvLxM2w4faaNOmvM7sLf+tZxVKBg7qQfkq jOjmmGjBuJI/GuvJGWVHVOCzju1P6Ugxy8uBrs7fkKprv+rEPa1znbU8gHLQc3EP sjVEJwyZNaPnkk0LjXQa5NtPpaK/2TC+fKi/g3QsfpAr5xhtiLuov0A4RTJ2bNRk W9qLCBg39fDlUFU6tiufwHx/2bc4t5MUPn+uxNzmqDxWJbSWpFUUwwPL0yapn3CU FbOATKkKTJDtqSfX4fHHwUl+eSiNmB91SH5GJb/+2FfkI71PH3d52x7kRFg5yT9i GkH7ofHbS4nqsooEdBmUTrrLa4Jay3uekSe/WXQX4jVmqJBHy8jw== 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 w8qpfpv0MBht for ; Thu, 10 Feb 2022 23:37:12 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56c0434z1SHwl; Thu, 10 Feb 2022 23:37:11 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 05/24] scsi: pm8001: Remove local variable in pm8001_pci_resume() Date: Fri, 11 Feb 2022 16:36:45 +0900 Message-Id: <20220211073704.963993-6-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm8001_pci_resume(), the use of the u32 type for the local variable device_state causes a sparse warning: warning: incorrect type in assignment (different base types) expected unsigned int [usertype] device_state got restricted pci_power_t [usertype] current_state Since this variable is used only once in the function, remove it and use pdev->current_state directly. While at it, also add a blank line after the last local variable declaration. Reviewed-by: John Garry Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index d8a2121cb8d9..4b9a26f008a9 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1335,13 +1335,13 @@ static int __maybe_unused pm8001_pci_resume(struct device *dev) struct pm8001_hba_info *pm8001_ha; int rc; u8 i = 0, j; - u32 device_state; DECLARE_COMPLETION_ONSTACK(completion); + pm8001_ha = sha->lldd_ha; - device_state = pdev->current_state; - pm8001_info(pm8001_ha, "pdev=0x%p, slot=%s, resuming from previous operating state [D%d]\n", - pdev, pm8001_ha->name, device_state); + pm8001_info(pm8001_ha, + "pdev=0x%p, slot=%s, resuming from previous operating state [D%d]\n", + pdev, pm8001_ha->name, pdev->current_state); rc = pci_go_44(pdev); if (rc) From patchwork Fri Feb 11 07:36: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: 542317 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 0E839C433FE for ; Fri, 11 Feb 2022 07:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347724AbiBKHhY (ORCPT ); Fri, 11 Feb 2022 02:37:24 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347710AbiBKHhR (ORCPT ); Fri, 11 Feb 2022 02:37:17 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 147D1110E for ; Thu, 10 Feb 2022 23:37:15 -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=1644565033; x=1676101033; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=P9yKSBo3OyVYkqFAXqh6trK7u1E1pTxqRHMhtoDQwHQ=; b=mvep1uHBaTQXRuK+efUHnw9jlycNksvWMWDRIlqt7HzgVrnXneiRCLMb BRG2is9q7x7N0ia0erPgdyPGcLPe9ulo1gj7/+Q4rNrUI36CJTTqV71Xk 6TbXQCPwfIB61VqxV+OfF6xe7qYABdvpDrOIhvC3X1UwRpS9tdpPhqtSG 2Uw6jOvGCt8QUBJ1TW8d0hRraoXyWvRA/1VQiILXkZGWMURMe/hUOpKhN y1eXPklggZq0oP7BYfeYw6iyHJJOlxBeISPLS33xnDJHFBJ5BwLDiMz2j 2itZuNEUr2nXRlCzno0hI0NiA/Psy4lDTV4rMWERt5EeRI73xkEYc+XlS g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675130" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:13 +0800 IronPort-SDR: bLwOMNIH91/unH+SK82P0Md/1ZEdLNPqhCjflFomZyt/bBYSn0DHplQ0zJMEhklI9FFiRZgNNd AHMmrCuHFhY5mwgKMGW3yPVXFcL2h11NQN+WYKW0GzHsi/XtRj2Iwab4ucGyJAHYO2qarA9HXn vb1cWZ3NtOE+Csg1ZSsWGg828DFqbf71lZY7hPFF3eLkRpC0DEmWjsklivvG7UNCMdzvULm6Kh MCIIgua+Jc3nn/1sQu0w5tRNHqstAltME9gLT/HtsdknAIiNqLze3NRMSzuNqf5WxJYxJ7e7KB FgGtxTQdyB1Fr2id6gUWrl3g Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:01 -0800 IronPort-SDR: E9hqOJpssq+2GyCdMCXB7Ca8Qhdetk2Q4oHsjMmc1TfRPeGE2FctcwXNmg5Hy0u4s6LfryBodE 1LCPzt2VL56oPh4G52HIMq2W6px9+jZ7EHZtq8KSt9+enuZcNoYi21sWhzn2fPClSjHZJT4tlE 1MOfIhrjIo89iSa2qd/AfNutjHhk1k5qZwrOko4TNRDXgu4MeDS+eb+bEfAScCZ/s0s66q1vbY 4k85BbmCMUnYlvk2P/dNLkJktmOSz3Hcsd8RC9ggaPwb+jD39pyLnubwfwe3mmZaGW8SFbWqDe 7GU= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:15 -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 4Jw56f4f6lz1SVp3 for ; Thu, 10 Feb 2022 23:37:14 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565034; x=1647157035; bh=P9yKSBo3OyVYkqFAXq h6trK7u1E1pTxqRHMhtoDQwHQ=; b=CdGpCgbZHSF3xhe9zIvAhnZFVHU6Ju6ZGY gXPJnkQ14Hl1NAoW/qknzwhsScOoGwdYo0mm9luQP0flooNuGJ14Yar6xnEOdES5 q1zUP9PLWPCl6Z1kuWT/BHBN+RWHxffJh9K+UgvbW8gqVGpkLaYMY3Niuy4S1aVO n8LWc8JmOZo3ozSJd6BiMK6+5WtXao+wk5J+cqO+z94cQ3Vv1fk1xxk0QtePcgK2 mHPbHmMwnYeV47xJ0GaEV08DSu/sqlZMPKfW4jjny6awMeTLu7a5AQt4QbvRhIXw jbkbsPvx3/osmshsLeCIEOmVGrl7s/Wmx0T7n3ZQB2NpeuugKGHw== 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 X4_236lCJ0Xn for ; Thu, 10 Feb 2022 23:37:14 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56d1n1Vz1Rwrw; Thu, 10 Feb 2022 23:37:13 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 06/24] scsi: pm8001: Fix pm8001_update_flash() local variable type Date: Fri, 11 Feb 2022 16:36:46 +0900 Message-Id: <20220211073704.963993-7-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Change the type of partitionSizeTmp from u32 to __be32 to suppress the sparse warning: warning: cast to restricted __be32 Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_ctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 41a63c9b719b..03aff0ba3657 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; @@ -740,7 +741,7 @@ static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data; while (sizeRead < pm8001_ha->fw_image->size) { partitionSizeTmp = - *(u32 *)((u8 *)&image_hdr->image_length + sizeRead); + *(__be32 *)((u8 *)&image_hdr->image_length + sizeRead); partitionSize = be32_to_cpu(partitionSizeTmp); loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN, IOCTL_BUF_SIZE); From patchwork Fri Feb 11 07:36: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: 542041 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 57C03C4332F for ; Fri, 11 Feb 2022 07:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347715AbiBKHhZ (ORCPT ); Fri, 11 Feb 2022 02:37:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347712AbiBKHhS (ORCPT ); Fri, 11 Feb 2022 02:37:18 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42171111C for ; Thu, 10 Feb 2022 23:37:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644565034; x=1676101034; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=paa3TCfl6M+XAYMYGpNges4WtY+xxDK1wI5MkwlKq2o=; b=TxijJvBtEfM5bMYxp+qW1vVQvIj/kPMNViNt+GpFyYzOs+5DEfbMJ1gs +4ihXcvBtM9yuusZoYlpdP4QT02WxdVmByHKtvdjja9UJfclLFLtCPu24 kb46174s1adVZUiwbyuNRm21+tASnw7toMCRzM6V14ZrOSnw6Z9TaNuyn qecWoa2GmYz9wfoC7dUeMvGvm1AyaVvXX84PUjszV3kB3qILxN/uJMscS 8oYwMjQ2y5mz+bL0iwcScwk52FN/0d45KZDsHmbMtY4+EN10FuHoap4Yd oOSiUvTyMxAerlpBdWfEMMTqXpFoItmKCtB+cJSlmG5sWswpomA1PsaXz A==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675132" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:14 +0800 IronPort-SDR: rW0lbo979rH4V3elH8G/ZLmZd++Y6W5/SNmvOg6JVr9byQGQyv9zB659liLQvApLGckGS1unBv tNzZ9Fx8+UIC2dlmQyVjgH92RMMqloCwX85geJE6OWW54s0wJa6aLQ+VWuTAacBzLv9a/EGQei QttUGuzofrFGmZeDz17gg1vT6Z3ja+FyfEBk8fylnQ5OELyu91Kw0HuV21/aBp4dR9Z06cwCk9 2INPv44GI+LAU7xLjQLAoB8K1pN+qIfefMAvDpw8zS2i70w8xlX7x6T+G4oCZhS4Uq9f05KXql 6dyhg+qD4o9FhPAcdn+pL3ZK Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:02 -0800 IronPort-SDR: mzwCxsqR/JINgL2cuctR8zfPElVcmz0UNGgEWw0Gv5D12tUyMLYUvJfH4+p0NhUuu9Gb5qBVv5 RISF9UsjSXY4G9jJigXj+CvnnBFrHGWmOeHmcPdTo6ITkpVW7IQf0tPwHx7DlN5hhlCmJDkop0 gOXVdfBP0WJ8kkRQKuutH8ZAbnCJswQSag7A9dDXbUNqmHhcWe3ZGaMFH/3N6XtEKqhmDUaqm1 Q3ewC1AeX6DTv/1dLJZlE+2pmF9v0S77HpxaM99mQuhHzGJyOdZQ6DP1cW5SZnJc8rH6U4r8Cw nk4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:16 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw56g5tfBz1SVny for ; Thu, 10 Feb 2022 23:37:15 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565035; x=1647157036; bh=paa3TCfl6M+XAYMYGp Nges4WtY+xxDK1wI5MkwlKq2o=; b=R37/TAcnagO6GYOUrVs/dfO/M0m7LVG8Qx /Kif3X/EODmab83MDhEXo0B5yIe1Omt+mUyThWI7dSD+BF78FZwg2Es+X0XH8o9P 90EXgL0D9P3Ae5mENv4y4kK3ps12VYExwfIB6003GsXT5CqOO0aModBy7jkEO+0/ u0NpmH2PXfpj6e28RaKybZb1En39kht3hBu1NXSFSMoLV+dAhLyoPMW6lyonrhx4 1kKl1BHvogIBT/UFBTYVS3NMVJviZKHP/CkD018IYeS/FKKgUC5GEcm7h5IA+05G 1s1pl7K9pzblb6JuXCD3sY2UO2Zsj0R6eH79KwEQbEu0p5GGsdcQ== 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 hOyCdYqPzwyY for ; Thu, 10 Feb 2022 23:37: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 4Jw56f2zFhz1SHwl; Thu, 10 Feb 2022 23:37:14 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 07/24] scsi: pm8001: Fix command initialization in pm80XX_send_read_log() Date: Fri, 11 Feb 2022 16:36:47 +0900 Message-Id: <20220211073704.963993-8-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Since the sata_cmd struct is zeroed out before its fields are initialized, there is no need for using "|=" to initialize the ncqtag_atap_dir_m field. Using a standard assignment removes the sparse warning: warning: invalid assignment: |= Also, since the ncqtag_atap_dir_m field has type __le32, use cpu_to_le32() to generate the assigned value. Fixes: c6b9ef5779c3 ("[SCSI] pm80xx: NCQ error handling changes") Reviewed-by: John Garry Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_hwi.c | 2 +- drivers/scsi/pm8001/pm80xx_hwi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 9ec310b795c3..d978f7226206 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1865,7 +1865,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 9d20f8009b89..ec6b970e05a1 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1882,7 +1882,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, sata_cmd.tag = cpu_to_le32(ccb_tag); sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); - sata_cmd.ncqtag_atap_dir_m_dad |= ((0x1 << 7) | (0x5 << 9)); + sata_cmd.ncqtag_atap_dir_m_dad = cpu_to_le32(((0x1 << 7) | (0x5 << 9))); memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, From patchwork Fri Feb 11 07:36: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: 542316 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 7DC6BC433F5 for ; Fri, 11 Feb 2022 07:37:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347725AbiBKHh0 (ORCPT ); Fri, 11 Feb 2022 02:37:26 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347713AbiBKHhS (ORCPT ); Fri, 11 Feb 2022 02:37:18 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 757A4112C for ; Thu, 10 Feb 2022 23:37: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=1644565035; x=1676101035; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=qfUTrMyD4ge///nHppeLZESG5QBSI+5fOiZvflIP3ME=; b=OSXoW8Sus9C0zMgk6W+BPIcGheLlxIHQieBYkk1gR210QLuwMD5STJBg Nm9HpFH2u6URd+Aa/8skrygoz/zvVrEaKyML0dddvfZKI/UW5xPBIcH4s az9Y+B/HR7sNLt3dNcAGQcvSkl9+l4j6f7TgHNmyIcX6fY+2a6MqFn0jI vkZkc3t/ojiFTizREstubIq4pLq9N1ezR5hW5O7NI7AKGUcp0kHUc851+ 34M1NYA1qQ5+FoKKio0NlWH9gAJG0idfrZH9cMhpcpbxKuDYkbyVkkCZ4 E92lwLzJNLBokuIIZhZjuoX3Ge4QIg38JU5K8fRXx7pTzFkvkgDtGYDDd A==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675134" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:15 +0800 IronPort-SDR: Lf8lUYKWaADQRj9JY/rB682pE+9x2eZ35xpywohv1FSmwikuVDZKtZORHjmw6m8baWHieXPYBz 4a2hNkrPsN1Un8LX3p/5vHHen6o7YXaBxqWrFMOuzZ/1zgsgoJQPmGEDBzp0RuHq/IFYsgavEC LJXGO5/PmyhrxSuCpDVq7V8SjuOmgC0bnCnAu5hUGJitusMNSi1GFQGN1bBh556rUiftLORHbs 9oAYqfbwKfUqjTKuPNgcVWEOaal2IJuOiqKnO6wy8FjK9I+NYWuZm3bwL92OUyFKOQVpP4fckU +b9HM1I3y8N3Vd6TiJtmRWV/ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:03 -0800 IronPort-SDR: g3kQ2Tt+ndqkFrBhiKgl69KyVZJIlA/tnKpXw1thyo4P/l0ckq2RT8PmCaNEJnlfrRffPYclvW gO78D2EDd0CGiIi+hoPbBmH8YNZKNHhjeWDRg3kOcuJrSSOG8SosQoE/mWcJ0+EWmDEcWkxW2d mxJ25mJQRLv5cpeaWH3BmVLNdkaqxvN11DMwfnMuCE/e9NcN8gjNwjChYWNSc8gu8n+Zo6qQZR j8oCPUvnJ7f3q9YLD7dbJZctXglyxKwMqehJ6MSs6kaRsLkA2IKMM68ZPHLOnaZimYkmtx13Ii 0Jk= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw56j0CDYz1SVp0 for ; Thu, 10 Feb 2022 23:37: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=1644565036; x=1647157037; bh=qfUTrMyD4ge///nHpp eLZESG5QBSI+5fOiZvflIP3ME=; b=m9rB7bfCrQ+It0dReh+kBsr8EOIdY1f3pv cuqc00/K02Y5H0tzT4tT4n0ahAa8Dx8tyl6n98mS/drLF6pf3gkI04fT9EJXiyE+ 0YXge7FwPsUeEhamWHlDTfiVyW9rXC2afnghYHUY83iWgrdfME5/rQ/bi8tbKtS9 9GH++KZuSbMnC6+L5/SBtR4XnTjOdgLd5l8VI1ujfdImEY3osd6wnuO2Z8bITG1u 8ci96WXPHJxtua3C3MqX/maUVHqLJNF9mbtrA/jirAgzT5yM/Kp2ACbN+elGFCZR dR2BgRojYf3Qzeopz8IC6Mpr9uoyyoejHgs+wcMYt5G0IauIX5wg== 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 Ch5jMOzRfC_8 for ; Thu, 10 Feb 2022 23:37:16 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56g4lpvz1Rwrw; Thu, 10 Feb 2022 23:37:15 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 08/24] scsi: pm8001: Fix pm80xx_pci_mem_copy() interface Date: Fri, 11 Feb 2022 16:36:48 +0900 Message-Id: <20220211073704.963993-9-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The declaration of the local variable destination1 in pm80xx_pci_mem_copy() as a pointer to a u32 results in the sparse warning: warning: incorrect type in assignment (different base types) expected unsigned int [usertype] got restricted __le32 [usertype] Furthermore, the destination" argument of pm80xx_pci_mem_copy() is wrongly declared with the const attribute. Fix both problems by changing the type of the "destination" argument to "__le32 *" and use this argument directly inside the pm80xx_pci_mem_copy() function, thus removing the need for the destination1 local variable. Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm80xx_hwi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index ec6b970e05a1..b04ab4a1822d 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -67,18 +67,16 @@ int pm80xx_bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shift_value) } static void pm80xx_pci_mem_copy(struct pm8001_hba_info *pm8001_ha, u32 soffset, - const void *destination, + __le32 *destination, u32 dw_count, u32 bus_base_number) { u32 index, value, offset; - u32 *destination1; - destination1 = (u32 *)destination; - for (index = 0; index < dw_count; index += 4, destination1++) { + for (index = 0; index < dw_count; index += 4, destination++) { offset = (soffset + index); if (offset < (64 * 1024)) { value = pm8001_cr32(pm8001_ha, bus_base_number, offset); - *destination1 = cpu_to_le32(value); + *destination = cpu_to_le32(value); } } return; From patchwork Fri Feb 11 07:36: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: 542040 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 9E718C433FE for ; Fri, 11 Feb 2022 07:37:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347728AbiBKHh1 (ORCPT ); Fri, 11 Feb 2022 02:37:27 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347714AbiBKHhT (ORCPT ); Fri, 11 Feb 2022 02:37:19 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9BF310B1 for ; Thu, 10 Feb 2022 23:37: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=1644565036; x=1676101036; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=QxFaq4u/ltI4EXOZN0EExZT+6BlFEgHRDm4Mn9uwkNU=; b=hEuSBf838jhejNtj4aoB8WgSfNPDI5xFOT0Wk9Ap7jiQmZTdANnHu/I3 it0mUvCe+/jVbOPPCxc3hKOd7GLwbRBBp5GvdJaq+F6iTRh+Qr3N2CyNM ufwxo8zTwWq1U2jttToQhMHchcoVNJlKqx9tCSeF7YuxXRwEpghOhWszJ pq5TM2W0L/czzFs8/aVe4uphNmoqISkf28qxfnm+Lwf25bKtsKlaLlNgZ M4bt/mzGEbVctP9QkmBtlc0fq1ocioxCOZRkoVhEOqVKkSzL29LIoMehN 7eJ+dgquET7a1zmINJsV0yb+GKMVyxxtJ7tEHWCQjkoyF11AayrH2s9zB g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675138" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:16 +0800 IronPort-SDR: o/9Xz3EstcgxDWrft3jSRbJS1ddpWeTV0IxDmzPwQs7Zb12trh917XmPA+ea1N59R1NfWnJKF3 AHAX6wG7QM5/GAzK4mHCIaMwKVMphWplusSH2rr+H/4HUmRux0x2O4Oz1jVQUAb8MQTsAQLyDT /J8gdx3gaXvMh4gTXyhBYSzGLAG69OoWh/VoRccb1xlPm2vZhr3gDrhtco1lMDZ+Z69ejLl+tV rAF4TgNw3sp3K7bQWPp21aA5R46nqNZlpNC+eArDQ9YEAP9lzmlQBMRYZKvxG5hPSUkJj/plAM w+0ooOlIoCPGZA1BZDL2A30g Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:05 -0800 IronPort-SDR: IgEFq1DYp4m6DTP9QZQcVgu/+1P87UnGzpunawD5e5EZs5/NL9xYRXwWdnf9v9DgJ3Arj1Ycqi ddhLneAOq2Pz2bbB69urbHkpGuRWwmHJxbSA3wMLWZ4UsE0OgJmgUklp9+tKC/4AUne4/8P2oQ +7tQbPZB8kSs0lFAbXtXLR1UBs6sH92+TOVN33aHfBKjxI1luGat+0jtSJv06w5jbDBnG5Y0Bo BOfvYFwKfEeOZ7LyZoTQEmIaw5gUzdq8w3gw46858qSxWa84AORbI1ztRTUrrQj8Fj4vOg+ehd fQc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw56k2KpZz1SVp3 for ; Thu, 10 Feb 2022 23:37:18 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565037; x=1647157038; bh=QxFaq4u/ltI4EXOZN0 EExZT+6BlFEgHRDm4Mn9uwkNU=; b=eOZU1F3ZaK89Ek/Pibt4P3leki6qm2tupg gsQG5ioR6Td8b+DQPCfUYqCaT0MJdCHfzktsFDjGPrRwKIeCGNpWBjRxcaIzmcuW N/ancj+aO2JvbHcFdQFo1bpFH7hHx73d9or72yfPcfzzmmomaoedD/zghXDsERpx ssfwTKyTigmQt2/YtJ+Uzp7dCqvZRrhBpcfIf9nsDazK2uAwRXmqTHYGDmFdm3mi 69DG6sQITSLiUu47kms8LhiRvI8y6uQqF6fyyljd7fse2+8dynQ9f8kUj1t9WVPl pvJWruNQtYfZLUL0/c9MuS1LSNId1MXofF6P04Dmu+D6Bu7RF14Q== 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 3cmOcezo_g3S for ; Thu, 10 Feb 2022 23:37: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 4Jw56h6lsvz1SHwl; Thu, 10 Feb 2022 23:37:16 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 09/24] scsi: pm8001: Fix command initialization in pm8001_chip_ssp_tm_req() Date: Fri, 11 Feb 2022 16:36:49 +0900 Message-Id: <20220211073704.963993-10-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The ds_ads_m field of struct ssp_ini_tm_start_req has the type __le32. Assigning a value to it should thus use cpu_to_le32(). This fixes the sparse warning: warning: incorrect type in assignment (different base types) expected restricted __le32 [addressable] [assigned] [usertype] ds_ads_m got int Fixes: dbf9bfe61571 ("[SCSI] pm8001: add SAS/SATA HBA driver") Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_hwi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index d978f7226206..43c2ab90f711 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4626,7 +4626,7 @@ int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha, memcpy(sspTMCmd.lun, task->ssp_task.LUN, 8); sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag); if (pm8001_ha->chip_id != chip_8001) - sspTMCmd.ds_ads_m = 0x08; + sspTMCmd.ds_ads_m = cpu_to_le32(0x08); circularQ = &pm8001_ha->inbnd_q_tbl[0]; ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd, sizeof(sspTMCmd), 0); From patchwork Fri Feb 11 07:36: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: 542039 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 2BE79C433F5 for ; Fri, 11 Feb 2022 07:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347730AbiBKHh3 (ORCPT ); Fri, 11 Feb 2022 02:37:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347708AbiBKHhU (ORCPT ); Fri, 11 Feb 2022 02:37:20 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5A8E10E1 for ; Thu, 10 Feb 2022 23:37: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=1644565038; x=1676101038; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=9iGRnRm6RVIa0BEI369iHW7Fp1wTznqFrwMpZVlIlQQ=; b=O2m/P6anOPvHJce92hdfdJlCNUZWFF6bnHd612LECdmA/rGMNnPD7aG4 EZ0EjednQ8eKpcFErBtyETYUZfjgVreF8ZxS7nf1s8Nbmob14PspJvXwG /8z9t092s2sOfYl2f379psIQQPNrVjlwR4khxMCecruXpZYWAMn67Y3lq VOMQpL1gEsU+75q45i3mjEqbMwO1DZhmbVv8+T3vX/kpEBNqdkcqNXpkH SWh8IAzsEt/n3Yedcwmb2ialXlevs0B3bGkCGf667fXJW6nYaRBVdDqHk kuV8ey2/X+fyGNWd7uCvRIggrg48jELRwpVlTI1vvBiRL7CpYdWYZcoZK g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675140" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:17 +0800 IronPort-SDR: 2ubfnBseZiSfgzJf1fEfiaQ1aNXD/Umt+xB16g+0aYyqpXe9JDiygwRBUTSPHicfzmUyOPvnKv PY2bkqL1Hb9lczHuopqiCR8cv8mVgtlVqQp7FgBlmMnLJuEhETUByeUXi3w1Gx4bje15odT3di 6FSoyu/gZStVTLogREqk90QwKwbDApganoRrmLikDg+wmYsZFjGEQTJ050HWOalywV9VERzipo 21+KJfq7a55t6FD1GpXZjwv5U9sp0Yg79y5Z89EAk2Ufo8yJ7uwpU5V6teQtAbqZ+p73q2brMJ zOYWzrWnk0lGp58+KTgIY09y Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:06 -0800 IronPort-SDR: PiKfdSNoLYi9zKiJ6wFbKx8FZ02tWxxGQDTeVnCkz3ShdDcuaS58410a3Aa42xXAMHUqnLJi2E qn6WKsxbCLSMrFAbz7fz9On/0XPMuM9Uht6OMvfu++soViYEWeCAD8Vfhw00KUMywzBuWKghES fJSCowHOkNkf6mDFOn5404qwu5UT0wwVAMwRd3mXf4nE3aAgFbaSQPqRCDMnaiQ8CrqsCOQJt5 EZuXOp2kDNJAx0ueq99jpGY9GonaaiC4qxBbgHK9qh/sQ0n54x/vPPvxMDFgnNmpeyz2mxnlJb opE= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:20 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw56l3nP8z1SVp4 for ; Thu, 10 Feb 2022 23:37: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=1644565039; x=1647157040; bh=9iGRnRm6RVIa0BEI36 9iHW7Fp1wTznqFrwMpZVlIlQQ=; b=oT6FB0LLPolhVIkeUk18JenPpoD4K1QPCJ M3qi1tKXW7jyGFp1nYmth2/3QYCcHEFE10R+1Ou5cU5Kupm40I2Qt3oQ90MYKr8y /S6O8ANq9W1C23ZrgseMMkkJDu0rHvzdOXG3Roim5fza+Rfvo8XCZ1lMvct/uAZy ijNpxjhdegadnUTFDOc3dUepH0Xx+/tzZVIAQDHBat8gykDcvYYWnwlgEuLEBbOB bnO2fQz2huqNTRdV0SumnAY2C6Zgl47+y+BoMi8HEkvRyqpsVPudgSavIyPfFPKQ jTsEtdtCTUwyt3j/E5QwikeypqWwBCYFfuMRc7l9flEGSoNijRTA== 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 FLtD366zBGNn for ; Thu, 10 Feb 2022 23:37:19 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56k17YVz1SVp0; Thu, 10 Feb 2022 23:37:18 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 10/24] scsi: pm8001: fix payload initialization in pm80xx_set_thermal_config() Date: Fri, 11 Feb 2022 16:36:50 +0900 Message-Id: <20220211073704.963993-11-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The fields of the set_ctrl_cfg_req structure have the __le32 type, so use cpu_to_le32() to assign them. This removes the sparse warnings: warning: incorrect type in assignment (different base types) expected restricted __le32 got unsigned int Fixes: 842784e0d15b ("pm80xx: Update For Thermal Page Code") Fixes: f5860992db55 ("[SCSI] pm80xx: Added SPCv/ve specific hardware functionalities and relevant changes in common files") Signed-off-by: Damien Le Moal Reviewed-by: John Garry --- drivers/scsi/pm8001/pm80xx_hwi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index b04ab4a1822d..6f8bdbd24156 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1201,9 +1201,11 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) else page_code = THERMAL_PAGE_CODE_8H; - payload.cfg_pg[0] = (THERMAL_LOG_ENABLE << 9) | - (THERMAL_ENABLE << 8) | page_code; - payload.cfg_pg[1] = (LTEMPHIL << 24) | (RTEMPHIL << 8); + payload.cfg_pg[0] = + cpu_to_le32((THERMAL_LOG_ENABLE << 9) | + (THERMAL_ENABLE << 8) | page_code); + payload.cfg_pg[1] = + cpu_to_le32((LTEMPHIL << 24) | (RTEMPHIL << 8)); pm8001_dbg(pm8001_ha, DEV, "Setting up thermal config. cfg_pg 0 0x%x cfg_pg 1 0x%x\n", From patchwork Fri Feb 11 07:36: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: 542315 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 18DF8C433EF for ; Fri, 11 Feb 2022 07:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347729AbiBKHh2 (ORCPT ); Fri, 11 Feb 2022 02:37:28 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347718AbiBKHhV (ORCPT ); Fri, 11 Feb 2022 02:37:21 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B01B10F4 for ; Thu, 10 Feb 2022 23:37: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=1644565039; x=1676101039; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=ljE5lfdxexuRaDu5qOXZpYyWAr/KrWbmU1oOByCCssA=; b=PtQ0uEUR978s+8fs/4mbRTjHkMO72hsCqFFrEoztsvUDBYidymK9uLdp S3hahuSPVAfKLCyUwd1PFhEVfMsmE50mjz9q3bsC5nYyfMPbpNq3b9V4O KMQOh3swHsE/94ZkWXt7rTLOb9PYbZ5odQXEJOLaswOfeCDnPkd1TJY1s RPcMR8E1ODB6WzG53j8uzVxSE8x4ICWOBmC8WNFltdbw9iInQxkSBuvvK BgZD7hki3OFxWEQkgmY7sTsf9jlQflP+V2BRfgpR2FD9/1WBLACWO0JjJ hDc3cN7CPqfzh6MbvnGBwUQ50R3IUpnCUzbRLG3ny0DNBIPDhBRUmc3sI g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675143" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:19 +0800 IronPort-SDR: G1dAfxvz8EtZoSRdyxEz80LcmTbkBNM7B+L7KgCNLWRhD2q+bIo0dFnReQHbgDvc0rTxz/ajtf TOYLmpRZYb/H6wKx9kX/TdymNoMpFI8XQnoqT13BxCwj9P1L5js5DNlV7wQe3E+IFBGHziMjau uWTL1hvlWTLLsa8+qWmEkU24nX5AX3bM/fD7KcSFUvQyBfTh/lcbwOJy6Sn9lvgyewti/s82QC UNtvUW4ucbARSprN+nWvhpadNSe6cDa96yt3K/E7NWIwnp6UpFwhLTlP+1lhFC9NZxzkS4pBKq NgMcy3YREOBQQkxxAJoCTTbH Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:07 -0800 IronPort-SDR: VTYpcKzEYbJD1SGMrJcQTHDGBNMixHXQL4YXbNnqmOQFA14qpDI0Qq4c3s8L1i2y0BfKepN7nn et7tDnzgiYX97xCSCgXI2Bnkxzvv73qsX86IES7DQY4FNedlyan/EuCyLv/vejg5O2Rgs762EV d5GxF1RwYQvYWu9jEtn4z8BsCjip63J7GKxzHtkOZBi0nolFSlNrJe/5TgwrtCfOWV7I3QeI0e a5/ghd6hjqK+fVB/i+O4AXTtGpCQCUJql6nSY6ZaNa5AilXINUenxiV+03eI4DHMmhGImwLIMw f7Q= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw56m74l9z1SVp4 for ; Thu, 10 Feb 2022 23:37: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=1644565040; x=1647157041; bh=ljE5lfdxexuRaDu5qO XZpYyWAr/KrWbmU1oOByCCssA=; b=hYJow+GKIPsx9pmHOv14DS1V6z3OTXgZSU uW7LpC7EHhPtZUpQdlAM5ka7kyKK7TuLTceYXUN6zfS2n4XhodVrLpr4cUOVs1F7 vwPrDJiqGDgTUllfxif52AVx7pM2LVYh59W0urF5X9hBtrEV6uXWmfYoHUsXyUh7 xNe1QtFvMiDJJZlqWhQ4cmhIU81vvfaV9HMg2iME/V7MX97wHyowlc0+/YcFRhNr KAHJntJojTiHT0IsC+rQ21J8rBIuLOhh0As0r6d5kxk3J++8Pe0+vWxATuuLz08N Y0UI/TbFc4NGV+7ZqdXqQQuEGnKld6Cn0wiOh0mFcLXc067Mvupg== 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 VGRw1_n8tg8x for ; Thu, 10 Feb 2022 23:37: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 4Jw56l2gsGz1Rwrw; Thu, 10 Feb 2022 23:37:19 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 11/24] scsi: pm8001: fix le32 values handling in pm80xx_set_sas_protocol_timer_config() Date: Fri, 11 Feb 2022 16:36:51 +0900 Message-Id: <20220211073704.963993-12-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org All fields of the SASProtocolTimerConfig structure have the __le32 type. As such, use cpu_to_le32() to initialize them. This change suppresses many sparse warnings: warning: incorrect type in assignment (different base types) expected restricted __le32 [addressable] [usertype] pageCode got int Note that the check to limit the value of the STP_IDLE_TMO field is removed as this field is initialized using the fixed (and small) value defined by the STP_IDLE_TIME macro. The pm8001_dbg() calls printing the values of the SASProtocolTimerConfig structure fileds are changed to use le32_to_cpu() to present the values in human readable form. Fixes: a6cb3d012b98 ("[SCSI] pm80xx: thermal, sas controller config and error handling update") Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm80xx_hwi.c | 52 +++++++++++++++----------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 6f8bdbd24156..ea1f250e4b42 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1245,43 +1245,41 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) circularQ = &pm8001_ha->inbnd_q_tbl[0]; payload.tag = cpu_to_le32(tag); - SASConfigPage.pageCode = SAS_PROTOCOL_TIMER_CONFIG_PAGE; - SASConfigPage.MST_MSI = 3 << 15; - SASConfigPage.STP_SSP_MCT_TMO = (STP_MCT_TMO << 16) | SSP_MCT_TMO; - SASConfigPage.STP_FRM_TMO = (SAS_MAX_OPEN_TIME << 24) | - (SMP_MAX_CONN_TIMER << 16) | STP_FRM_TIMER; - SASConfigPage.STP_IDLE_TMO = STP_IDLE_TIME; - - if (SASConfigPage.STP_IDLE_TMO > 0x3FFFFFF) - SASConfigPage.STP_IDLE_TMO = 0x3FFFFFF; - - - SASConfigPage.OPNRJT_RTRY_INTVL = (SAS_MFD << 16) | - SAS_OPNRJT_RTRY_INTVL; - SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = (SAS_DOPNRJT_RTRY_TMO << 16) - | SAS_COPNRJT_RTRY_TMO; - SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = (SAS_DOPNRJT_RTRY_THR << 16) - | SAS_COPNRJT_RTRY_THR; - SASConfigPage.MAX_AIP = SAS_MAX_AIP; + SASConfigPage.pageCode = cpu_to_le32(SAS_PROTOCOL_TIMER_CONFIG_PAGE); + SASConfigPage.MST_MSI = cpu_to_le32(3 << 15); + SASConfigPage.STP_SSP_MCT_TMO = + cpu_to_le32((STP_MCT_TMO << 16) | SSP_MCT_TMO); + SASConfigPage.STP_FRM_TMO = + cpu_to_le32((SAS_MAX_OPEN_TIME << 24) | + (SMP_MAX_CONN_TIMER << 16) | STP_FRM_TIMER); + SASConfigPage.STP_IDLE_TMO = cpu_to_le32(STP_IDLE_TIME); + + SASConfigPage.OPNRJT_RTRY_INTVL = + cpu_to_le32((SAS_MFD << 16) | SAS_OPNRJT_RTRY_INTVL); + SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = + cpu_to_le32((SAS_DOPNRJT_RTRY_TMO << 16) | SAS_COPNRJT_RTRY_TMO); + SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = + cpu_to_le32((SAS_DOPNRJT_RTRY_THR << 16) | SAS_COPNRJT_RTRY_THR); + SASConfigPage.MAX_AIP = cpu_to_le32(SAS_MAX_AIP); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.pageCode 0x%08x\n", - SASConfigPage.pageCode); + le32_to_cpu(SASConfigPage.pageCode)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.MST_MSI 0x%08x\n", - SASConfigPage.MST_MSI); + le32_to_cpu(SASConfigPage.MST_MSI)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_SSP_MCT_TMO 0x%08x\n", - SASConfigPage.STP_SSP_MCT_TMO); + le32_to_cpu(SASConfigPage.STP_SSP_MCT_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_FRM_TMO 0x%08x\n", - SASConfigPage.STP_FRM_TMO); + le32_to_cpu(SASConfigPage.STP_FRM_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.STP_IDLE_TMO 0x%08x\n", - SASConfigPage.STP_IDLE_TMO); + le32_to_cpu(SASConfigPage.STP_IDLE_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.OPNRJT_RTRY_INTVL 0x%08x\n", - SASConfigPage.OPNRJT_RTRY_INTVL); + le32_to_cpu(SASConfigPage.OPNRJT_RTRY_INTVL)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO 0x%08x\n", - SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO); + le32_to_cpu(SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR 0x%08x\n", - SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR); + le32_to_cpu(SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR)); pm8001_dbg(pm8001_ha, INIT, "SASConfigPage.MAX_AIP 0x%08x\n", - SASConfigPage.MAX_AIP); + le32_to_cpu(SASConfigPage.MAX_AIP)); memcpy(&payload.cfg_pg, &SASConfigPage, sizeof(SASProtocolTimerConfig_t)); From patchwork Fri Feb 11 07:36: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: 542314 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 73101C433FE for ; Fri, 11 Feb 2022 07:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347731AbiBKHha (ORCPT ); Fri, 11 Feb 2022 02:37:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347723AbiBKHhW (ORCPT ); Fri, 11 Feb 2022 02:37:22 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 845BE110E for ; Thu, 10 Feb 2022 23:37: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=1644565040; x=1676101040; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=8dQ5lKPkh6OkNBD1ShdPkO1NXPCql9jZdUSOljzBMdI=; b=X3lb76Xu+jFTDZ1HN9xokFO7GR0NqEsjRYOen+i5TiiL4Wne/shirc49 BapKEKvz/c39BfRPDYq/tV3/2dgd3vSKW4KqqxsIByHloD0ZpQcGxwD5T DRsiX78ORKvcXY5sm6L+YFr8UPhZl+1qQwa6hAzmb3qQ+du4G1QEZtcqn fzItgF/8/NPyXZn0w3N00U3TkFBRb5zf9w0geUIQ+QTOYx/NzB1eav2v+ W5dpszW92phzZYQWbJX9evto3UT8YdBQpFCPMt523ikqhgpsgdalm5cY9 WkXw1WOTnLMaRwt3nYlyOzdXXhA7YhqRz1W7S6Z5yVZPljAQREAOEKf7t A==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675147" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:20 +0800 IronPort-SDR: cFJ1ezAxuEzuEy1K3f6TXMxZ7Bz8mganKDw540UHb3sJrQvAs8l6ViImn60MGmPHh1P+0oBvql /WOIdgVpitdZAI/Am6464bKoG3YMBcfVVXJZJBibqQR1qlr6dOI6uyRSb6wi1GFeuSVXDbNTsP LUBMRBMYrylH9yMnBptRbNydVY5C6X3nKDa/UjA5y7LIWjKRtBtZpKzA5MRROhgj5KUNlZQw5n cPlL0ftPR3OvVBIUKoYSWyGV8Cgtl8+1T4eyI3IIsXvoshuQCDjOShSyuyWxPiC+1REn6cS8hK 1wg5+jP5uY9lrgDMH+XUdHNA Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:08 -0800 IronPort-SDR: C2ybNMsnFTimV6SKA4EskNV/BjCvllB8Nqu8XdZS8jVILBUMw6ZJLVRafe/SCot+NPipV4fgmX UpvZjN6ibxScJ1EhrfnXUMdv9drFgX5N+fcT0TYAwTJ48QDk9XjsM6Clftp6zlsDUOokVXV9vq XoNWiZZiyBrqhYo4rpmlmnIljJ5HtvBY7CHQb3gkWN4H8uXJoTEyA4Fgzmy2/lOeoLpkWkQV/C AgNi+S3NM+yCdEEl3QvBxEGE7fWlsHzd66mjpMfrIPeKGwxw5zP6fZUPPzBqEPvvxi7xPJSGW6 FQw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw56p0hcVz1SVp3 for ; Thu, 10 Feb 2022 23:37:22 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565041; x=1647157042; bh=8dQ5lKPkh6OkNBD1Sh dPkO1NXPCql9jZdUSOljzBMdI=; b=QsE4o5r5Hyim3a6Cn0v7XxiChnPzA3wmB7 Xb1plnZUMWrMkTUYTyImMPBQ+jc8MOJ+7jTnsPH6+lQz1lsFTzGJ1I4eqYkw5dH2 r5kGbhPXDGFjrsmdf6H2i0REK6wcBv0pPgnmdxPMhu9zOVF8G3yIRgcuawO4NTFr nbfSq550VykVKfVId7M7VOC/SPBT8DjqaAh8v+5ncAl9vkdk+bdRkzTSzJSRgmCF a33Qf+pqQ41eDAnh8G7nB3348zelW+YXgnIy7KEAxTBv7ph2rpaCMKAd1xpW0dx8 nABrK088todaBtF0hWVLsgVhpCzgE9lpN8murfZpLFk9lbkBqPig== 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 aBdELKqIK8UW for ; Thu, 10 Feb 2022 23:37: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 4Jw56m54ggz1SHwl; Thu, 10 Feb 2022 23:37:20 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 12/24] scsi: pm8001: fix payload initialization in pm80xx_encrypt_update() Date: Fri, 11 Feb 2022 16:36:52 +0900 Message-Id: <20220211073704.963993-13-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org All fields of the kek_mgmt_req structure have the type __le32. So make sure to use cpu_to_le32() to initialize them. This suppresses the sparse warning: warning: incorrect type in assignment (different base types) expected restricted __le32 [addressable] [assigned] [usertype] new_curidx_ksop got int Fixes: 5860992db55c ("[SCSI] pm80xx: Added SPCv/ve specific hardware functionalities and relevant changes in common files") Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm80xx_hwi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index ea1f250e4b42..41a74943888b 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1405,12 +1405,13 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) /* Currently only one key is used. New KEK index is 1. * Current KEK index is 1. Store KEK to NVRAM is 1. */ - payload.new_curidx_ksop = ((1 << 24) | (1 << 16) | (1 << 8) | - KEK_MGMT_SUBOP_KEYCARDUPDATE); + payload.new_curidx_ksop = + cpu_to_le32(((1 << 24) | (1 << 16) | (1 << 8) | + KEK_MGMT_SUBOP_KEYCARDUPDATE)); pm8001_dbg(pm8001_ha, DEV, "Saving Encryption info to flash. payload 0x%x\n", - payload.new_curidx_ksop); + le32_to_cpu(payload.new_curidx_ksop)); rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); From patchwork Fri Feb 11 07:36: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: 542038 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 0A1C3C433EF for ; Fri, 11 Feb 2022 07:37:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347745AbiBKHhf (ORCPT ); Fri, 11 Feb 2022 02:37:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238659AbiBKHhY (ORCPT ); Fri, 11 Feb 2022 02:37:24 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E74B410B1 for ; Thu, 10 Feb 2022 23:37: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=1644565042; x=1676101042; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=0By2svS/qa6+92M3y1emldA/HHxQI5Ee/J/kHWALG8U=; b=DB2TU4g4H88FXqKJ7cD043f4QeFsM/6CPYcHBeB4WSQa9CIA6FnhoFiG BJ9Dy4MPaNnJWJz6sAyGpXXLiwxbwqRFulr9PCm/gS1/imrAmUnTjvwdD 0XWyD7KCKsE0dH7f/BoE6KXcZakqtfAEnrlJbQAGe2ofjB78e34J4trw7 gScRL94RQ7SYNgXxNiMJ6LHTIIFKEgzJ7IQrl4dOyOQ/3fPsUZdPpBbPY zTTbGwkylP/tTHs7hB5hiAKDtB0ir6/TB/PzCA5H8AIzxb+9qIAgCMcCl OqkRvsrNBM5ALRKsrc5eREfgPkej1zrM1eVyFyFl61Le42rdHVzcgyMv7 g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675148" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:21 +0800 IronPort-SDR: RDe7F71NHH+FAPUYEiuH/5Tv76Y2OVnbSiMROni45cLbx4uymolvL+G6ZYx3y08RpLrI/uPXTY xiJUNEr3YovKl0eVBibMAdL7wutKYYhsdorroE6BS3Z7CtqX106IkezUp+x1o6k1UFXq+286Nk RAiQXFwwIYneiTeNC3eigj3OLqNv8+tIE3laOm99ZgxQrPwJ7nPMIVQRcRKKRWpLZ/+t0GziKJ WBEYkqqRVPeA9+uKkMz74kdFMbbDiX8+EzGhPSIX2s4u5Hc7P9jPWb4IER+a5rIZ9YZ/OZ6tTR PO1Kxd0vByyy6NvEZF4IOCx+ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:10 -0800 IronPort-SDR: beev+G5IM++SoX1sX+xM8yTJkxWJviJFD9QTUeRNUlYjuCBieI5tXFtAcQyYkOc6sjNwTTDWpG Kb/WK9dRXXRD9EmwtHuokhcM2qtc10D2ZbjyD0yIQ9ZE0QOQNa9LvoTELpdAoaXuX/TcbxdWvk eh/s8azEHfGpNoX3kSjmn5Xpn5WDJf4BGEa5VBH9TO+hY7PLJUxc0Uonv3HhgfJsY9TBsmDH6E GWV+S9/4qT8GnJJbwqnQZRJadM3c07kxq5h9BZsJMbidW+pZBguyCT9RARWPJUgid3CKAgVZW2 XIo= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:24 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw56q3Hykz1SVp0 for ; Thu, 10 Feb 2022 23:37: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=1644565042; x=1647157043; bh=0By2svS/qa6+92M3y1 emldA/HHxQI5Ee/J/kHWALG8U=; b=KaAAI+spW/Hg+0GQtXoXk2nxaSqYAL5Zob P6BUJVXJldvZtCqyF4JJq3t23MYtd+gVAiVY0Zk7lLpM8IzGnYXU/U/xWK707vtd rmOQoHN7by9TaUfjROvwH/fLnS2s/mOSh/GoSvw82+sc0i9DrwJIHNuNhdE3ulKD 1h3thrUSmW7uHZonDvPvl2bihVOs9uZmYhJK01RNzx9FyiLsH1HWPI35dz2zZoXR BiVrLCa+K9ktEwqe6t3W0uTp+mNLlN1F9jtiYZFTya9OM2oZeNDkWeuXobnc+eSY ey32oII7pLc+NXd2wDzjJz3E9anHljUmjj0l3gIsomnBDt90FngA== 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 PTV2KfXHkfUM for ; Thu, 10 Feb 2022 23:37: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 4Jw56n6V8Hz1Rwrw; Thu, 10 Feb 2022 23:37:21 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 13/24] scsi: pm8001: fix le32 values handling in pm80xx_chip_ssp_io_req() Date: Fri, 11 Feb 2022 16:36:53 +0900 Message-Id: <20220211073704.963993-14-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make sure that the __le32 fields of struct ssp_ini_io_start_req are manipulated after applying the correct endian conversion. That is, use cpu_to_le32() for assigning values and le32_to_cpu() for consulting a field value. In particular, make sure that the calculations for the 4G boundary check are done using CPU endianness and *not* little endian values. With these fixes, many sparse warnings are removed. While at it, add blank lines after variable declarations and in some other places to make this code more readable. Fixes: 0ecdf00ba6e5 ("[SCSI] pm80xx: 4G boundary fix.") Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm80xx_hwi.c | 41 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 41a74943888b..2e1a9261212d 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4378,13 +4378,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 @@ -4395,7 +4397,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, @@ -4427,21 +4429,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); @@ -4450,7 +4455,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; @@ -4458,8 +4463,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) | @@ -4481,20 +4488,22 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, ssp_cmd.esgl = cpu_to_le32(1<<31); } else if (task->num_scatter == 1) { u64 dma_addr = sg_dma_address(task->scatter); + ssp_cmd.addr_low = cpu_to_le32(lower_32_bits(dma_addr)); ssp_cmd.addr_high = cpu_to_le32(upper_32_bits(dma_addr)); ssp_cmd.len = cpu_to_le32(task->total_xfer_len); ssp_cmd.esgl = 0; + /* Check 4G Boundary */ - start_addr = cpu_to_le64(dma_addr); - end_addr = (start_addr + ssp_cmd.len) - 1; - end_addr_low = cpu_to_le32(lower_32_bits(end_addr)); - end_addr_high = cpu_to_le32(upper_32_bits(end_addr)); - if (end_addr_high != ssp_cmd.addr_high) { + end_addr = dma_addr + le32_to_cpu(ssp_cmd.len) - 1; + end_addr_low = lower_32_bits(end_addr); + end_addr_high = upper_32_bits(end_addr); + if (end_addr_high != le32_to_cpu(ssp_cmd.addr_high)) { pm8001_dbg(pm8001_ha, FAIL, "The sg list address start_addr=0x%016llx data_len=0x%x end_addr_high=0x%08x end_addr_low=0x%08x has crossed 4G boundary\n", - start_addr, ssp_cmd.len, + dma_addr, + le32_to_cpu(ssp_cmd.len), end_addr_high, end_addr_low); pm8001_chip_make_sg(task->scatter, 1, ccb->buf_prd); From patchwork Fri Feb 11 07:36: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: 542313 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 DC25EC433F5 for ; Fri, 11 Feb 2022 07:37:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347707AbiBKHhg (ORCPT ); Fri, 11 Feb 2022 02:37:36 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347720AbiBKHh0 (ORCPT ); Fri, 11 Feb 2022 02:37:26 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43F8210F4 for ; Thu, 10 Feb 2022 23:37: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=1644565043; x=1676101043; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=//HcszDAJKd/CLH75b53FTwMYsQK+nBTlok5LRe6EaQ=; b=Uo7/7lZXHLyN06X6xCDw8nFZeym3ro3I4K8dAbnxUHeNnbuBqNNsbZbD UYWdNUBokZr1Sp8lFKRbLOgwgLAdV0alvWBUBKprIp1msbHG7T2Vdk9Bw ZOsFK4JUjBXOSX0tHZiqONlHm3Yb+yfWwvoryM80dRrQEIuvxbfaVfovU QubAHcD329Xguq9jn56YvzEK/UPT4HGHhIG2B5ucvRcfdTurRB50KxJg+ nLyX7055Hi5oqiQzO0RMB9/snzO8NsRShmTNcYBrKtEJO8td8fZkkxkH0 fe3CUL0M4qLufud4XYdFr5XIFNxz7j3untOGdtPtEcpj9YQBHUSwm6QRx w==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675149" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:23 +0800 IronPort-SDR: g+l/Q2DRDpRXQ0hwZEkQpS9xChVZts5VRWGt9Rjxkj7aBPtjBgWZH9XFwqo9MguZjTFjVmkSzb pInz5ue6bCwews17XJC2iDHuFaIqe9jKFdUhhKKkT+heBb3LphmsNcybWRhbdMF0ZoJdA53tr+ YNbVGvr4gIDMIKPVLVaEXq4i5y1ZwIW2NQAvU13tYerh4P6Nc0TMQUM8PgCMZcjwrV9HKk1ZMk M/3eGM08FkAX0eYILz+tt4c1BPtjMG9hwgqQURjPcv5/81WeJkpOJT7YyF/pu//37EMPTXwGSe dlHE+Jz8C1ATuVS2NE52Qw4t Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:11 -0800 IronPort-SDR: iUsa7nYxms7eYuEy7n4PMePbVW5Ok0jMnd7t9E4zrqor/Nq0h4rJEhHX+hOFEfQNPtXecbYXIN nXNbyC5rIj96UYmryMni9BX3QGBf2gMG5WwxCSNAjofwQxSbgJOqcdC9SvRs+ubkSrpeGl2Afy vjMu+hj1gM18N8EXDgDZklnglvbqcfnRx6dVfcOIyPJTmbef2RTF2MJw6awaNEhA15Cv6xxv+M v5LQ8TmYhIxO68N3K9idF0ohB1lZ/mpqpd21PURW8OA5wXDus9QjWCD6s7qsTuh4LwP7PmjXkG JZ4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw56r5zfxz1SVny for ; Thu, 10 Feb 2022 23:37: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=1644565044; x=1647157045; bh=//HcszDAJKd/CLH75b 53FTwMYsQK+nBTlok5LRe6EaQ=; b=Q8RGH03YSGbXcPipeKP8YdqrKe+T9YhOoD Whtr4UjT877FI5hMKQlfVLrZMOcs15Sy1PnrI0EW5gayfXDPGemZuHRFAc3ponm/ 4+HKBtnSB+W6hYVcjEDS/fx4bdpRqYYsD98RtwdSY/Xtk5ORKnAAh8t7OKrywZc/ pl3Jv8a0llr/rzorYbHqsTE5cepUUK+ETcgYnjLIctC36R1RODUPKNef+Wpeg1Ov CaVjlIe8JbHzagi1IBdfXU0tM7ofpcUdpB6gibKAlKRbt/b4shelA5xWJG+ihEDL R30WwotwKJoy4bl+pv9QuHmuRHaFEDeWlaUoc6FIOwidkBiTbGxw== 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 VF3D5uAR8Mlw for ; Thu, 10 Feb 2022 23:37: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 4Jw56q0z9hz1SHwl; Thu, 10 Feb 2022 23:37:22 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 14/24] scsi: pm8001: fix le32 values handling in pm80xx_chip_sata_req() Date: Fri, 11 Feb 2022 16:36:54 +0900 Message-Id: <20220211073704.963993-15-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make sure that the __le32 fields of struct sata_cmd are manipulated after applying the correct endian conversion. That is, use cpu_to_le32() for assigning values and le32_to_cpu() for consulting a field value. In particular, make sure that the calculations for the 4G boundary check are done using CPU endianness and *not* little endian values. With these fixes, many sparse warnings are removed. While at it, fix some code identation and add blank lines after variable declarations and in some other places to make this code more readable. Fixes: 0ecdf00ba6e5 ("[SCSI] pm80xx: 4G boundary fix.") Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm80xx_hwi.c | 82 ++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 2e1a9261212d..faff475333a9 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4538,7 +4538,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; @@ -4599,32 +4599,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); } @@ -4635,7 +4641,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) | @@ -4661,31 +4668,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; @@ -4693,27 +4700,28 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, sata_cmd.len = cpu_to_le32(task->total_xfer_len); sata_cmd.esgl = 0; } + /* scsi cdb */ sata_cmd.atapi_scsi_cdb[0] = cpu_to_le32(((task->ata_task.atapi_packet[0]) | - (task->ata_task.atapi_packet[1] << 8) | - (task->ata_task.atapi_packet[2] << 16) | - (task->ata_task.atapi_packet[3] << 24))); + (task->ata_task.atapi_packet[1] << 8) | + (task->ata_task.atapi_packet[2] << 16) | + (task->ata_task.atapi_packet[3] << 24))); sata_cmd.atapi_scsi_cdb[1] = cpu_to_le32(((task->ata_task.atapi_packet[4]) | - (task->ata_task.atapi_packet[5] << 8) | - (task->ata_task.atapi_packet[6] << 16) | - (task->ata_task.atapi_packet[7] << 24))); + (task->ata_task.atapi_packet[5] << 8) | + (task->ata_task.atapi_packet[6] << 16) | + (task->ata_task.atapi_packet[7] << 24))); sata_cmd.atapi_scsi_cdb[2] = cpu_to_le32(((task->ata_task.atapi_packet[8]) | - (task->ata_task.atapi_packet[9] << 8) | - (task->ata_task.atapi_packet[10] << 16) | - (task->ata_task.atapi_packet[11] << 24))); + (task->ata_task.atapi_packet[9] << 8) | + (task->ata_task.atapi_packet[10] << 16) | + (task->ata_task.atapi_packet[11] << 24))); sata_cmd.atapi_scsi_cdb[3] = cpu_to_le32(((task->ata_task.atapi_packet[12]) | - (task->ata_task.atapi_packet[13] << 8) | - (task->ata_task.atapi_packet[14] << 16) | - (task->ata_task.atapi_packet[15] << 24))); + (task->ata_task.atapi_packet[13] << 8) | + (task->ata_task.atapi_packet[14] << 16) | + (task->ata_task.atapi_packet[15] << 24))); } /* Check for read log for failed drive and return */ From patchwork Fri Feb 11 07:36: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: 542037 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 69C37C433FE for ; Fri, 11 Feb 2022 07:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347769AbiBKHhh (ORCPT ); Fri, 11 Feb 2022 02:37:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347726AbiBKHh1 (ORCPT ); Fri, 11 Feb 2022 02:37:27 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B7F4112A for ; Thu, 10 Feb 2022 23:37: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=1644565044; x=1676101044; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=T0RknSK7iqFE4xOMmrc8pK6mkwHdkLqp91rQAtj5i64=; b=EbfbZ+HBSXu72jrr26Sj7YOprNEpwHl7A/j3VgnBzxBPssao6P1wIPov QcTUX9bxBMGEIGuYbUFUKrkyMQwipma0bS7cYoa6919TMKtwNAQaDqbRD 5yctPHxSti2edDcwRnSWSgMzOrhetCw8G2a8V4hvkvrWvylZpkGXE/tPk WEicgAsiBfS41MNZIrrvGJYWdKsUGE1cN0wkrIgFNbPQ4efHC79XH04A7 aAOQ85E9LraQPsX2bmBtv2nKZRGtoP0eh3yaEIG1Rfbst3r0byi9ilWHz mipjzDjQiEFgZPJ/74SOUYErI+7BPifg+/EIurRE816j4wS1t4woJpMCK A==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675150" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:24 +0800 IronPort-SDR: VLaUBB3qgbn1jCHHxm9ef0bhe4W4mGqSg6Cel1ezc39MuJ+zWhyjq1FpwCT5RRLb3w02XBEcW/ Q5fDyIoov+AYJxf4ZfBGYngYflcpi3GE/G7Q6vOttkpuS2JhD/s6srtfJSfqusPkfDMt+gTTUp gWi9dKvB5wkYVkLwopR3n7Uy8ZBeXAQyMevOyPyKZy4gojKP45sFNgUBr1t4F0ZQUiBk/Ar3AK DY8ifX/A7Z3OKZNKrfEsMUTY3Gm7feCyx1kS4dQuiXGjjYNBeDsWLtC6u35iUWOYQoP2ODOYIw oM4vD4zQRnsWBdPeU9a19nwC Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:12 -0800 IronPort-SDR: y0qkfwHZ27kQxgU4UtHWwUuwUd5Gi4t3hetNFVKKsIt7SrE+DlhvN/Sibjtuop15jyZpYOF+bW EeNMkVzdj9Jc+dP8hmhYhmS/umaoH4Iirs3l4/eoFwvX05oUqbIrsyO8eE8jx1nBx7ESJFVThW ArjOtKZ/vaWKOAuwF8rLDNfJ2JSonjK6GWKIch/R4TrOhy9RQWSvF9kAMRRnSYXiRfS6BUj+EJ jspoBNRNZ8d+Qxdwmz+uz9mM+mtSAN2SbDSjO8l4QNRGThd5XWuZR5ZqzE7zKstfEBcqdlIseX His= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw56s6bBFz1SVp0 for ; Thu, 10 Feb 2022 23:37:25 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565045; x=1647157046; bh=T0RknSK7iqFE4xOMmr c8pK6mkwHdkLqp91rQAtj5i64=; b=fWWoPcjNcQx+lNTBsZkixQlbKznUAIKjYv XO3Zs3X/JGeOfAm8XFxJYrUbcymwgQiD8G5ITq+ncXCTvgIyhrfA9m0NneXtPyDN dVnJ9g8O5iJh0ToddEb/BqClmePh9SLO0etmPXvOkTgX1hldEVa14R9yBahwKnnT E2ygxuIDOleEoHOdbFvi5sh//J6BzoI9jg88olWjFr29d8NfkiuTCx4hZF2wU6KM +6IDIaeuMnAmpbtsQezn2pVLMEr0v3DJOiY0KMlv7lzWnqZFAgOZPZdDQGtnHxI5 JoaFxEnVLX1sU7Rg7HF3K7M3l2jcDOMo301fMNN09Hl20pknd0nA== 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 6sc_MlM5OPgZ for ; Thu, 10 Feb 2022 23:37: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 4Jw56r3PJ2z1Rwrw; Thu, 10 Feb 2022 23:37:24 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 15/24] scsi: pm8001: fix use of struct set_phy_profile_req fields Date: Fri, 11 Feb 2022 16:36:55 +0900 Message-Id: <20220211073704.963993-16-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In mpi_set_phy_profile_req() and pm8001_set_phy_profile_single(), use cpu_to_le32() to initialize the ppc_phyid field of struct set_phy_profile_req. Furthermore, fix the definition of the reserved field of this structure to be an array of __le32, to match the use of cpu_to_le32() when assigning values. These changes remove several sparse type warnings. Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm80xx_hwi.c | 12 +++++++----- drivers/scsi/pm8001/pm80xx_hwi.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index faff475333a9..288bad31b423 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4975,12 +4975,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, @@ -5020,8 +5021,9 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, opc = OPC_INB_SET_PHY_PROFILE; payload.tag = cpu_to_le32(tag); - payload.ppc_phyid = (((SAS_PHY_ANALOG_SETTINGS_PAGE & 0xF) << 8) - | (phy & 0xFF)); + payload.ppc_phyid = + cpu_to_le32(((SAS_PHY_ANALOG_SETTINGS_PAGE & 0xF) << 8) + | (phy & 0xFF)); for (i = 0; i < length; i++) payload.reserved[i] = cpu_to_le32(*(buf + i)); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h index c41ed039c92a..d66b49323d49 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.h +++ b/drivers/scsi/pm8001/pm80xx_hwi.h @@ -972,7 +972,7 @@ struct dek_mgmt_req { struct set_phy_profile_req { __le32 tag; __le32 ppc_phyid; - u32 reserved[29]; + __le32 reserved[29]; } __attribute__((packed, aligned(4))); /** From patchwork Fri Feb 11 07:36: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: 542312 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 649E5C433F5 for ; Fri, 11 Feb 2022 07:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347720AbiBKHhi (ORCPT ); Fri, 11 Feb 2022 02:37:38 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347741AbiBKHhe (ORCPT ); Fri, 11 Feb 2022 02:37:34 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 973541156 for ; Thu, 10 Feb 2022 23:37:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644565045; x=1676101045; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=o+9qq7zUJxoUK8qHjvEKnFJaU8c2h1gMU0ygPrb48cs=; b=e53hlkAXWjfhZFVifZ2yNRq90zAnYhmQjEciRKb79CQxozIpUfb/WivH dUAMfGFSEl1mJ5A1I7NnI4DxbimIXCExrP4WNyXmIer0jXfKSVdnwYP/h 9Eb0vZv7/tfgvnNr967TqrXQ95dBihPRpyHyDfTfdyfwHYPlJ6rF/6GWy vPpnJOo4oBxT1EMH86Jl9gOxVl/ffTWiXvsx0hWap6nx5fB8DyNBADpNL wj6rG1JeQ1P6NNlf1NrHVmjrJ2j5P77T/bpI5SF0B0HuCJS5Aq8J2D9zq KmBoC5cJgNJicRst5qH9o1Is6cXXUkhkMo6M/U4BBqSrsU6mlRGOFZ5ob w==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675151" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:25 +0800 IronPort-SDR: DmJqril3cJnyjgF7N9H7/ZeSG1E1g6eIEIX43ssvKvHECS3/ikt8Wr6xWMO/i2ezbfhmykKs/u XCgc4mZpfL3Va4vdUghd4TLqpncrdJVECdbFz/l26kakX8EbhecS51EZr+KocE5+Lf7/g5RrKw uGjyXAEOyXjndSzvflo5ABeB0rkCC6i0u6mUTk3r4GEfN+ijJloPd2+0pyapR/BjMuuR5rLNW1 OouSGwiLq63AoWGp2ESEIx2toDFv7AtoqigiobMN51hY2hVD+RVDuv+SCztlQk5JQxJQcjJd3V IWlsctiaIz2F/UWMDUXYpwgf Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:13 -0800 IronPort-SDR: M/FllstpcMx/5x10Inmz83jrGMBsYKy+w9B24/jnJyHvV/e5vKZXXw3nGwMob7vz0AVLGB/de5 z563iDqJJCIHkfKZC9Ri5LGGSTspy9LSyq6g/2+KxWXYPUpxp9suTBicK542o8V5+U4SC3rBmA Em8dGA85V1gl1i8UUg9J8ZtLhN8MdJuBNglLgXWgRqsDHhZ9Zf+ZlI+Em+KjaHecQBaQgp8VSG 3A+QEtk9NJR/bb6xU9tevrzYyAnPFKoARgnCPkwQO3jLMTs5X2k8zJUg+TDu3Z6o5ITl8rmrYB N4o= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw56v1T3Gz1SVp2 for ; Thu, 10 Feb 2022 23:37: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=1644565046; x=1647157047; bh=o+9qq7zUJxoUK8qHjv EKnFJaU8c2h1gMU0ygPrb48cs=; b=jXN1lqkKwDgyJkDci2HbVJe72DU2vazSd5 8lLyg7SaiFgW+vHWrYbCZtnzCWj3AAB6OkeuxYfoc6HKafwDocri2E6+6L016kAS ENympFfvDLKMW1O1sTcL4YahMXznJWm4lFywoWK2xkK98FBSVkvKexZUdd7JqaxB TT5jGPBkGGko/vASKCT521zSfo2HhRkbMQ9wH5ObIB2mqK5Lld9d6/vO4S9weh2O 2bdc0Xyo+zZgyRTk8mkJGPgHTXkZJm7SR/KPNBmUjbCpTsv9mitw/65gvxuAdiFh FX+HtVAdzxWPry6qYfl6eD9hK7eO3BKEybUt1Lvvyoo+0Mn5IoNw== 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 suFf1xduNFC9 for ; Thu, 10 Feb 2022 23:37:26 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56s5fC6z1SHwl; Thu, 10 Feb 2022 23:37:25 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 16/24] scsi: pm8001: simplify pm8001_get_ncq_tag() Date: Fri, 11 Feb 2022 16:36:56 +0900 Message-Id: <20220211073704.963993-17-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org To detect if a command is NCQ, there is no need to test all possible NCQ command codes. Instead, use ata_is_ncq() to test the command protocol. Reviewed-by: John Garry Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_sas.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 60a56a18e60a..e72006a23c1c 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -304,16 +304,12 @@ static int pm8001_task_prep_smp(struct pm8001_hba_info *pm8001_ha, u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag) { struct ata_queued_cmd *qc = task->uldd_task; - if (qc) { - if (qc->tf.command == ATA_CMD_FPDMA_WRITE || - qc->tf.command == ATA_CMD_FPDMA_READ || - qc->tf.command == ATA_CMD_FPDMA_RECV || - qc->tf.command == ATA_CMD_FPDMA_SEND || - qc->tf.command == ATA_CMD_NCQ_NON_DATA) { - *tag = qc->tag; - return 1; - } + + if (qc && ata_is_ncq(qc->tf.protocol)) { + *tag = qc->tag; + return 1; } + return 0; } From patchwork Fri Feb 11 07:36: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: 542311 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 797D3C433EF for ; Fri, 11 Feb 2022 07:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347741AbiBKHhj (ORCPT ); Fri, 11 Feb 2022 02:37:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347717AbiBKHhf (ORCPT ); Fri, 11 Feb 2022 02:37:35 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFBAA25C3 for ; Thu, 10 Feb 2022 23:37: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=1644565047; x=1676101047; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=WRJ7YjUS7L+40YA6RuU0P5ISAqIp3F+S+1UznVatJjM=; b=UtyxWvCC2Gli9r7SsyFpfTsuIepeoy9lwJqiNFrsAuRnkwcBjABEBxmK dirgNQm8jWNJd4LWIS3yz4Q00J7ZQRIiUzAGiWpTiGiIJKDBF1Pj2JnXp Qle1bTKsJuzRcvqArSFEriXu3xufztERHRdr4gjF+AtXO1UkVWBHgsQm0 xjCgoc9Rd3RMgJpzLnzdZNn4wi2hgj/nz9JjSbA81uTCIxT6E9eNApmZU FQQsEGmLEi9uiJLhQ/dgQK2J8u+8X5zn1QLzS2TXKgq2KCn81/J9yxfcW wul7NuQWkPusSHIFxWSTPTbwnkBLmcVIblZvVPbVnqbLTZ6ehH8zyh7ol A==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675154" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:26 +0800 IronPort-SDR: 5DpO3iHkjWmJo0dCXcJRtK93wyhcYtEZhhVEAD2nUsv3+gbeiT1/wAAxVARtdc6B2VJKLRDmQ2 x5+Q0swLZ6rAnnwD9wPCxRkNjxFa59V0ZR34EoQMsUL2QFisAyM1C5JFignpeT8XaAG0dZQjGe B1wy1uXPD+kedJUQ2604PEXJ1JwN9RkkmgrDWsmEPReBW5T9ZRNArYSifvQSx4TxWapkrNb90Q 6+i8TvfyB73CsZN3yeLL9lVvlS3LgUMRMs4UVy9OPRqvepXETXxC8ainX12rK4uHzACtnRGZAA yfMCo1B84wda1Y35BHWlfpHV Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:15 -0800 IronPort-SDR: 9mOvN+4UjKEfZtLYETanNnLsZ+99xC7HnOnRODNPpzSN/ZMkNNC+E5H1nheJkWMhK7SAif1zsO eFpOI6DGpH/cSGlJeuOeqNDMc9k0CDvzQLdOWDM6VEvX4zUezmO8JydmJuLYBYd9Q14ylppbJ0 mvBTAjF9sme6TLeizp8dnwbe1VDRmLDu81uG+WInEmpwS1QiXACxQJ+Ld6IdLL2VcMUe0x1U73 wuEv2RMRK0qydLoIYUKs1T7UgLMbiJXOJNHbL3TzcbSfPn/xF+HwN7WHygr041zKrFpuCmtdg9 i4o= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw56w3Yyqz1SVp1 for ; Thu, 10 Feb 2022 23:37:28 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565047; x=1647157048; bh=WRJ7YjUS7L+40YA6Ru U0P5ISAqIp3F+S+1UznVatJjM=; b=hwCQMfh7d6LM9G2nS2QM3OFdK9tplxvGaR M4x2Zlky+gFzlLozmSVrKEs8psC9M2TEL4oGroorN3popdhXhPd+pmHV/3KKM4qq JfOBkyZ8LuOvD0ChbVu1KUVpll4a4ZPwVw6suwAZUNwhiU4uTaQZZnJ7d5LI6UQi K9tuHmcdsO3o7V2HLOcUC8VQtUy5qY4pGlZNm8lzkRh+vXCgy6ifcpLSDoAc3s9t hv1rsui8+XHEHzYO5W3viNSBLgtcxP349JSf87WmJJwaiacHxd/5a6n5kCGqGN5L X94LHbGiBxu5pikxSc4WN9NdCjaK/F2JxbWzL0PE9x1XTfBi/DxQ== 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 MwDNUolGKZtV for ; Thu, 10 Feb 2022 23:37: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 4Jw56v0GCQz1Rwrw; Thu, 10 Feb 2022 23:37:26 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 17/24] scsi: pm8001: fix NCQ NON DATA command task initialization Date: Fri, 11 Feb 2022 16:36:57 +0900 Message-Id: <20220211073704.963993-18-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In the pm8001_chip_sata_req() and pm80xx_chip_sata_req() functions, all tasks with a DMA direction of DMA_NONE (no data transfer) are initialized using the ATAP value 0x04. However, NCQ NON DATA commands, while being DMA_NONE commands are NCQ commands and need to be initialized using the value 0x07 for ATAP, similarly to other NCQ commands. Make sure that NCQ NON DATA command tasks are initialized similarly to other NCQ commands by also testing the task "use_ncq" field in addition to the DMA direction. While at it, reorganize the code into a chain of if - else if - else to avoid useless affectations and debug messages. Fixes: dbf9bfe61571 ("[SCSI] pm8001: add SAS/SATA HBA driver") Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_hwi.c | 14 +++++++------- drivers/scsi/pm8001/pm80xx_hwi.c | 13 ++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 43c2ab90f711..9d982eb970fe 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4271,22 +4271,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 288bad31b423..283b68d7da24 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4550,22 +4550,21 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num); circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; - if (task->data_dir == DMA_NONE) { + if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { ATAP = 0x04; /* no data*/ pm8001_dbg(pm8001_ha, IO, "no data\n"); } else if (likely(!task->ata_task.device_control_reg_update)) { - if (task->ata_task.dma_xfer) { + if (task->ata_task.use_ncq && + dev->sata_dev.class != ATA_DEV_ATAPI) { + ATAP = 0x07; /* FPDMA */ + pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); + } else if (task->ata_task.dma_xfer) { ATAP = 0x06; /* DMA */ pm8001_dbg(pm8001_ha, IO, "DMA\n"); } else { ATAP = 0x05; /* PIO*/ pm8001_dbg(pm8001_ha, IO, "PIO\n"); } - if (task->ata_task.use_ncq && - dev->sata_dev.class != ATA_DEV_ATAPI) { - ATAP = 0x07; /* FPDMA */ - pm8001_dbg(pm8001_ha, IO, "FPDMA\n"); - } } if (task->ata_task.use_ncq && pm8001_get_ncq_tag(task, &hdr_tag)) { task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); From patchwork Fri Feb 11 07:36: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: 542036 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 B3F60C4332F for ; Fri, 11 Feb 2022 07:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347749AbiBKHhl (ORCPT ); Fri, 11 Feb 2022 02:37:41 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347748AbiBKHhf (ORCPT ); Fri, 11 Feb 2022 02:37:35 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2627B2678 for ; Thu, 10 Feb 2022 23:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644565048; x=1676101048; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=FeXdlqn2vSeYOtDQaxXiZabjzvdlegzxYr7xC79s/XQ=; b=E0oI4jHbH4XEUFPCiq3FkgP7KOPwDEZmfCqbIJK/xPScFUoJHf9/qZvi lwjlkDAJ33b/BPZG7BGZKvdLaGC5Ssf6p6t3xZHMESa6ow9cg62hK6+XJ wlW+XAsN/BgrhWBcnxmSXbpDi0EyYmsJipVTy7//9kETHBYoZIS84J3zv Fdl37VkhX1S1BWXg/knyKpyVrZAi0GhmvLKm6cNS0ALLpjIwHYUIJc2ao AAr1Mvb5RyUJPzdm7DtjX2k+cVvoXabONLXL3klXjseLQhjOCIEdvox0v OkkrSTh+DV0DcdUGcyGdY//02Wv3tANKnyJ+dAP/dWSPQvYiWVonxsiOm w==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675155" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:28 +0800 IronPort-SDR: MxSaA526LlWQd/D/KfEszHpgEMvggTjU9FFkexRIwhA2ODE4OsJXQpj64qn72Kd3IYDLFlN+dn 971Eyl26NIjmBHC7CKCqMsSpeqbjk04eZxhboFCtijv58OxDSoqKkSNvbSPrjT/17Rbk4IOeJk iOmvS6eU8WlK9zXULyLWLvP2+5xF/IHSoC2PxTapS67EXJzOI4YjsCWrx7YEch95N0lbJjDjmr 7Ltsvykzarf60pAed9UUJn95PccZ5AytVg9DnBcaTPytyjW+TOZGzQetCve/lDB6VFVHPpmV5K rNxkRHOOf/6ey5dLrEoWV84h Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:16 -0800 IronPort-SDR: 9wsgEj5sWJN6wZ+lBaqm0bYgTUHb6KvXJqofRw8rZ+9gvQtM8jXDv5vSqimRuNORS9crk6v5CK 0I1moQIfNcYkRD3SmBDqMR1wwO6LpWOTUTzEplgqSwBn87ovL04c5D10u93J/alrghH2Z54NLt sGnVNG5BLFWOL1pDMp2Nue6r1wSKxFHfEh9vdN0Qq92F6UQx1sapLXK0/xDBTuwejlL42b3OCH 6z9WYMNzusrS2eoaa0DiRmx5/zIy5RR8HTxIts+TyGh63u7xTBfuHcYDuWnXZrngDz+BTkSzvl uCg= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:30 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw56x5Qytz1SVp4 for ; Thu, 10 Feb 2022 23:37: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=1644565049; x=1647157050; bh=FeXdlqn2vSeYOtDQax XiZabjzvdlegzxYr7xC79s/XQ=; b=c5FXOabpsrvlAdpp0YSJaHBneQLnthe09s Y4gKUBFbQ7IMhxILThWgNOfHNhD7VyppZtdh7Q/46EAFPi+jZZrIHOlLp4ml3TaY xGCpZ+Oi3EiQSEKf09y9z6XkPwQTcXZMforljDJ25cp7t9yqxbsyRu8yww5HME+G x3nwxTErG5FqGUF0gBpnWNZOuXMMcl6QWf9Ijx19vyFAY2sCzGRLy7HSdG5M+w+5 vEPyoqp/TXwMdAm5Cm0QnEZF3BfLgzwdgKY5NEtxeICFQpN29FqQZjdc8ykqS3GZ As44bp0grehAtMjnQ02I02yjq0MEZdIw4D7wsoGO/nOub8yATQ4w== 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 SNPkpZHo6x5o for ; Thu, 10 Feb 2022 23:37: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 4Jw56w2Nn6z1SVny; Thu, 10 Feb 2022 23:37:28 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 18/24] scsi: pm8001: fix NCQ NON DATA command completion handling Date: Fri, 11 Feb 2022 16:36:58 +0900 Message-Id: <20220211073704.963993-19-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org NCQ NON DATA is an NCQ command with the DMA_NONE DMA direction and so a register-device-to-host-FIS response is expected for it. However, for an IO_SUCCESS case, mpi_sata_completion() expects a set-device-bits-FIS for any ata task with an use_ncq field true, which includes NCQ NON DATA commands. Fix this to correctly treat NCQ NON DATA commands as non-data by also testing for the DMA_NONE DMA direction. Fixes: dbf9bfe61571 ("[SCSI] pm8001: add SAS/SATA HBA driver") Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_hwi.c | 3 ++- drivers/scsi/pm8001/pm80xx_hwi.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 9d982eb970fe..8095eb0b04f7 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -2418,7 +2418,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 283b68d7da24..d9f0afe784e7 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -2509,7 +2509,8 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, len = sizeof(struct pio_setup_fis); pm8001_dbg(pm8001_ha, IO, "PIO read len = %d\n", len); - } else if (t->ata_task.use_ncq) { + } else if (t->ata_task.use_ncq && + t->data_dir != DMA_NONE) { len = sizeof(struct set_dev_bits_fis); pm8001_dbg(pm8001_ha, IO, "FPDMA len = %d\n", len); From patchwork Fri Feb 11 07:36: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: 542308 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 7A61CC433F5 for ; Fri, 11 Feb 2022 07:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347817AbiBKHsS (ORCPT ); Fri, 11 Feb 2022 02:48:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347800AbiBKHsS (ORCPT ); Fri, 11 Feb 2022 02:48:18 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF843B35 for ; Thu, 10 Feb 2022 23:48: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=1644565696; x=1676101696; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=ZEH58Mx+JDtaj1pUPUFdEIk3VShBFqVuE+ZOslCsQAA=; b=pldyjPGp6rvUXwK3Ev8uLtJHI1Z+FEpi+4JOUEs2fyAZgvGjGDGawmnw 6byWiWvji+keoumjsIEBQe5KazdtEsqxtmyhdtMOnCXbe7t2cTfp9WMRG /NbIf+63oGPFqdxLUgwzToy3TauoAW9rPn+GLEM66Dv96kdDjkFzKLqL0 o2YB3My9Rj1ku3dfxRsoAEeRdPCOFrLFlXaovvnRf5KU8sMGHuaMs+z3g /9WzFtGZpB2FAu+whymoiTjXjrOC/sI7W5Xdt75KvygnwtNxREPOBqn56 HJXnoM0i9iVuQAPDHdbl8tiWFbx74ZRE02Oktpv9ptqdQxSVTrRVWgum7 Q==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675711" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:48:16 +0800 IronPort-SDR: Qu0CimtmBFqdlWK0XNYM1uqFiDN/l8IGA41Jhqs6hwfd2lIjFD2dV1LNKmrEaW5yO+05FD183/ A6b2syxQroGwspVBQoExG+O9k22LBN8gMeNYykH4Z06v/IgMSRW9zfK93PqGcGh69w+ZCn1Oir sZUC71Jw95PLiDmajD9oN14KXz3ILRK0jjWVFwGlSAHddCg46N+qI7RRz/ONzV5lwni38IRhhs tCY9fgZo58YeTs+mL2CyerFcwVwO1rCgZkzfoMwhfWjQ6iaMCpGiGD6YXywp0UcHG4e5A3XRcY o1qeGBaLfbnhF6p634Nk1Zyz Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:20:04 -0800 IronPort-SDR: cCggl333x3uCHvRvEyF22ZPdCJA1VlF6BTLJcXMBNAVEWeRTC7HHLWdwuTByZyfz9A4YGdf4hA KBPWXDrcVl9VCsBKLCDSdwhTbeMx9yqOgXlQXqDDFk7t8p6MJ7DVFMBqElsJR/IeYwCbrNBkxl rEd7UtM16uLtW1Yu6S7q/Jx7QBFezogPwWBnYGls87JIA3ferO47cbObvTbQ2v6cCJ5WbeLCzV tPVItR/FbwM7psWiqY2o/7vkye5bE+4Pn8Ya+iC8zgdoDNoLDgXoUXdVRtotI8K3tJOU1SXBl1 cb4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:48: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 4Jw56z0fBxz1SVp6 for ; Thu, 10 Feb 2022 23:37:31 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565050; x=1647157051; bh=ZEH58Mx+JDtaj1pUPU FdEIk3VShBFqVuE+ZOslCsQAA=; b=rmtH8Jz0PyugAOT253/GXNlaVeUe5HSDKC TI47GluksvmxbxI9/JieOwf7T36d6Vsphsj2XVKzhvr6n1iJDW8u54yeJmldC+A8 cV4jAPcWK0+185r/kWCpU2COTEMNQ2YFw1djzWtWFYYp5DfutXlGpWtXHZI/1QtD ulA9cqYA9y6w338B3epwhXerLejLho9XrGD174DZL7ArhqLve6BtxsmOPO8QBjOi kUFzCQFqQ+c1Y2klb4oCa7oc8QztCO4qS8hHPXoqz8fRCQW4FRgwGMT16uQrbIpo ysKBSt/FmBmlHifs9z8g/ceqSladAoRA/UXWKQnjyhuWmkTMxZIw== 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 ryb2cqPVLFoT for ; Thu, 10 Feb 2022 23:37:30 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw56x47LTz1Rwrw; Thu, 10 Feb 2022 23:37:29 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 19/24] scsi: pm8001: cleanup pm8001_queue_command() Date: Fri, 11 Feb 2022 16:36:59 +0900 Message-Id: <20220211073704.963993-20-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Avoid repeatedly declaring "struct task_status_struct *ts" to handle error cases by declaring this variable for the entire function scope. This allows simplifying the error cases, and together with the addition of blank lines make the code more readable. Reviewed-by: John Garry Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_sas.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index e72006a23c1c..7b749da82a61 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -381,54 +381,53 @@ static int pm8001_task_exec(struct sas_task *task, struct pm8001_device *pm8001_dev; struct pm8001_port *port = NULL; struct sas_task *t = task; + struct task_status_struct *ts = &t->task_status; struct pm8001_ccb_info *ccb; u32 tag = 0xdeadbeef, rc = 0, n_elem = 0; unsigned long flags = 0; enum sas_protocol task_proto = t->task_proto; if (!dev->port) { - struct task_status_struct *tsm = &t->task_status; - tsm->resp = SAS_TASK_UNDELIVERED; - tsm->stat = SAS_PHY_DOWN; + ts->resp = SAS_TASK_UNDELIVERED; + ts->stat = SAS_PHY_DOWN; if (dev->dev_type != SAS_SATA_DEV) t->task_done(t); return 0; } + pm8001_ha = pm8001_find_ha_by_dev(task->dev); if (pm8001_ha->controller_fatal_error) { - struct task_status_struct *ts = &t->task_status; - ts->resp = SAS_TASK_UNDELIVERED; t->task_done(t); return 0; } + pm8001_dbg(pm8001_ha, IO, "pm8001_task_exec device\n"); + spin_lock_irqsave(&pm8001_ha->lock, flags); + do { dev = t->dev; pm8001_dev = dev->lldd_dev; port = &pm8001_ha->port[sas_find_local_port_id(dev)]; + if (DEV_IS_GONE(pm8001_dev) || !port->port_attached) { + ts->resp = SAS_TASK_UNDELIVERED; + ts->stat = SAS_PHY_DOWN; if (sas_protocol_ata(task_proto)) { - struct task_status_struct *ts = &t->task_status; - ts->resp = SAS_TASK_UNDELIVERED; - ts->stat = SAS_PHY_DOWN; - spin_unlock_irqrestore(&pm8001_ha->lock, flags); t->task_done(t); spin_lock_irqsave(&pm8001_ha->lock, flags); - continue; } else { - struct task_status_struct *ts = &t->task_status; - ts->resp = SAS_TASK_UNDELIVERED; - ts->stat = SAS_PHY_DOWN; t->task_done(t); - continue; } + continue; } + rc = pm8001_tag_alloc(pm8001_ha, &tag); if (rc) goto err_out; + ccb = &pm8001_ha->ccb_info[tag]; if (!sas_protocol_ata(task_proto)) { From patchwork Fri Feb 11 07:37: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: 542035 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 94055C433EF for ; Fri, 11 Feb 2022 07:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347704AbiBKHho (ORCPT ); Fri, 11 Feb 2022 02:37:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347751AbiBKHhh (ORCPT ); Fri, 11 Feb 2022 02:37:37 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF357271B for ; Thu, 10 Feb 2022 23:37: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=1644565051; x=1676101051; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=m9ONpfbaNybtnS2LxOy9cE3+ApQLiS17hBJJN1ZGn9o=; b=YNcxnjkQC/NowUJQnpuQ8421kb0OrB6jxO7IEadPEFz037iGBht0Jo8J 8u1P4xAYs250PocnnUE4PxeNPV6ebSoRPCaTm51BkhPVxsGQPzph/JBe6 K56oELSoMv/3q9aGP4+9JjKWkWwCMvHm2919PsoB9UXwgo+eJMLPMqZTK 8KvdCgaKR+E2TcnzaLNXET9eWMtu43wqyeG7I44s+RkPObE6qwcjNC021 CllM5C+SoTHdKs1o/PX4d/y+MFQPBQbF+Ac7u8jB75hbYe8m7QSCTNU8u c2rQaQqRVuTsoxcu/lNRd1EHqFBYCOav4Gx8Lyl/jzHSMdhlmp3W0AmWX A==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675158" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:30 +0800 IronPort-SDR: A6YfhkLwW9N0RQbk8Ou6Bgd1J+9WvoWVvjJVcgrpkyoRrJzo4hZ90vUTpDNyjj4xV+V4Ok9ZsK JCqKBJcSIuWxEyXZJI/rnsoFI9BBkzhKXka/YGAwY3LJ/08emz7zc+OUUDXO1PogIt0U0yrSKG 1sn/zVv/mgZqnLGWZIOX4/2rBmf4j18CiFqAlHZ8WjmV4hHRC8ghyqKjAzFA+nFJ1wSXqvcznM sU4BH+fR87oKejdup9a7rnunGKSB52Bt3QQIYImVaT0Z6ZRdNfoYjXHdtM7Um0/DDFsFToEG8m JW7kyGDLY9Z6L5vvR/R/S9Rk Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:19 -0800 IronPort-SDR: rIwrTnbQ7x23p82vMbZ0ih85XEco5LKFVLL7PUmY1obTYzh+YJLU9GT90D/kaiK39nJBStSK+S 2maTLTvSXCLodrrTSYcxZRSOvTU7tFCEqigWO/y0484rKEkPRZKuLH4GyjVto6v4Swuhr7smhy 2lE1dCbLLhXOrEyRfQAKjlbwDbCHgOltANUxUWaDsreqyVnzVldafZRNAmjJP71giEZpB/R5fP lif+a0CFvHRLIsWZjypGXM5ySUgjlm8VFAKQ/jZ/OQls2jeGhRXe00CVjK3M4Gt0i+DS29lyon 2MI= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:33 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw5703vHrz1SVp3 for ; Thu, 10 Feb 2022 23:37: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=1644565051; x=1647157052; bh=m9ONpfbaNybtnS2LxO y9cE3+ApQLiS17hBJJN1ZGn9o=; b=ZlsL+uU9AYNrRQP58iR+Z8MmCfLyO4DwL1 Gyy80vdOC75P6u7NHlh7Zz5QeSUup7B1yIWFA7YiwJdRKVXp4PZpaeWVq/QPtlDr 71SPyuLgC6enm8yr0d99f8bRI+rmiJn40L5/vRRUSW1EXiIU04jMWquqeotkHTK9 acybukOvVAgmL4O0wCmrMjyyoLJBvAG0J+5Rjtbzam1KQe4D90q5pMolPDnPHJH6 z/HAr1njEzaVLoAbECfI4i/Hh+TUDAILLHQqCcqXKGqrGqDEJuzs1clrxJxnFdKq a/vaNyru+GuSMxEWzhTf37BBEUp4vZXvqEI8BgJICt1GKRPzo/FQ== 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 WkR_1LyMMpE1 for ; Thu, 10 Feb 2022 23:37: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 4Jw56y6HScz1SHwl; Thu, 10 Feb 2022 23:37:30 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 20/24] scsi: pm8001: fix abort all task initialization Date: Fri, 11 Feb 2022 16:37:00 +0900 Message-Id: <20220211073704.963993-21-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In pm80xx_send_abort_all(), the n_elem field of the ccb used is not initialized to 0. This missing initialization sometimes lead to the task completion path seeing the ccb with a non-zero n_elem resulting in the execution of invalid dma_unmap_sg() calls in pm8001_ccb_task_free(), causing a crash such as: [ 197.676341] RIP: 0010:iommu_dma_unmap_sg+0x6d/0x280 [ 197.700204] RSP: 0018:ffff889bbcf89c88 EFLAGS: 00010012 [ 197.705485] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff83d0bda0 [ 197.712687] RDX: 0000000000000002 RSI: 0000000000000000 RDI: ffff88810dffc0d0 [ 197.719887] RBP: 0000000000000000 R08: 0000000000000000 R09: ffff8881c790098b [ 197.727089] R10: ffffed1038f20131 R11: 0000000000000001 R12: 0000000000000000 [ 197.734296] R13: ffff88810dffc0d0 R14: 0000000000000010 R15: 0000000000000000 [ 197.741493] FS: 0000000000000000(0000) GS:ffff889bbcf80000(0000) knlGS:0000000000000000 [ 197.749659] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 197.755459] CR2: 00007f16c1b42734 CR3: 0000000004814000 CR4: 0000000000350ee0 [ 197.762656] Call Trace: [ 197.765127] [ 197.767162] pm8001_ccb_task_free+0x5f1/0x820 [pm80xx] [ 197.772364] ? do_raw_spin_unlock+0x54/0x220 [ 197.776680] pm8001_mpi_task_abort_resp+0x2ce/0x4f0 [pm80xx] [ 197.782406] process_oq+0xe85/0x7890 [pm80xx] [ 197.786817] ? lock_acquire+0x194/0x490 [ 197.790697] ? handle_irq_event+0x10e/0x1b0 [ 197.794920] ? mpi_sata_completion+0x2d70/0x2d70 [pm80xx] [ 197.800378] ? __wake_up_bit+0x100/0x100 [ 197.804340] ? lock_is_held_type+0x98/0x110 [ 197.808565] pm80xx_chip_isr+0x94/0x130 [pm80xx] [ 197.813243] tasklet_action_common.constprop.0+0x24b/0x2f0 [ 197.818785] __do_softirq+0x1b5/0x82d [ 197.822485] ? do_raw_spin_unlock+0x54/0x220 [ 197.826799] __irq_exit_rcu+0x17e/0x1e0 [ 197.830678] irq_exit_rcu+0xa/0x20 [ 197.834114] common_interrupt+0x78/0x90 [ 197.840051] [ 197.844236] [ 197.848397] asm_common_interrupt+0x1e/0x40 Avoid this issue by always initializing the ccb n_elem field to 0 in pm8001_send_abort_all(), pm8001_send_read_log() and pm80xx_send_abort_all(). Fixes: c6b9ef5779c3 ("[SCSI] pm80xx: NCQ error handling changes") Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_hwi.c | 2 ++ drivers/scsi/pm8001/pm80xx_hwi.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 8095eb0b04f7..d853e8d0195a 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1788,6 +1788,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]; @@ -1849,6 +1850,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 d9f0afe784e7..0cf515844493 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -1800,6 +1800,7 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; + ccb->n_elem = 0; circularQ = &pm8001_ha->inbnd_q_tbl[0]; From patchwork Fri Feb 11 07:37: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: 542310 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 3C58CC433F5 for ; Fri, 11 Feb 2022 07:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347771AbiBKHh7 (ORCPT ); Fri, 11 Feb 2022 02:37:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347759AbiBKHhh (ORCPT ); Fri, 11 Feb 2022 02:37:37 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31399272B for ; Thu, 10 Feb 2022 23:37: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=1644565052; x=1676101052; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=oQ2ji8IJZUHle9Y9hqNsyKJ4i2QjdaIMrbal2CVVGoM=; b=foqUKQa520LWaf/CqTikg/Gul/vTGJMN2ycS258jzVd0IYhCERKNcf79 sihKHKoAB3UkPAq26XQ9gpUEpWbXCGFZ9Qhg8fuI0LMl4yY16nZn0W8sW DIBnLGWeG0on96hCKgYPisMwBKmeLj+eAxxfuCqCEgcOpDu8e/eYivuXX 95vYcvTrINwTJTkWLtSD/jBUsU41AVl1I5P7X7tvNS7j+P4sdzRD1+/ht LxGGTKkE8/RNzSZVLMthXu27aamBUTYYLHmDE82HowQQbhP6paY6Cph91 Kf5okX6UM5AdM/787QJzIw3mdScgPPV0pX/Gih1fXO+LhTcl7831xFQ6I g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675159" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:32 +0800 IronPort-SDR: 0pMA3GxDb4mDJAl9dXUu0mBiNt4//fH2v6Uqy8o3nJd48FAMKnjyhBYf1pdOGNp973dpJRN/0T 1c2OHqDV0738+xLQVMqQ3Er0n6JtJ5/+HI+TW+AJDrXHZ6PZHg+IrjPS1GXmHJJXJOHVHFK7C2 D/V6e67uSPimKpyRI/qxcdhidV1bP+4C2TRvO+kF2/hez3WLhtzXQOKQ5iF/fKzK7YVo+E9EUu KqCHceKTqsynMwhlmopQWK6j5OZuRuIrTVRp4gJzsmxhif8T/S6OURnAv+yAwfMVK/kTM7rOIs PYTR+z3KaQ9GW92YuEQAkwmb Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:20 -0800 IronPort-SDR: 3twWOgTG16yL/lLtd8A67jqazkdwxc+TagOVuKex3txeh8/BxeVfTRvmXd//2ypsRTnz5dnnWV Ciioo84Ycshgt+2bQW8tACsg9AU93w4aP0qOLprFoG1Z8pvmpLUEPoUIl8jhV9UvN+Gy+tCmJp 3CWWnuClLk5wOFPf7zx77cavcxelnfIvloZejdjk65XGGuuM9tHGboz3jFGfMqidTHxGZ6+RMz 3rfxnsOL84A6rdxXImdPjkFDq+2sORSRkObjoeB+h6ipax46+w/IyIPcdeU5S04zqFA4WZJURI J64= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw5714HTTz1SVp0 for ; Thu, 10 Feb 2022 23:37: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=1644565053; x=1647157054; bh=oQ2ji8IJZUHle9Y9hq NsyKJ4i2QjdaIMrbal2CVVGoM=; b=LS5juentKpcEO0XrmCXDqaHUiwHgXRgJDX 2kW94twbus9Zu1fH8VyP+ntGS0+7+0SxiDSyu628ricm86B10iV/E+jIrLMi4U30 u39aqKXrK+04TZidfJD0SW7nPem+iQFuKEYCxetoyhPEm3EtZ6c0WSod4VC9P/Vp 3aJcNn/ZqVoQQ+P6laiHt1W4O98WAD8RQghDHCt8Su2vY1MiCuKXAtCoA1OBG4IR o5KUCcU7dsckvo6EtyCdDEmcajzXIU66fLBfHgMjZWqTbpAe/rZ1NSDeQJwePWVg CK9rN5mSxyPuZUnL+jjY3UO+163duK5qnSpUFPJ3EzPtO7HNYyJg== 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 egH6V3ewhEMN for ; Thu, 10 Feb 2022 23:37:33 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Jw5701l76z1Rwrw; Thu, 10 Feb 2022 23:37:32 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 21/24] scsi: pm8001: Fix pm8001_task_exec() Date: Fri, 11 Feb 2022 16:37:01 +0900 Message-Id: <20220211073704.963993-22-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The n_elem local variable in pm8001_task_exec() is initialized to 0 and changed set to the number of DMA scatter elements for a needed for a task command only for ATA commands and for SAS commands that have a non-zero number of sg segments. n_elem is never initialized to 0 for SAS commands that do not no sg segments, potentially leading to an incorrect value of n_elem being used for a task. Add the missing 0 initialization. Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_sas.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 7b749da82a61..8cd7e7837f41 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -383,7 +383,7 @@ static int pm8001_task_exec(struct sas_task *task, struct sas_task *t = task; struct task_status_struct *ts = &t->task_status; struct pm8001_ccb_info *ccb; - u32 tag = 0xdeadbeef, rc = 0, n_elem = 0; + u32 tag = 0xdeadbeef, rc = 0, n_elem; unsigned long flags = 0; enum sas_protocol task_proto = t->task_proto; @@ -440,6 +440,8 @@ static int pm8001_task_exec(struct sas_task *task, rc = -ENOMEM; goto err_out_tag; } + } else { + n_elem = 0; } } else { n_elem = t->num_scatter; From patchwork Fri Feb 11 07:37: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: 542034 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 19759C433FE for ; Fri, 11 Feb 2022 07:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347726AbiBKHiA (ORCPT ); Fri, 11 Feb 2022 02:38:00 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347770AbiBKHhh (ORCPT ); Fri, 11 Feb 2022 02:37:37 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C50910E1 for ; Thu, 10 Feb 2022 23:37: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=1644565053; x=1676101053; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=AitAV1CBe7kiP6NC834qdZNZdn/41OHpdV7ouBe4kno=; b=mDQarEUKPjFIC0wH/166j7C019gMLKHUlsTHELUL/cxEPdK0n9gU30Xw hXG2N49NXdqURc1dHtX2yceLaRttU84gA5Cvv9cnmVWPPA+Y+DqiwWYeB G7EqMuO/AVhEHwYUbkCq2nRthlIgaN+uZei79RW2cTrdd3U7BchvEYT28 kPHk1tI8fozPMosSm7QsXmqWT2aukyQn02OVl0SD44r5pEpeIF28pI48x JyYM/ujt8hKpdofRmYG66M9YQJxO3ozGg29jFJ5Tdrf7aIM9J4JPVLeP4 jII9I62vZ7LbDLwcI/TjvANI6CS9ha4gjCn9sHe8R3NpBSZJP5w1UhSvW g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675160" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:33 +0800 IronPort-SDR: gsVY77IdQCXEJyEG8ye5QEywD/Glnpae4d5YSNznsWC6Y/fn/NYiQQCtPUpwPxFmDT+UO5v5xU OfgRxiBNhyTA4eF/VzxtyqOtajDcEsK7P8xZ4uF/aLtcNDBNZMuwIPRU827FZb/ViZlkkcsgdk /N5gIdbZqgGPsQvVeJTo63k9y7KOKR2KwB/yXz2ZjyxvfN6z3GM54gdCEiRdmxa4EpSl+P+eK4 5XM86Ga/tAf4Y/lZmMTOGNt4ZiCxQGleJMj9lgYp1THxiyr/MlGq24NZy6e2SETWJA4pSqMXbR 6NL3UbL9uKyscHoakMnzYV48 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:21 -0800 IronPort-SDR: 7HNOpVQd0WgDLzlBXFDOVfur/qJdw3No3CHs0NdkAfXE0vzNntbpBen0yZCl3GZsNF0DjiP24P 6YAfHgh36RzJmAxWjuvvCcLLj6twNBFflGr9A684oan+LWnMQ0s6WD/H/PJofYvv+h9FR7oo9c GI20PwgFSPKAZ9jfmPUXxB2ohyEVC/q6lhZsw4bV4uUbfQEJ7PDt7NlB0AI8if+0ptBP3y3hOf igfHOYcUaUt1cSJz7DOJSOZF1Cc4MZwmVf4xjFIbG7ScvdRDsW9Ml1B8UJiTHqM7cCS4U9kq2k qVQ= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:36 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Jw57303Vhz1SVp2 for ; Thu, 10 Feb 2022 23:37:35 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1644565054; x=1647157055; bh=AitAV1CBe7kiP6NC83 4qdZNZdn/41OHpdV7ouBe4kno=; b=gbfwGjTlPQzlR3xxXQjA1HVidEYzg1Ywec KLeHVfQqjjvinYRIePro8otazEbz1rf5tGFZisy5Etg4ELsYlisM35TEQhk70Rso jjJ6g8agXv0UkboAUTls80K+v4Dnu6Yl582Yn++1K80PJhDatgHo6Ho3BhGbQPXs S1PIFn/UfJZKVh38Iz7izEmczb1OyPGy2EUGRB92Up2IikKbBXmeJboHKAEAhfDa bAs5eGz3f6qUdwIZgv7/SO5BJtUaTve/U0zJIhuUkcYyXCDlN8aqn3/Zk3ta+OEd 8RqeJhH3LjP3/lwsnEJbxUMT1TwRlcALN5MynHi317MGDECQkwJw== 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 XoTs5Zeswc9k for ; Thu, 10 Feb 2022 23:37: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 4Jw5713YHfz1SHwl; Thu, 10 Feb 2022 23:37:33 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 22/24] scsi: pm8001: Fix pm8001_tag_alloc() failures handling Date: Fri, 11 Feb 2022 16:37:02 +0900 Message-Id: <20220211073704.963993-23-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-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. Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm80xx_hwi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 0cf515844493..ce33d0e71076 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4972,8 +4972,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 = @@ -5015,8 +5018,10 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha, memset(&payload, 0, sizeof(payload)); rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) + if (rc) { pm8001_dbg(pm8001_ha, INIT, "Invalid tag\n"); + return; + } circularQ = &pm8001_ha->inbnd_q_tbl[0]; opc = OPC_INB_SET_PHY_PROFILE; From patchwork Fri Feb 11 07:37: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: 542309 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 9941EC43217 for ; Fri, 11 Feb 2022 07:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347735AbiBKHiB (ORCPT ); Fri, 11 Feb 2022 02:38:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347717AbiBKHhk (ORCPT ); Fri, 11 Feb 2022 02:37:40 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0CC9113A for ; Thu, 10 Feb 2022 23:37: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=1644565056; x=1676101056; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=hXPqmIXiC6fp3v8P+yy+phH6B+zb+6qWEioSWfTUL7U=; b=oTscMybZUqJNc52JUkNl1/hJqUjc1lHAPcy2UDiBBDgqA2nrgyqKVrP5 +QX1MgQqY+HuBPG1V7xrIfRR34Cfw/NOLc+t/XATuxhLKQhDHAFXubKa8 ik++yM3ktXXwmERExNfMgimRGCWtzUNPyidmMJ8lBFQkvutu/9dV5N6kH gYGQg5VO5ggdKqGTzPJ+coKkx3NVBpbSunSl1S7yXgRfU2JLqjCRNSqq0 HZO3Lw+lh/wT1+LsLDlvC0pXgqsHWU6QCOkSOX6vuo2/wIAvRih/VtKda gin67FjFiV+hxSb+hYgyNPPFogslIBOGDBWGAVputMr56bmuhg25cxFVu A==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675162" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:36 +0800 IronPort-SDR: nAf+INTGOvVjljP7ZoaWA02uNeqJ2AwUYkA2bNC9hjiOL/59C7uN1PZo9G4wC49jxrXgA8nsqn 6MP7fX57exkWfUQGWA/eHBdCoOOoG3qXjTYGnvSyJFfBRWIrQlXdaIwf1Xv7qvNg+Dixq6Mcnb SdPUcdesVKG8f3w9p2wIsCHHYhPv1ruaL0lgEm5RfofvyDpLH/3FDvTr77qp2wDkjYfKMR0cS9 BtHyEqHtAGNK1kPVlFYnRKNDhCDgJFi7KDvAWuM4g4VpKk9ozxkGSSSsq5QQNasqpPw8ssG5h2 KUxtycd8SyJJoUssm7FIBenI Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:25 -0800 IronPort-SDR: xwRzl1953XEQZb+/9+X48oGjvSnRk1jQciztWR9sipM4YhDqWESQJ9+uTFr2B6Zp/5qfpb3IkT cctRc6Lg/iUDK/359lEZaeQa96qm80FoojF8SEPL+sT+v5kKv8GWiK4x4fyoateUySaAmeesZr Qt6mZ2NJrngixbh3Xc9w66GeyihvBjDwhSMvyLDVYxd8HoE8AXX6DHtdfbfl8yNzajis6usjQv vGV2UUHZqhVeCBVi10jT5TevAfciIKZfI7LYsoNLJ0pyeOgvJ/XesJau349jc7JswMv8EpYzrl Ls4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37: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 4Jw5752JcNz1SHwl for ; Thu, 10 Feb 2022 23:37: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=1644565055; x=1647157056; bh=hXPqmIXiC6fp3v8P+y y+phH6B+zb+6qWEioSWfTUL7U=; b=fq1+iyegpJ5Mp9L8r2g7xPxirBjvpfKdUv 7+p9X7sbsU/gRnLSR27cxLObj2nt6a8zw/XEJ5uUoRiNYAjFPesagb72+sklNqii HGzh5vpe4pYJwm/X74Co18PWowXsQJ10brMxIhmNEnIoceiR45b+1t8xzvhjnNHP lsA4ZdGQOpEoV2/GJBLEE3Y7GD8Qpu15sFBrX9ToF5oIdMImnhEWP92M+7pWc87A IbkMyQ2TiDS5c0rbLP5+gmZr3gqciiOxdgzVMJm5mUpkI8b4xu8yJMzyM8zSAnhF 5KZ4or946FFYzScUfXbtJo1slSlv+1dekuxxbak7hVwqUFgGFHDQ== 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 bpHYRdkLNKKC for ; Thu, 10 Feb 2022 23:37: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 4Jw5725HHXz1SVp0; Thu, 10 Feb 2022 23:37:34 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 23/24] scsi: pm8001: Introduce ccb alloc/free helpers Date: Fri, 11 Feb 2022 16:37:03 +0900 Message-Id: <20220211073704.963993-24-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-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 pattern: res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); ... ccb = &pm8001_ha->ccb_info[ccb_tag]; ccb->device = pm8001_ha_dev; ccb->ccb_tag = ccb_tag; ccb->task = task; ccb->n_elem = 0; With a simpler single function call: ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_ha_dev, task); 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. All call site of the pm8001_tag_alloc() function that use the ccb info associated with the allocated tag are converted to use the new helpers. Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_hwi.c | 153 ++++++++++++++----------------- drivers/scsi/pm8001/pm8001_sas.c | 37 +++----- drivers/scsi/pm8001/pm8001_sas.h | 33 +++++++ drivers/scsi/pm8001/pm80xx_hwi.c | 66 ++++++------- 4 files changed, 141 insertions(+), 148 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index d853e8d0195a..8c4cf4e254ba 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1757,8 +1757,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; @@ -1780,28 +1778,26 @@ 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) { + pm8001_dbg(pm8001_ha, FAIL, "cannot allocate tag !!!\n"); + 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) - pm8001_tag_free(pm8001_ha, ccb_tag); - + if (ret) { + sas_free_task(task); + pm8001_ccb_free(pm8001_ha, ccb); + } } static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, @@ -1809,7 +1805,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; @@ -1825,20 +1820,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; @@ -1846,11 +1834,14 @@ 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) { + pm8001_dbg(pm8001_ha, FAIL, "cannot allocate tag !!!\n"); + sas_free_task(task); + kfree(dev); + return; + } + pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; @@ -1865,7 +1856,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)); @@ -1874,7 +1865,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); } } @@ -4433,7 +4424,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; @@ -4444,13 +4435,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 { @@ -4642,7 +4631,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; @@ -4657,15 +4645,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 -EBUSY; } - 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: { @@ -4726,7 +4714,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; } @@ -4737,7 +4725,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; @@ -4753,15 +4740,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; } - 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; @@ -4811,7 +4798,7 @@ int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha, sizeof(nvmd_req), 0); if (rc) { kfree(fw_control_context); - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); } return rc; } @@ -4856,8 +4843,6 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, struct fw_flash_updata_info flash_update_info; 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; @@ -4881,17 +4866,16 @@ 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; } - 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); - return rc; + + return pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, + ccb->ccb_tag); } ssize_t @@ -4979,24 +4963,21 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, struct set_dev_state_req payload; 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) + + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, NULL); + if (!ccb) return -1; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->ccb_tag = tag; - ccb->device = pm8001_dev; + 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); - return rc; + return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + sizeof(payload), 0); } static int @@ -5006,25 +4987,27 @@ 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) + + ccb = pm8001_ccb_alloc(pm8001_ha, NULL, NULL); + if (!ccb) return -ENOMEM; - ccb = &pm8001_ha->ccb_info[tag]; - ccb->ccb_tag = tag; + 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); + 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 8cd7e7837f41..6b8843344893 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -74,7 +74,7 @@ void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag) * @pm8001_ha: our hba struct * @tag_out: the found empty tag . */ -inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) +int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) { unsigned int tag; void *bitmap = pm8001_ha->tags; @@ -383,7 +383,7 @@ static int pm8001_task_exec(struct sas_task *task, struct sas_task *t = task; struct task_status_struct *ts = &t->task_status; struct pm8001_ccb_info *ccb; - u32 tag = 0xdeadbeef, rc = 0, n_elem; + u32 rc = 0, n_elem; unsigned long flags = 0; enum sas_protocol task_proto = t->task_proto; @@ -424,11 +424,11 @@ static int pm8001_task_exec(struct sas_task *task, continue; } - rc = pm8001_tag_alloc(pm8001_ha, &tag); - if (rc) + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, t); + if (!ccb) { + rc = -EBUSY; goto err_out; - - ccb = &pm8001_ha->ccb_info[tag]; + } if (!sas_protocol_ata(task_proto)) { if (t->num_scatter) { @@ -438,7 +438,7 @@ static int pm8001_task_exec(struct sas_task *task, t->data_dir); if (!n_elem) { rc = -ENOMEM; - goto err_out_tag; + goto err_out_ccb; } } else { n_elem = 0; @@ -449,9 +449,7 @@ static int pm8001_task_exec(struct sas_task *task, t->lldd_task = ccb; ccb->n_elem = n_elem; - ccb->ccb_tag = tag; - ccb->task = t; - ccb->device = pm8001_dev; + switch (task_proto) { case SAS_PROTOCOL_SMP: atomic_inc(&pm8001_dev->running_req); @@ -480,7 +478,7 @@ static int pm8001_task_exec(struct sas_task *task, if (rc) { pm8001_dbg(pm8001_ha, IO, "rc is %x\n", rc); atomic_dec(&pm8001_dev->running_req); - goto err_out_tag; + goto err_out_ccb; } /* TODO: select normal or high priority */ spin_lock(&t->task_state_lock); @@ -490,8 +488,8 @@ static int pm8001_task_exec(struct sas_task *task, 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)) @@ -816,7 +814,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; @@ -832,18 +829,12 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, task->slow_task->timer.expires = jiffies + PM8001_TASK_TIMEOUT * HZ; add_timer(&task->slow_task->timer); - res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) + ccb = pm8001_ccb_alloc(pm8001_ha, pm8001_dev, task); + if (!ccb) goto ex_err; - ccb = &pm8001_ha->ccb_info[ccb_tag]; - ccb->device = pm8001_dev; - ccb->ccb_tag = ccb_tag; - ccb->task = task; - ccb->n_elem = 0; res = PM8001_CHIP_DISP->task_abort(pm8001_ha, - pm8001_dev, flag, task_tag, ccb_tag); - + pm8001_dev, flag, task_tag, ccb->ccb_tag); if (res) { del_timer(&task->slow_task->timer); pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n"); diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h index a17da1cebce1..6aafa48bf235 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -738,6 +738,39 @@ void pm8001_free_dev(struct pm8001_device *pm8001_dev); /* ctl shared API */ extern const struct attribute_group *pm8001_host_groups[]; +/* + * 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)) + 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) +{ + pm8001_tag_free(pm8001_ha, ccb->ccb_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 ce33d0e71076..eddaf2dff0e9 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,26 @@ 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) { + pm8001_dbg(pm8001_ha, FAIL, "cannot allocate tag !!!\n"); 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 +1816,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 +1831,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 +1846,14 @@ 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) { + pm8001_dbg(pm8001_ha, FAIL, "cannot allocate tag !!!\n"); + 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 +1868,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 +1878,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); } } @@ -4844,7 +4832,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; @@ -4855,13 +4843,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 */ @@ -4898,7 +4884,7 @@ static int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); if (rc) - pm8001_tag_free(pm8001_ha, tag); + pm8001_ccb_free(pm8001_ha, ccb); return rc; } From patchwork Fri Feb 11 07:37: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: 542033 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 B67F0C433EF for ; Fri, 11 Feb 2022 07:38:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347716AbiBKHiD (ORCPT ); Fri, 11 Feb 2022 02:38:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231602AbiBKHh6 (ORCPT ); Fri, 11 Feb 2022 02:37:58 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19EF98D for ; Thu, 10 Feb 2022 23:37:40 -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=1644565058; x=1676101058; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=BEMiWvPkP9DMasF+4/zwsuWWg9MEPVY7ZKjIv70wrjI=; b=q+uBzjqFMkXmYtZzlj3grgB1vO5ZOONek0jpgMw96WDQtkMXq3h9D82v V3nMk7ODa0BkaFrMHYIzGf4gh2PzoZwHz+fHxhK9HnuHKBOax8Gj9ZZpU cqR4a9d+lErtZT6l1K/ErImDwPqQdtZBeJASlBctrQqAc6FSaKsu5zzKk uxpTx2EXaQEEnGWZ4pl2KOapfgBZTefw+tdi6IVLSgEkPvh7BieAoc0Ia L2hojI/UK8Kx3FCn+vbbA88pJGjpXY5P65NCoSuwVtQToeNrP/Psj4X0g dQIEm+wtapm7QWSe3q7YzjZT0n8wPTwikxrN8U1gdJ3T8YEFA4et7dIIT g==; X-IronPort-AV: E=Sophos;i="5.88,359,1635177600"; d="scan'208";a="192675163" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2022 15:37:38 +0800 IronPort-SDR: tgE9YfiREXIm91LES61czE3puyOEXISO9g/Sdw/0X2p8yBvlvq2OVr3M6nbHmg+koBRelFcwpa bcWW/U5M0EgpQNAYrJZ103PvZhMRjjtKmX1ZcAvIj2rlBQAmbkS+bu8xYwaY0lvHRPZGi/UByA 1NBdggT7RqJtHi+JVUjxXJWSR/Im7RtyTjePY6ocxuvd3x6jlBEBFoqbhKreDeEqZaKOCQXXC4 6ENHEC3ySuOg0i2jd0I5uqSpjQTQJrSaQVu5WKBRS+2+WxWmthWKHNq8ldvK7SmWs1by3PCoK8 g4bhACD1CHuxOzcum3TYo6Zw Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:09:26 -0800 IronPort-SDR: qtUEBVAJKROQNoc2YDmZKQdY5Oh8gdxFGblZin4PtdjVeyn1oKT0WP+lOPvoJhgb9QY22Ilc9+ kBWU/7p0covBlFO5x1J1mXPHA5r5YfEI8I0KUHrG987lwlF7f4uwWhOUl0Or7y+yFJYvwwiUHO Wek+EcKEKrVmlNfRctWOIelwafulSu6TRfOqaIxUAAcp7eBmVdg0kcvOtgeya7sl5sFXdwvoHr yLuO/za0zK7sUhUeB6cxa+5TIR566G6aoiytaxvFOe6M0NSFZxeOZPVOSQ829Nl1LczGWjwXuq zJY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 23:37:40 -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 4Jw5771fJqz1SVny for ; Thu, 10 Feb 2022 23:37: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=1644565057; x=1647157058; bh=BEMiWvPkP9DMasF+4/ zwsuWWg9MEPVY7ZKjIv70wrjI=; b=LJ/vwCMXSeR7dCa5RNgrjDqTcTCgVFN4Mx 6gZmNZin16mlOcueDDiCjYH+GHd8vu7YS66ugQG48TZB8uUBDNaCAGw7X2RrFz69 JDdgrFMY06QCKa0qFJtnAXA4oKRHoUvyH+7H+oHTn7g8SkzcP4tVKn43QA0CDRFu 0/ywFo05dLekU7qa4gtTF7ZVOWPo3ygSra17T/sVoDbgzdwIECbrQ4Gf7uNI2Ik0 UK2Q4gb1ZKmRpleybOo4cAyFA4kqOWZJzBhMIzVhzjg4S2CBR2wlI8I7br0doj99 wyEMsYVBLMIIoRIxzZ6++PR67Lx84Ud+UX8CntD7vc9j9DAb1vVQ== 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 Hijbmi1zW91j for ; Thu, 10 Feb 2022 23:37: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 4Jw5736cCyz1Rwrw; Thu, 10 Feb 2022 23:37:35 -0800 (PST) From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , John Garry , Xiang Chen , Jason Yan , Luo Jiaxing Subject: [PATCH v2 24/24] scsi: pm8001: simplify pm8001_mpi_build_cmd() interface Date: Fri, 11 Feb 2022 16:37:04 +0900 Message-Id: <20220211073704.963993-25-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> References: <20220211073704.963993-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There is no need to pass a pointer to a struct inbound_queue_table to pm8001_mpi_build_cmd(). Passing the start index in the inbound queue table of the adapter is enough. This change allows avoiding the declaration of a struct inbound_queue_table pointer (circularQ variables) in many functions, simplifying the code. While at it, blank lines are added i(e.g. after local variable declarations) to make the code more readable. Signed-off-by: Damien Le Moal --- drivers/scsi/pm8001/pm8001_hwi.c | 153 +++++++++++-------------------- drivers/scsi/pm8001/pm8001_sas.h | 3 +- drivers/scsi/pm8001/pm80xx_hwi.c | 99 +++++++------------- 3 files changed, 88 insertions(+), 167 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 8c4cf4e254ba..fcd253fffd4a 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); @@ -1760,7 +1759,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; @@ -1785,15 +1783,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); @@ -1809,11 +1805,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; @@ -1845,9 +1839,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; @@ -1856,13 +1847,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); @@ -3286,17 +3278,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, @@ -4137,7 +4126,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)); /* @@ -4163,7 +4151,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)); @@ -4174,8 +4161,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; @@ -4203,9 +4190,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); @@ -4221,7 +4206,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) { @@ -4242,9 +4226,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, @@ -4254,17 +4238,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*/ @@ -4351,9 +4333,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); } /** @@ -4365,11 +4346,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); /* @@ -4386,9 +4365,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); } /** @@ -4400,17 +4379,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); } /* @@ -4422,9 +4399,7 @@ 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; u8 retryFlag = 0x1; u16 firstBurstSize = 0; @@ -4432,7 +4407,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); @@ -4466,9 +4440,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); - return rc; + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, + sizeof(payload), 0); } /* @@ -4479,18 +4453,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); } /** @@ -4503,17 +4474,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) @@ -4551,9 +4520,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; @@ -4565,9 +4532,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); } /* @@ -4607,9 +4574,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); @@ -4619,10 +4584,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, @@ -4632,7 +4596,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; @@ -4643,7 +4606,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); @@ -4710,8 +4672,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); @@ -4726,7 +4689,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; @@ -4735,7 +4697,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); @@ -4794,7 +4756,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); @@ -4815,12 +4778,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); @@ -4831,9 +4791,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 @@ -4961,7 +4921,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; u32 opc = OPC_INB_SET_DEVICE_STATE; @@ -4971,12 +4930,11 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, if (!ccb) return -1; - 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); - return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); } @@ -4984,7 +4942,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; @@ -4995,14 +4952,12 @@ pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha) if (!ccb) return -ENOMEM; - 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, + 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 6aafa48bf235..234114de95d9 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -668,8 +668,7 @@ int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr, void pm8001_chip_iounmap(struct pm8001_hba_info *pm8001_ha); int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha, - struct inbound_queue_table *circularQ, - u32 opCode, void *payload, size_t nb, + u32 q_index, u32 opCode, void *payload, size_t nb, u32 responseQueue); int pm8001_mpi_msg_free_get(struct inbound_queue_table *circularQ, u16 messageSize, void **messagePtr); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index eddaf2dff0e9..d7bf4f5a54a2 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 -1; - 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 -1; - 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 -1; - 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; @@ -1795,15 +1787,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); @@ -1820,11 +1810,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; @@ -1858,7 +1846,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)); @@ -1873,8 +1860,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); @@ -3220,17 +3207,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, @@ -4209,7 +4194,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; @@ -4238,7 +4222,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; @@ -4306,8 +4289,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; @@ -4367,10 +4350,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; @@ -4394,7 +4375,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 && @@ -4511,9 +4491,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, @@ -4524,7 +4504,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; @@ -4532,13 +4511,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*/ @@ -4754,9 +4731,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); } /** @@ -4768,11 +4744,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); @@ -4794,9 +4768,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); } /** @@ -4808,17 +4782,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); } /* @@ -4830,7 +4802,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; @@ -4840,7 +4811,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); @@ -4881,7 +4851,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); @@ -4901,17 +4871,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)); - return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + + return pm8001_mpi_build_cmd(pm8001_ha, 0, opc, &payload, sizeof(payload), 0); } @@ -4953,7 +4924,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)); @@ -4963,7 +4933,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)); @@ -4974,8 +4943,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); } @@ -4999,7 +4968,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)); @@ -5009,7 +4977,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); @@ -5020,7 +4987,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);