From patchwork Sat Aug 3 13:59:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E166413AC for ; Sat, 3 Aug 2019 14:00:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D15B528895 for ; Sat, 3 Aug 2019 14:00:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C50E6288D2; Sat, 3 Aug 2019 14:00:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63BFE28895 for ; Sat, 3 Aug 2019 14:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391008AbfHCOAN (ORCPT ); Sat, 3 Aug 2019 10:00:13 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37405 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387781AbfHCOAM (ORCPT ); Sat, 3 Aug 2019 10:00:12 -0400 Received: by mail-pg1-f195.google.com with SMTP id d1so4655064pgp.4 for ; Sat, 03 Aug 2019 07:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=efLwhG0YC+uhlzEO2fzT58whGcj2lqMnTbkUHu4S1wg=; b=heCCxK6SWEg/1+rjQQuiqVNp+VxOWtvWU6FC2o+md2+OcS9/O1DH/LUm3VUGUClk1W 6DxeQRzVUEZAwSfPorGSHwTWh9BWVdG0EXzIOma7+eIX51xSGooGPeX20SnhJm6ByUuv DS8KUjdmiQfjnJR/M+nSpQXgYyR+gSKBj5/Lg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=efLwhG0YC+uhlzEO2fzT58whGcj2lqMnTbkUHu4S1wg=; b=kVWdWZ0raqch3al33GcuiJgOyqSh8PP3wBS57dHBD2WztpDAOwfn/ywYjgH8lXIuzd iPjQBrrnxS+F/QIwbwh5J3rUIXr69EBHm7wM5gQeA7FkWgs4uaKdkexb0954MG/R9scz y+FJQtvFsz3wnI6TIonbYp82rZ8a8CL/sS/WpV34VDtCBmmv3gocOvLsdGAZwxmYD4Ni 4NgOhjBmQBF6EojbBoEb3KjrhrGUIVL/n4KTjuNOsPxGWsMuyyFaNKDSA87+vilbp5j/ TsLy0X36L9MMrf/YX2ZucyViSUZOPJ1E98zLo5GT41o8+pPglooEEmE7dfoeOgmTdNDm 6wAw== X-Gm-Message-State: APjAAAU2a26EP4+saggxRdiN6j9UV1Cd505mvmn0qCDDoQO/AkkGAbic DBAQQ6WrTG6MEd3eI0KGI5aRs4tjFh7rg0c1MdFPRelfoFkl4Q1vLEST5qOlMuO8er9ttKkejCZ wa4zXQ5GLBosW1cGW+qEElwGfVeumv6x6RlID+5E9nqYeolH0daSppfwSg+3QpkrtcCUD+mkQDD 9ojqbiK63YwYpZzgZGXA== X-Google-Smtp-Source: APXvYqxcGDrOJ8JqUl1wpTUx8RL3B26mrYeOrNYN9iHnPMMwRRiIeMqK9pOtp375RQ61d8q1hy6NxA== X-Received: by 2002:a63:c50f:: with SMTP id f15mr29073101pgd.372.1564840811838; Sat, 03 Aug 2019 07:00:11 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:11 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 01/12] mpt3sas: Add support for PCIe Lane margin Date: Sat, 3 Aug 2019 09:59:46 -0400 Message-Id: <1564840797-5876-2-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP PCIe Lane margin tool box request requires IEEE sgl's and hence driver fills the SGL field with IEEE sgl's while issuing the PCIe Lane margin ioctl request to the HBA firmware. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index d4ecfbb..acd803a 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -921,13 +921,14 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, Mpi2ToolboxCleanRequest_t *toolbox_request = (Mpi2ToolboxCleanRequest_t *)mpi_request; - if (toolbox_request->Tool == MPI2_TOOLBOX_DIAGNOSTIC_CLI_TOOL) { + if ((toolbox_request->Tool == MPI2_TOOLBOX_DIAGNOSTIC_CLI_TOOL) + || (toolbox_request->Tool == + MPI26_TOOLBOX_BACKEND_PCIE_LANE_MARGIN)) ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma, data_in_sz); - } else { + else ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz, data_in_dma, data_in_sz); - } ioc->put_smid_default(ioc, smid); break; } From patchwork Sat Aug 3 13:59:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A534D13AC for ; Sat, 3 Aug 2019 14:00:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 956C828895 for ; Sat, 3 Aug 2019 14:00:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89D61288D2; Sat, 3 Aug 2019 14:00:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E3F428895 for ; Sat, 3 Aug 2019 14:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391012AbfHCOAP (ORCPT ); Sat, 3 Aug 2019 10:00:15 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:43828 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387781AbfHCOAP (ORCPT ); Sat, 3 Aug 2019 10:00:15 -0400 Received: by mail-pl1-f194.google.com with SMTP id 4so27724410pld.10 for ; Sat, 03 Aug 2019 07:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6wN1C0AvC9x7tBljRtSGnfqzECeBaW2pIXhX7Ubn5/E=; b=iPegaWhgohApRqdbz7dn4PxzQ2bOGwiHF5Xo51nvma2UcxrloGU06Kw9vAbyQOeP6z onykP09idxdOEyKHWlIuuizz8Syb/C8n+BQeDoKwKuk6EtBRDib7MRkUIFtFWhwNJbk7 H72FCPxcRhQ91Q6UhFcVtOHr1OVBCJz/DoFg4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6wN1C0AvC9x7tBljRtSGnfqzECeBaW2pIXhX7Ubn5/E=; b=DwRbRLZZPmEN0/xKQ8KEY3B2SG3Lj+sgR3CVzEOqWZ+Q6m2qXyvReWB8Y1A5ELWlnh EX2lRQ+bXbPnFmO41QvglfWPhTJIQWymPUyAq7okFjAHrKZHAOW5RrkzYEaMtxsGiGHD Emk6b/k/r5q7igS87r9y3tfbgPcFq9YcqDeoXh9royuMuIO+s0vwEZ3lmhiovajy8V+E 3sEKCAhGYbQO3JZTNNUT8vdM5emQdGPCk6Mu5O8PGU/Me6JH8clXHIFG0E637QDMRYPJ +aAgn6YleqGjXeN91yx7ju8iwSMo1i/nUoI9kid9Zwx1hJlsR7O2vti5JCVOhJX7FhCM 2FJw== X-Gm-Message-State: APjAAAWSxg0+YZCNGM3VdLOQgJLipFhjmRBihwHlaYRR7cn8+UYAgXRx LfGzh8n9YoYAQ3xaNALNVI4P1BAGire3rQhpVEemhWpBrKUUTKRgBnfNahaODE/WHkIdQNFhpMf gaMDYYrnKVeMBDKpmrJozJBxYUs0fVAcCsIbkuZKdNR3lzobt1QZ2HuNqsAxCVdxqm1+15hAYuX RpHPHR/1UHRjUZzog8Eg== X-Google-Smtp-Source: APXvYqw2W8JDGETD3SbUXCoxmGIwXIArO1EcsrrMI25X8JMo5J77UNztYrJohCBqe5eM4KiWb34qTg== X-Received: by 2002:a17:902:a714:: with SMTP id w20mr136523376plq.127.1564840814368; Sat, 03 Aug 2019 07:00:14 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:13 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 02/12] mpt3sas: memset request frame before reusing Date: Sat, 3 Aug 2019 09:59:47 -0400 Message-Id: <1564840797-5876-3-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Driver gets a request frame from the free pool of DMA able request frames and fill in the required information and pass the address of the frame to IOC/FW to pull the complete request frame. In certain places the driver used the request frame allocated from the free pool without completely clearing the previous data stored in it. The request contents were cleared only for the size of the new request to be issued and that left out some stale data in the unused part of the request. Though the IOC/FW is not expected to access the request beyond the specified size it is good practice to clear complete request message frame. So reinitialize the complete request message frame with 0's before using it. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 ++ drivers/scsi/mpt3sas/mpt3sas_ctl.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 050c0f0..ba83f59 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -5037,6 +5037,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc) _base_release_memory_pools(ioc); goto retry_allocation; } + memset(ioc->request, 0, sz); if (retry_sz) ioc_err(ioc, "request pool: dma_alloc_coherent succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), total(%d kb)\n", @@ -5868,6 +5869,7 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, ioc->base_cmds.status = MPT3_CMD_PENDING; request = mpt3sas_base_get_msg_frame(ioc, smid); ioc->base_cmds.smid = smid; + memset(request, 0, ioc->request_sz); memcpy(request, mpi_request, sizeof(Mpi2SepReply_t)); init_completion(&ioc->base_cmds.done); ioc->put_smid_default(ioc, smid); diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index acd803a..ea87871 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -707,6 +707,7 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, ioc->ctl_cmds.status = MPT3_CMD_PENDING; memset(ioc->ctl_cmds.reply, 0, ioc->reply_sz); request = mpt3sas_base_get_msg_frame(ioc, smid); + memset(request, 0, ioc->request_sz); memcpy(request, mpi_request, karg.data_sge_offset*4); ioc->ctl_cmds.smid = smid; data_out_sz = karg.data_out_size; From patchwork Sat Aug 3 13:59:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22F15912 for ; Sat, 3 Aug 2019 14:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 140A928895 for ; Sat, 3 Aug 2019 14:00:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0881A288D2; Sat, 3 Aug 2019 14:00:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 760A428895 for ; Sat, 3 Aug 2019 14:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391024AbfHCOAS (ORCPT ); Sat, 3 Aug 2019 10:00:18 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:36286 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387781AbfHCOAS (ORCPT ); Sat, 3 Aug 2019 10:00:18 -0400 Received: by mail-pg1-f195.google.com with SMTP id l21so37466310pgm.3 for ; Sat, 03 Aug 2019 07:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y151potURalM4a9rPPaFD6S1UTRiyK+Hq+doF1sRmSw=; b=N6/XU2OiBRLFZHtNTVhxIjZunFmCPbG654dCbU7u+bNJlA0SjN0+xH1cxtJk1XkOHX RoDvh9VansiBo/l0GndtdSp1fxVtk26RxraiRO8M5scDQ7RWrkzKg8Sp7GOZ7Hl39/Ny onbLBUs3vEfcBt562Q289Y5/eFMWoOAU+VFg8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Y151potURalM4a9rPPaFD6S1UTRiyK+Hq+doF1sRmSw=; b=CM+0d/tOawRPvRunYnWdQQOHary/hYpefmb6T/dPuEwl5+b7xTk58s+sLspRwv86q1 Gk+Xj6lPRIh4uuQx684E7xYGyPUqB5C7xhZIv0vBCpGvWShVT7bv3Hv2ApDBLyqzMpJ9 zzWGxjHfvH4o1UGvrRhIbAeMANVNKN2WeqYz5YFZsMulhgLjAwop/TALqoiU8CpEHHBN lBxC/NiKu45IKqJWsVxL7rH1GQfoh62q7mNW/77U038vQWiZqf0r/LVtUl/W7sZU8nRj 9NOjMQZjSgX3bnmdrPvlvbJIoJw3FVlTEec0QVvXTG6i+GZgOeGKyxFlQoq6w33TPg4o kQDw== X-Gm-Message-State: APjAAAU6yxRVvoJnzM76G6DZ0A7Wh6qGQMNUY3EGSMyGGw2ZCtB7jCwp B6HExzVYcFR/RsrpiyJgG+/DDzqr/5NYUswXBPsXQvscsCR7BjsRmb+Zi+NwgvDxVS61HLYN7YR s77bSlJP1DZuqNKawK7QDDvGALjE92XkaZl7dKmh+jbOBm/3ReUiTTpxgDV7Hi5o9zxxLJ3ItNP nxp/6fnmnqs7QN8HPPEg== X-Google-Smtp-Source: APXvYqzsPOPnEKpAJVHLpAs0EA1D48WwNm2mCSID3y1eSrlCZfIi9BcO8B34DOzU6BmwQZdjYLkb5Q== X-Received: by 2002:a63:cb4b:: with SMTP id m11mr55412663pgi.49.1564840816647; Sat, 03 Aug 2019 07:00:16 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:16 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 03/12] mpt3sas: Gracefully handle online firmware update Date: Sat, 3 Aug 2019 09:59:48 -0400 Message-Id: <1564840797-5876-4-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Issue: During online Firmware upgrade operations, It is possible that, MaxDevHandles filed in IOCFacts may change with new FW. With this we may observe kernel panics when driver try to access the pd_handles or blocking_handles buffers at offset greater than the old firmware's MaxDevHandle value. Fix: _base_check_ioc_facts_changes() looks for increase/decrease in IOCFacts attributes during online firmware upgrade and increases the pd_handles, blocking_handles, etc buffer sizes to new firmware's MaxDevHandle value if this new firmware's MaxDevHandle value is greater than the old firmware's MaxDevHandle value. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_base.c | 93 +++++++++++++++++++++++++++++++++++++ drivers/scsi/mpt3sas/mpt3sas_base.h | 2 + 2 files changed, 95 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index ba83f59..a2a70a5 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -7120,6 +7120,13 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) if (r) goto out_free_resources; + /* + * Copy current copy of IOCFacts in prev_fw_facts + * and it will be used during online firmware upgrade. + */ + memcpy(&ioc->prev_fw_facts, &ioc->facts, + sizeof(struct mpt3sas_facts)); + ioc->non_operational_loop = 0; ioc->got_task_abort_from_ioctl = 0; return 0; @@ -7282,6 +7289,85 @@ mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc) } /** + * _base_check_ioc_facts_changes - Look for increase/decrease of IOCFacts + * attributes during online firmware upgrade and update the corresponding + * IOC variables accordingly. + * + * @ioc: Pointer to MPT_ADAPTER structure + */ +static int +_base_check_ioc_facts_changes(struct MPT3SAS_ADAPTER *ioc) +{ + u16 pd_handles_sz; + void *pd_handles = NULL, *blocking_handles = NULL; + void *pend_os_device_add = NULL, *device_remove_in_progress = NULL; + struct mpt3sas_facts *old_facts = &ioc->prev_fw_facts; + + if (ioc->facts.MaxDevHandle > old_facts->MaxDevHandle) { + pd_handles_sz = (ioc->facts.MaxDevHandle / 8); + if (ioc->facts.MaxDevHandle % 8) + pd_handles_sz++; + + pd_handles = krealloc(ioc->pd_handles, pd_handles_sz, + GFP_KERNEL); + if (!pd_handles) { + ioc_info(ioc, + "Unable to allocate the memory for pd_handles of sz: %d\n", + pd_handles_sz); + return -ENOMEM; + } + memset(pd_handles + ioc->pd_handles_sz, 0, + (pd_handles_sz - ioc->pd_handles_sz)); + ioc->pd_handles = pd_handles; + + blocking_handles = krealloc(ioc->blocking_handles, + pd_handles_sz, GFP_KERNEL); + if (!blocking_handles) { + ioc_info(ioc, + "Unable to allocate the memory for " + "blocking_handles of sz: %d\n", + pd_handles_sz); + return -ENOMEM; + } + memset(blocking_handles + ioc->pd_handles_sz, 0, + (pd_handles_sz - ioc->pd_handles_sz)); + ioc->blocking_handles = blocking_handles; + ioc->pd_handles_sz = pd_handles_sz; + + pend_os_device_add = krealloc(ioc->pend_os_device_add, + pd_handles_sz, GFP_KERNEL); + if (!pend_os_device_add) { + ioc_info(ioc, + "Unable to allocate the memory for pend_os_device_add of sz: %d\n", + pd_handles_sz); + return -ENOMEM; + } + memset(pend_os_device_add + ioc->pend_os_device_add_sz, 0, + (pd_handles_sz - ioc->pend_os_device_add_sz)); + ioc->pend_os_device_add = pend_os_device_add; + ioc->pend_os_device_add_sz = pd_handles_sz; + + device_remove_in_progress = krealloc( + ioc->device_remove_in_progress, pd_handles_sz, GFP_KERNEL); + if (!device_remove_in_progress) { + ioc_info(ioc, + "Unable to allocate the memory for " + "device_remove_in_progress of sz: %d\n " + , pd_handles_sz); + return -ENOMEM; + } + memset(device_remove_in_progress + + ioc->device_remove_in_progress_sz, 0, + (pd_handles_sz - ioc->device_remove_in_progress_sz)); + ioc->device_remove_in_progress = device_remove_in_progress; + ioc->device_remove_in_progress_sz = pd_handles_sz; + } + + memcpy(&ioc->prev_fw_facts, &ioc->facts, sizeof(struct mpt3sas_facts)); + return 0; +} + +/** * mpt3sas_base_hard_reset_handler - reset controller * @ioc: Pointer to MPT_ADAPTER structure * @type: FORCE_BIG_HAMMER or SOFT_RESET @@ -7344,6 +7430,13 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, if (r) goto out; + r = _base_check_ioc_facts_changes(ioc); + if (r) { + ioc_info(ioc, + "Some of the parameters got changed in this new firmware" + " image and it requires system reboot\n"); + goto out; + } if (ioc->rdpq_array_enable && !ioc->rdpq_array_capable) panic("%s: Issue occurred with flashing controller firmware." "Please reboot the system and ensure that the correct" diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 6afbdb0..5cd6148 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1066,6 +1066,7 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc); * @event_log: event log pointer * @event_masks: events that are masked * @facts: static facts data + * @prev_fw_facts: previous fw facts data * @pfacts: static port facts data * @manu_pg0: static manufacturing page 0 * @manu_pg10: static manufacturing page 10 @@ -1276,6 +1277,7 @@ struct MPT3SAS_ADAPTER { /* static config pages */ struct mpt3sas_facts facts; + struct mpt3sas_facts prev_fw_facts; struct mpt3sas_port_facts *pfacts; Mpi2ManufacturingPage0_t manu_pg0; struct Mpi2ManufacturingPage10_t manu_pg10; From patchwork Sat Aug 3 13:59:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19C2013AC for ; Sat, 3 Aug 2019 14:00:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 069D328895 for ; Sat, 3 Aug 2019 14:00:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF4A8288D2; Sat, 3 Aug 2019 14:00:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24E5528895 for ; Sat, 3 Aug 2019 14:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391038AbfHCOAU (ORCPT ); Sat, 3 Aug 2019 10:00:20 -0400 Received: from mail-pf1-f182.google.com ([209.85.210.182]:43077 "EHLO mail-pf1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387781AbfHCOAU (ORCPT ); Sat, 3 Aug 2019 10:00:20 -0400 Received: by mail-pf1-f182.google.com with SMTP id i189so37430289pfg.10 for ; Sat, 03 Aug 2019 07:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fzp+d3FnBlvBe0Zqb+mhGXKaWVGRNrQqQAg82JCQoTU=; b=PXjfrHj6I3IRvAWH9FVNB1eCo7o7jxNXIs8CkLky/xTvmL0nMVWDdfx8eP+1VZ0qf8 jr6kGFPu2l5wPgx2RT7BYj5n4u9HgYF+qoZbUA7kSJtv16chwGqxY9t0bDifBD9abDko jryKSqtdHarmNDDUWSUxVxRc/hosW7nq/TdBs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fzp+d3FnBlvBe0Zqb+mhGXKaWVGRNrQqQAg82JCQoTU=; b=ccKGyC52a2AofPP1KZTFnQMgppypAfDXG3f34494IxpCL7Iud1Sz623TDVezS4gYck 5M4C247nT8B2n0hgCm3vF0cyedvQwowI6aXPljsnYMBuD703/6txIkerii5Kh5uk7Ifs YpthbqaDlPDJeev+1RTsEn3VXQ8RxpuagcBA2viMjjNhcOv5i6THS3szPV7nSPkkCBCm f/yNDoXonhTfmoBoUhs+x7WMOkr5mrd1naoQwpAp9lHHiPjJ3IanzbDDxiXItP6MH9e1 v07msKn2zI9ur9PFCVMGPIejNALwas+po8dGOH0Z/1/l7Gf5T0nOXrSBcwJ/Wf1evg/y umtw== X-Gm-Message-State: APjAAAUADtCt3IFBsijHbRXnCrm4RZ6ctosqyxEvLzGKCvtDcpxJHfrM XtHP9d7Fu0veionWQlsWmxGXrLLO1q3pk2eJ/eC0pqgI4TAWqepHXph4r48tecnoi7OZEuvtlUl Erwxo0+YRJk51EknvVqrF8B8VvGRUJnk6EjyxCrcgXDkem5rUZ5gP7IdbZCJCkWUEwRKw2StFfh YbuQg0UiZR6GiSakuuBA== X-Google-Smtp-Source: APXvYqy0DJTVcx3p21HCd024mq2/Ge6waUzq2vtOvtFoKG8TE8UoQjVkgVHt27HXh3m6ASbGCTGSCw== X-Received: by 2002:a63:6947:: with SMTP id e68mr93254050pgc.60.1564840819144; Sat, 03 Aug 2019 07:00:19 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:18 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 04/12] mpt3sas: Update MPI headers to 2.6.8 spec Date: Sat, 3 Aug 2019 09:59:49 -0400 Message-Id: <1564840797-5876-5-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Updated MPI to 2.6.8 specification and header files to 2.00.54. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpi/mpi2.h | 5 +++-- drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 10 +++++++-- drivers/scsi/mpt3sas/mpi/mpi2_image.h | 39 +++++++++++++++++++---------------- drivers/scsi/mpt3sas/mpi/mpi2_pci.h | 13 ++++++------ drivers/scsi/mpt3sas/mpi/mpi2_tool.h | 13 ++++++------ 5 files changed, 46 insertions(+), 34 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpi/mpi2.h b/drivers/scsi/mpt3sas/mpi/mpi2.h index 7efd17a..18b1e31 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2.h @@ -9,7 +9,7 @@ * scatter/gather formats. * Creation Date: June 21, 2006 * - * mpi2.h Version: 02.00.53 + * mpi2.h Version: 02.00.54 * * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 * prefix are for use only on MPI v2.5 products, and must not be used @@ -121,6 +121,7 @@ * 08-15-18 02.00.52 Bumped MPI2_HEADER_VERSION_UNIT. * 08-28-18 02.00.53 Bumped MPI2_HEADER_VERSION_UNIT. * Added MPI2_IOCSTATUS_FAILURE + * 12-17-18 02.00.54 Bumped MPI2_HEADER_VERSION_UNIT * -------------------------------------------------------------------------- */ @@ -161,7 +162,7 @@ /* Unit and Dev versioning for this MPI header set */ -#define MPI2_HEADER_VERSION_UNIT (0x35) +#define MPI2_HEADER_VERSION_UNIT (0x36) #define MPI2_HEADER_VERSION_DEV (0x00) #define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00) #define MPI2_HEADER_VERSION_UNIT_SHIFT (8) diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h index 167d79d..3a6871a 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h @@ -7,7 +7,7 @@ * Title: MPI Configuration messages and pages * Creation Date: November 10, 2006 * - * mpi2_cnfg.h Version: 02.00.46 + * mpi2_cnfg.h Version: 02.00.47 * * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 * prefix are for use only on MPI v2.5 products, and must not be used @@ -244,6 +244,11 @@ * Added DMDReport Delay Time defines to * PCIeIOUnitPage1 * -------------------------------------------------------------------------- + * 08-02-18 02.00.44 Added Slotx2, Slotx4 to ManPage 7. + * 08-15-18 02.00.45 Added ProductSpecific field at end of IOC Page 1 + * 08-28-18 02.00.46 Added NVMs Write Cache flag to IOUnitPage1 + * Added DMDReport Delay Time defines to PCIeIOUnitPage1 + * 12-17-18 02.00.47 Swap locations of Slotx2 and Slotx4 in ManPage 7. */ #ifndef MPI2_CNFG_H @@ -810,7 +815,8 @@ typedef struct _MPI2_MANPAGE7_CONNECTOR_INFO { U8 Location; /*0x14 */ U8 ReceptacleID; /*0x15 */ U16 Slot; /*0x16 */ - U32 Reserved2; /*0x18 */ + U16 Slotx2; /*0x18 */ + U16 Slotx4; /*0x1A */ } MPI2_MANPAGE7_CONNECTOR_INFO, *PTR_MPI2_MANPAGE7_CONNECTOR_INFO, Mpi2ManPage7ConnectorInfo_t, diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_image.h b/drivers/scsi/mpt3sas/mpi/mpi2_image.h index 4959585..a3f6778 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_image.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_image.h @@ -5,7 +5,7 @@ * Name: mpi2_image.h * Description: Contains definitions for firmware and other component images * Creation Date: 04/02/2018 - * Version: 02.06.03 + * Version: 02.06.04 * * * Version History @@ -17,6 +17,8 @@ * 08-14-18 02.06.01 Corrected define for MPI26_IMAGE_HEADER_SIGNATURE0_MPI26 * 08-28-18 02.06.02 Added MPI2_EXT_IMAGE_TYPE_RDE * 09-07-18 02.06.03 Added MPI26_EVENT_PCIE_TOPO_PI_16_LANES + * 12-17-18 02.06.04 Addd MPI2_EXT_IMAGE_TYPE_PBLP + * Shorten some defines to be compatible with DOS */ #ifndef MPI2_IMAGE_H #define MPI2_IMAGE_H @@ -200,17 +202,17 @@ typedef struct _MPI26_COMPONENT_IMAGE_HEADER { #define MPI26_IMAGE_HEADER_SIGNATURE0_MPI26 (0xEB000042) /**** Definitions for Signature1 field ****/ -#define MPI26_IMAGE_HEADER_SIGNATURE1_APPLICATION (0x20505041) -#define MPI26_IMAGE_HEADER_SIGNATURE1_CBB (0x20424243) -#define MPI26_IMAGE_HEADER_SIGNATURE1_MFG (0x2047464D) -#define MPI26_IMAGE_HEADER_SIGNATURE1_BIOS (0x534F4942) -#define MPI26_IMAGE_HEADER_SIGNATURE1_HIIM (0x4D494948) -#define MPI26_IMAGE_HEADER_SIGNATURE1_HIIA (0x41494948) -#define MPI26_IMAGE_HEADER_SIGNATURE1_CPLD (0x444C5043) -#define MPI26_IMAGE_HEADER_SIGNATURE1_SPD (0x20445053) -#define MPI26_IMAGE_HEADER_SIGNATURE1_NVDATA (0x5444564E) -#define MPI26_IMAGE_HEADER_SIGNATURE1_GAS_GAUGE (0x20534147) -#define MPI26_IMAGE_HEADER_SIGNATURE1_PBLP (0x50424C50) +#define MPI26_IMAGE_HEADER_SIG1_APPLICATION (0x20505041) +#define MPI26_IMAGE_HEADER_SIG1_CBB (0x20424243) +#define MPI26_IMAGE_HEADER_SIG1_MFG (0x2047464D) +#define MPI26_IMAGE_HEADER_SIG1_BIOS (0x534F4942) +#define MPI26_IMAGE_HEADER_SIG1_HIIM (0x4D494948) +#define MPI26_IMAGE_HEADER_SIG1_HIIA (0x41494948) +#define MPI26_IMAGE_HEADER_SIG1_CPLD (0x444C5043) +#define MPI26_IMAGE_HEADER_SIG1_SPD (0x20445053) +#define MPI26_IMAGE_HEADER_SIG1_NVDATA (0x5444564E) +#define MPI26_IMAGE_HEADER_SIG1_GAS_GAUGE (0x20534147) +#define MPI26_IMAGE_HEADER_SIG1_PBLP (0x504C4250) /**** Definitions for Signature2 field ****/ #define MPI26_IMAGE_HEADER_SIGNATURE2_VALUE (0x50584546) @@ -278,6 +280,7 @@ typedef struct _MPI2_EXT_IMAGE_HEADER { #define MPI2_EXT_IMAGE_TYPE_MEGARAID (0x08) #define MPI2_EXT_IMAGE_TYPE_ENCRYPTED_HASH (0x09) #define MPI2_EXT_IMAGE_TYPE_RDE (0x0A) +#define MPI2_EXT_IMAGE_TYPE_PBLP (0x0B) #define MPI2_EXT_IMAGE_TYPE_MIN_PRODUCT_SPECIFIC (0x80) #define MPI2_EXT_IMAGE_TYPE_MAX_PRODUCT_SPECIFIC (0xFF) @@ -472,12 +475,12 @@ Mpi25EncryptedHashEntry_t, *pMpi25EncryptedHashEntry_t; #define MPI25_HASH_ALGORITHM_UNUSED (0x00) #define MPI25_HASH_ALGORITHM_SHA256 (0x01) -#define MPI26_HASH_ALGORITHM_VERSION_MASK (0xE0) -#define MPI26_HASH_ALGORITHM_VERSION_NONE (0x00) -#define MPI26_HASH_ALGORITHM_VERSION_SHA1 (0x20) -#define MPI26_HASH_ALGORITHM_VERSION_SHA2 (0x40) -#define MPI26_HASH_ALGORITHM_VERSION_SHA3 (0x60) -#define MPI26_HASH_ALGORITHM_SIZE_MASK (0x1F) +#define MPI26_HASH_ALGORITHM_VER_MASK (0xE0) +#define MPI26_HASH_ALGORITHM_VER_NONE (0x00) +#define MPI26_HASH_ALGORITHM_VER_SHA1 (0x20) +#define MPI26_HASH_ALGORITHM_VER_SHA2 (0x40) +#define MPI26_HASH_ALGORITHM_VER_SHA3 (0x60) +#define MPI26_HASH_ALGORITHM_SIZE_MASK (0x1F) #define MPI26_HASH_ALGORITHM_SIZE_256 (0x01) #define MPI26_HASH_ALGORITHM_SIZE_512 (0x02) diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_pci.h b/drivers/scsi/mpt3sas/mpi/mpi2_pci.h index 63a0950..bb7b79c 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_pci.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_pci.h @@ -6,7 +6,7 @@ * Title: MPI PCIe Attached Devices structures and definitions. * Creation Date: October 9, 2012 * - * mpi2_pci.h Version: 02.00.03 + * mpi2_pci.h Version: 02.00.04 * * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 * prefix are for use only on MPI v2.5 products, and must not be used @@ -24,6 +24,8 @@ * 07-01-16 02.00.02 Added MPI26_NVME_FLAGS_FORCE_ADMIN_ERR_RESP to * NVME Encapsulated Request. * 07-22-18 02.00.03 Updted flags field for NVME Encapsulated req + * 12-17-18 02.00.04 Added MPI26_PCIE_DEVINFO_SCSI + * Shortten some defines to be compatible with DOS * -------------------------------------------------------------------------- */ @@ -41,7 +43,7 @@ #define MPI26_PCIE_DEVINFO_NO_DEVICE (0x00000000) #define MPI26_PCIE_DEVINFO_PCI_SWITCH (0x00000001) #define MPI26_PCIE_DEVINFO_NVME (0x00000003) - +#define MPI26_PCIE_DEVINFO_SCSI (0x00000004) /**************************************************************************** * NVMe Encapsulated message @@ -75,10 +77,9 @@ typedef struct _MPI26_NVME_ENCAPSULATED_REQUEST { #define MPI26_NVME_FLAGS_SUBMISSIONQ_IO (0x0000) #define MPI26_NVME_FLAGS_SUBMISSIONQ_ADMIN (0x0010) /*Error Response Address Space */ -#define MPI26_NVME_FLAGS_MASK_ERROR_RSP_ADDR (0x000C) -#define MPI26_NVME_FLAGS_MASK_ERROR_RSP_ADDR_MASK (0x000C) -#define MPI26_NVME_FLAGS_SYSTEM_RSP_ADDR (0x0000) -#define MPI26_NVME_FLAGS_IOCCTL_RSP_ADDR (0x0008) +#define MPI26_NVME_FLAGS_ERR_RSP_ADDR_MASK (0x000C) +#define MPI26_NVME_FLAGS_ERR_RSP_ADDR_SYSTEM (0x0000) +#define MPI26_NVME_FLAGS_ERR_RSP_ADDR_IOCTL (0x0008) /* Data Direction*/ #define MPI26_NVME_FLAGS_DATADIRECTION_MASK (0x0003) #define MPI26_NVME_FLAGS_NODATATRANSFER (0x0000) diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_tool.h b/drivers/scsi/mpt3sas/mpi/mpi2_tool.h index 3f966b6..17ef7f6 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_tool.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_tool.h @@ -7,7 +7,7 @@ * Title: MPI diagnostic tool structures and definitions * Creation Date: March 26, 2007 * - * mpi2_tool.h Version: 02.00.15 + * mpi2_tool.h Version: 02.00.16 * * Version History * --------------- @@ -40,6 +40,7 @@ * Tool Request Message. * 07-22-18 02.00.15 Added defines for new TOOLBOX_PCIE_LANE_MARGINING tool. * Added option for DeviceInfo field in ISTWI tool. + * 12-17-18 02.00.16 Shorten some defines to be compatible with DOS. * -------------------------------------------------------------------------- */ @@ -230,11 +231,11 @@ typedef struct _MPI2_TOOLBOX_ISTWI_READ_WRITE_REQUEST { #define MPI2_TOOL_ISTWI_FLAG_PAGE_ADDR_MASK (0x07) /*MPI26 TOOLBOX Request MsgFlags defines */ -#define MPI26_TOOLBOX_REQ_MSGFLAGS_ADDRESSING_MASK (0x01) +#define MPI26_TOOL_ISTWI_MSGFLG_ADDR_MASK (0x01) /*Request uses Man Page 43 device index addressing */ -#define MPI26_TOOLBOX_REQ_MSGFLAGS_ADDRESSING_DEVINDEX (0x00) +#define MPI26_TOOL_ISTWI_MSGFLG_ADDR_INDEX (0x00) /*Request uses Man Page 43 device info struct addressing */ -#define MPI26_TOOLBOX_REQ_MSGFLAGS_ADDRESSING_DEVINFO (0x01) +#define MPI26_TOOL_ISTWI_MSGFLG_ADDR_INFO (0x01) /*Toolbox ISTWI Read Write Tool reply message */ typedef struct _MPI2_TOOLBOX_ISTWI_REPLY { @@ -403,7 +404,7 @@ Mpi2ToolboxTextDisplayRequest_t, */ /*Toolbox Backend Lane Margining Tool request message */ -typedef struct _MPI26_TOOLBOX_LANE_MARGINING_REQUEST { +typedef struct _MPI26_TOOLBOX_LANE_MARGIN_REQUEST { U8 Tool; /*0x00 */ U8 Reserved1; /*0x01 */ U8 ChainOffset; /*0x02 */ @@ -434,7 +435,7 @@ typedef struct _MPI26_TOOLBOX_LANE_MARGINING_REQUEST { /*Toolbox Backend Lane Margining Tool reply message */ -typedef struct _MPI26_TOOLBOX_LANE_MARGINING_REPLY { +typedef struct _MPI26_TOOLBOX_LANE_MARGIN_REPLY { U8 Tool; /*0x00 */ U8 Reserved1; /*0x01 */ U8 MsgLength; /*0x02 */ From patchwork Sat Aug 3 13:59:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2311213AC for ; Sat, 3 Aug 2019 14:00:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 134EC28895 for ; Sat, 3 Aug 2019 14:00:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 075B8288D2; Sat, 3 Aug 2019 14:00:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AEBA28895 for ; Sat, 3 Aug 2019 14:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387781AbfHCOAX (ORCPT ); Sat, 3 Aug 2019 10:00:23 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43377 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbfHCOAW (ORCPT ); Sat, 3 Aug 2019 10:00:22 -0400 Received: by mail-pg1-f194.google.com with SMTP id r26so1514367pgl.10 for ; Sat, 03 Aug 2019 07:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Tmqwx9/SkOq74hygAn4QdOSztCIfacQ5T68S4Gl8EP8=; b=LHZuG+UiPTuCXQsQ2JbEel9xYDEfhqLi4iB9hw3BPbqxiD8K1pItsADap616pWn50c MlNHkSg/mOB23HHLclrHKQraOGA4USntYSe0Ym+ATRDCwRlgg4TbgSgDNjG/InuGk/0V k+hCqomdcqcxkNu4WXt1jpy9Oa/0bSEA3vLt4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tmqwx9/SkOq74hygAn4QdOSztCIfacQ5T68S4Gl8EP8=; b=EI6uKz6ZDKusqHdMsAPqJpN1Ge0XQK25PSa8A/pfywpjy5XOkTZ6825tXMt+lifrQ+ Bsuk6O1tIyKmZgV70JH1usQ9RY0KCxrxo/eFTJzAZAmU3Wh5UAoMINrWrvZEw5dqpSVg GR19z33CNWVa8L7Xg4JvRNMNTgYLQGNXGa5rIgoGN0yZxfPVdbO8rEdCUh+aPYTRzVGi 3P4H9+AaRfG08spvGkOOEz1OhfCE47I390G2s+1tb0WmLaq5VW6vyXX1uvwCIXoA09nc gz0Q5+P8eIvDR2KiralffUOHgjEx2HS1l6SosRfLkZD58Cx0kbZxz6Z1ENBOjjwhpkE3 eSAg== X-Gm-Message-State: APjAAAXELdJzFhpOQ9MH/gEqH9BzJwQ5VAkHLEaU2lTvnaMTWXNlGm+j PI2y71VKJEuD5OBlwzAH5h1dpNrtaFxeAntXDElKPsdlqSe3FI9lnoyAhuA+4NrL/fPoiJ4aA8t tgnyyFFiE+NDRvUAdH5X/cyY7GTqwIdmzjWho5qA9ohTfHLVr/8X0f9jpu6hqsiTcmxnb/df1Xd 4VJDo5HG0ubJOFgaAREw== X-Google-Smtp-Source: APXvYqwrdhcBQgGcbmzw3K6KNTLY3H1MTYdA9zm/v7dWKAnmnnwG36WeUFGGQvXwWEIi3uJbY7ISww== X-Received: by 2002:a17:90a:2163:: with SMTP id a90mr8969055pje.3.1564840821726; Sat, 03 Aug 2019 07:00:21 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:21 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 05/12] mpt3sas: Enumerate SES of a managed PCIe switch Date: Sat, 3 Aug 2019 09:59:50 -0400 Message-Id: <1564840797-5876-6-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP SES device of managed PCIe switch will be enumerated same as NVMe drives. The device info type for this SES device is MPI26_PCIE_DEVINFO_SCSI (0x4), whereas the device info type for NVMe drives is MPI26_PCIE_DEVINFO_NVME (0x3). So, based on this device info type driver determines whether the device is NVMe drive or a SES device of a managed PCIe switch. This SES device doesn't have the PCIe device page 2 information like NVMe drives, so driver won't read PCIe device page 2 information for SES device. This SES device uses only IEEE SGL's, So driver build's IEEE SGL's whenever it receives any SCSI commands for this SES device. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_base.c | 5 ++ drivers/scsi/mpt3sas/mpt3sas_base.h | 16 +++++++ drivers/scsi/mpt3sas/mpt3sas_ctl.c | 7 +-- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 92 +++++++++++++++++++++++------------- 4 files changed, 83 insertions(+), 37 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index a2a70a5..03d15f5 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -2260,6 +2260,11 @@ base_is_prp_possible(struct MPT3SAS_ADAPTER *ioc, bool build_prp = true; data_length = scsi_bufflen(scmd); + if (pcie_device && + (mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info))) { + build_prp = false; + return build_prp; + } /* If Datalenth is <= 16K and number of SGE’s entries are <= 2 * we built IEEE SGL diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 5cd6148..66a68be 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1735,4 +1735,20 @@ mpt3sas_setup_direct_io(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd, /* NCQ Prio Handling Check */ bool scsih_ncq_prio_supp(struct scsi_device *sdev); +/** + * _scsih_is_pcie_scsi_device - determines if device is an pcie scsi device + * @device_info: bitfield providing information about the device. + * Context: none + * + * Returns 1 if scsi device. + */ +static inline int +mpt3sas_scsih_is_pcie_scsi_device(u32 device_info) +{ + if ((device_info & + MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE) == MPI26_PCIE_DEVINFO_SCSI) + return 1; + else + return 0; +} #endif /* MPT3SAS_BASE_H_INCLUDED */ diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index ea87871..29ecaa4 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -654,7 +654,6 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, size_t data_in_sz = 0; long ret; u16 device_handle = MPT3SAS_INVALID_DEVICE_HANDLE; - u8 tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE; issue_reset = 0; @@ -1049,12 +1048,14 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, mpt3sas_halt_firmware(ioc); pcie_device = mpt3sas_get_pdev_by_handle(ioc, le16_to_cpu(mpi_request->FunctionDependent1)); - if (pcie_device && (!ioc->tm_custom_handling)) + if (pcie_device && (!ioc->tm_custom_handling) && + (!(mpt3sas_scsih_is_pcie_scsi_device( + pcie_device->device_info)))) mpt3sas_scsih_issue_locked_tm(ioc, le16_to_cpu(mpi_request->FunctionDependent1), 0, MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 0, pcie_device->reset_timeout, - tr_method); + MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE); else mpt3sas_scsih_issue_locked_tm(ioc, le16_to_cpu(mpi_request->FunctionDependent1), diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 27c731a..f7610b8 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -1433,17 +1433,20 @@ _scsih_is_end_device(u32 device_info) } /** - * _scsih_is_nvme_device - determines if device is an nvme device + * _scsih_is_nvme_pciescsi_device - determines if + * device is an pcie nvme/scsi device * @device_info: bitfield providing information about the device. * Context: none * - * Return: 1 if nvme device. + * Returns 1 if device is pcie device type nvme/scsi. */ static int -_scsih_is_nvme_device(u32 device_info) +_scsih_is_nvme_pciescsi_device(u32 device_info) { - if ((device_info & MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE) - == MPI26_PCIE_DEVINFO_NVME) + if (((device_info & MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE) + == MPI26_PCIE_DEVINFO_NVME) || + ((device_info & MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE) + == MPI26_PCIE_DEVINFO_SCSI)) return 1; else return 0; @@ -2872,7 +2875,8 @@ scsih_abort(struct scsi_cmnd *scmd) handle = sas_device_priv_data->sas_target->handle; pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle); - if (pcie_device && (!ioc->tm_custom_handling)) + if (pcie_device && (!ioc->tm_custom_handling) && + (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) timeout = ioc->nvme_abort_timeout; r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, @@ -2943,11 +2947,13 @@ scsih_dev_reset(struct scsi_cmnd *scmd) pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle); - if (pcie_device && (!ioc->tm_custom_handling)) { + if (pcie_device && (!ioc->tm_custom_handling) && + (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { tr_timeout = pcie_device->reset_timeout; tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE; } else tr_method = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET; + r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->lun, MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, 0, 0, tr_timeout, tr_method); @@ -3020,7 +3026,8 @@ scsih_target_reset(struct scsi_cmnd *scmd) pcie_device = mpt3sas_get_pdev_by_handle(ioc, handle); - if (pcie_device && (!ioc->tm_custom_handling)) { + if (pcie_device && (!ioc->tm_custom_handling) && + (!(mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info)))) { tr_timeout = pcie_device->reset_timeout; tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE; } else @@ -3598,7 +3605,9 @@ _scsih_tm_tr_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) sas_address = pcie_device->wwid; } spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); - if (pcie_device && (!ioc->tm_custom_handling)) + if (pcie_device && (!ioc->tm_custom_handling) && + (!(mpt3sas_scsih_is_pcie_scsi_device( + pcie_device->device_info)))) tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE; else @@ -6694,7 +6703,7 @@ _scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) /* check if this is end device */ device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); - if (!(_scsih_is_nvme_device(device_info))) + if (!(_scsih_is_nvme_pciescsi_device(device_info))) return; wwid = le64_to_cpu(pcie_device_pg0.WWID); @@ -6803,7 +6812,8 @@ _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) pcie_device_pg0.AccessStatus)) return 0; - if (!(_scsih_is_nvme_device(le32_to_cpu(pcie_device_pg0.DeviceInfo)))) + if (!(_scsih_is_nvme_pciescsi_device(le32_to_cpu + (pcie_device_pg0.DeviceInfo)))) return 0; pcie_device = mpt3sas_get_pdev_by_wwid(ioc, wwid); @@ -6813,6 +6823,31 @@ _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) return 0; } + /* PCIe Device Page 2 contains read-only information about a + * specific NVMe device; therefore, this page is only + * valid for NVMe devices and skip for pcie devices of type scsi. + */ + if (!(mpt3sas_scsih_is_pcie_scsi_device( + le32_to_cpu(pcie_device_pg0.DeviceInfo)))) { + if (mpt3sas_config_get_pcie_device_pg2(ioc, &mpi_reply, + &pcie_device_pg2, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, + handle)) { + ioc_err(ioc, + "failure at %s:%d/%s()!\n", __FILE__, + __LINE__, __func__); + return 0; + } + + ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & + MPI2_IOCSTATUS_MASK; + if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { + ioc_err(ioc, + "failure at %s:%d/%s()!\n", __FILE__, + __LINE__, __func__); + return 0; + } + } + pcie_device = kzalloc(sizeof(struct _pcie_device), GFP_KERNEL); if (!pcie_device) { ioc_err(ioc, "failure at %s:%d/%s()!\n", @@ -6855,27 +6890,16 @@ _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) le64_to_cpu(enclosure_dev->pg0.EnclosureLogicalID); } /* TODO -- Add device name once FW supports it */ - if (mpt3sas_config_get_pcie_device_pg2(ioc, &mpi_reply, - &pcie_device_pg2, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle)) { - ioc_err(ioc, "failure at %s:%d/%s()!\n", - __FILE__, __LINE__, __func__); - kfree(pcie_device); - return 0; - } - - ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { - ioc_err(ioc, "failure at %s:%d/%s()!\n", - __FILE__, __LINE__, __func__); - kfree(pcie_device); - return 0; - } - pcie_device->nvme_mdts = - le32_to_cpu(pcie_device_pg2.MaximumDataTransferSize); - if (pcie_device_pg2.ControllerResetTO) - pcie_device->reset_timeout = - pcie_device_pg2.ControllerResetTO; - else + if (!(mpt3sas_scsih_is_pcie_scsi_device( + le32_to_cpu(pcie_device_pg0.DeviceInfo)))) { + pcie_device->nvme_mdts = + le32_to_cpu(pcie_device_pg2.MaximumDataTransferSize); + if (pcie_device_pg2.ControllerResetTO) + pcie_device->reset_timeout = + pcie_device_pg2.ControllerResetTO; + else + pcie_device->reset_timeout = 30; + } else pcie_device->reset_timeout = 30; if (ioc->wait_for_discovery_to_complete) @@ -8594,7 +8618,7 @@ _scsih_search_responding_pcie_devices(struct MPT3SAS_ADAPTER *ioc) } handle = le16_to_cpu(pcie_device_pg0.DevHandle); device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); - if (!(_scsih_is_nvme_device(device_info))) + if (!(_scsih_is_nvme_pciescsi_device(device_info))) continue; _scsih_mark_responding_pcie_device(ioc, &pcie_device_pg0); } @@ -9175,7 +9199,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) break; } handle = le16_to_cpu(pcie_device_pg0.DevHandle); - if (!(_scsih_is_nvme_device( + if (!(_scsih_is_nvme_pciescsi_device( le32_to_cpu(pcie_device_pg0.DeviceInfo)))) continue; pcie_device = mpt3sas_get_pdev_by_wwid(ioc, From patchwork Sat Aug 3 13:59:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A838D912 for ; Sat, 3 Aug 2019 14:00:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 951EC28913 for ; Sat, 3 Aug 2019 14:00:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83BE728918; Sat, 3 Aug 2019 14:00:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5F8128932 for ; Sat, 3 Aug 2019 14:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391060AbfHCOAZ (ORCPT ); Sat, 3 Aug 2019 10:00:25 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40247 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391048AbfHCOAZ (ORCPT ); Sat, 3 Aug 2019 10:00:25 -0400 Received: by mail-pf1-f195.google.com with SMTP id p184so37423378pfp.7 for ; Sat, 03 Aug 2019 07:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=St9MEIkrv8Xz87oSli+iSLjsQPV39f+9VQxA9HZnemo=; b=dLNcuemzHtQzWg4zdxbKvQlWn6EzHj6hEgIRmI0ywU3f4eksf6WrIiGjdKKyFcjkkJ jn9ZxniRHG7wvggX55OmsMQivE4EAfykfkpCvShktNXh8WGXHuJF4DpensrQ4xsvT3p1 naJXI7I34+QTdGQ3+oRFbp8a0veFNaE3V+ICo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=St9MEIkrv8Xz87oSli+iSLjsQPV39f+9VQxA9HZnemo=; b=eSovvb6sGwjFVxyq41dh9sw3bKFG5oyl25ECgAFSDOjcY0VI6eQPsuYlPDOU+1Aehe dBrM/Zm/4+nY6yqBcUg0yQpePOe9XWIDlvhWdWKw2PCzND84SBN/GUnQwk32mqiDNTvr 2NhiMp6jNTTFR3eocbZ7zoCD4YQZZsLuxPPYKX6TcJRnoE4Ip+g5yi9OJbUF0WzLroSa swtzJ1+nrSc9f41DhbulFuTjrDjetU7dBrAoqyxTA4ZuViF58sNzaiAKAv6dB0Ey1qAo f7O3xAp6dgCyVqnw4CWiS+SNyZSya3tTTu1t6Nr9gRoy5oCTJIGIQaGiWLOZbpUcXZAH L82Q== X-Gm-Message-State: APjAAAVza+US3xeTw55NkxJH4K4q9Bi+dpV8AVlIzjzmj7fNrUP0t8Xz 75lZaswVNuFDX2/0atSdqREmTnLE+gOBI8YyXrQ6kJrbXBrFDhH2U13r+VOICHFCCyIZxUqeaBY AQe/c9vXUQPqJYhxR/kAptEiNVHBlRVFwBK1jtio33CuVmUy/oaFxLArTsyAkj336NzvP4UW9oE TdSdcIrAUNtFIEsDZa3g== X-Google-Smtp-Source: APXvYqwyBEO6BHeWgs8os/6j0tQb7iXVo+WJ6CVK45kjgxuLzoYRR+obwPh9eXnyDfWHR9lhyAKjCA== X-Received: by 2002:a17:90a:77c5:: with SMTP id e5mr9066783pjs.109.1564840824007; Sat, 03 Aug 2019 07:00:24 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:23 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 06/12] mpt3sas: Allow ioctls to blocked access status NVMe Date: Sat, 3 Aug 2019 09:59:51 -0400 Message-Id: <1564840797-5876-7-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Description: Currently if driver see the NVMe drive with "DEVICE_BLOCKED" AcessStatus in it's PCIe Device Page0 then driver removes the drive from it's internal list and does not allow any IOCTL commands to be sent to the drive and will return the IOCTLs with "-ENODEV" status. Now driver will allow NVMe Encapsulated IOCTL issued to the NVMe device with an access status of DEVICE_BLOCKED. This change allows the user to flash new drive firmware online and make the drive working. Implementation: Add NVMe device only in the driver's internal list even though the device is in the blocked state so that the device will be visible to Apps. So that Apps can send NVMe Encapsulated IOCTLs to this drive and make the drive online. This NVMe drive with DEVICE_BLOCKED access status won't added to the SML, it will be added only in the driver's internal list. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_base.h | 2 ++ drivers/scsi/mpt3sas/mpt3sas_scsih.c | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 66a68be..5094319 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -583,6 +583,7 @@ static inline void sas_device_put(struct _sas_device *s) * @enclosure_level: The level of device's enclosure from the controller * @connector_name: ASCII value of the Connector's name * @serial_number: pointer of serial number string allocated runtime + * @access_status: Device's Access Status * @refcount: reference count for deletion */ struct _pcie_device { @@ -604,6 +605,7 @@ struct _pcie_device { u8 connector_name[4]; u8 *serial_number; u8 reset_timeout; + u8 access_status; struct kref refcount; }; /** diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index f7610b8..325b5b7 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -1152,6 +1152,11 @@ _scsih_pcie_device_add(struct MPT3SAS_ADAPTER *ioc, list_add_tail(&pcie_device->list, &ioc->pcie_device_list); spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); + if (pcie_device->access_status == + MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED) { + clear_bit(pcie_device->handle, ioc->pend_os_device_add); + return; + } if (scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0)) { _scsih_pcie_device_remove(ioc, pcie_device); } else if (!pcie_device->starget) { @@ -1196,7 +1201,9 @@ _scsih_pcie_device_init_add(struct MPT3SAS_ADAPTER *ioc, spin_lock_irqsave(&ioc->pcie_device_lock, flags); pcie_device_get(pcie_device); list_add_tail(&pcie_device->list, &ioc->pcie_device_init_list); - _scsih_determine_boot_device(ioc, pcie_device, PCIE_CHANNEL); + if (pcie_device->access_status != + MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED) + _scsih_determine_boot_device(ioc, pcie_device, PCIE_CHANNEL); spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); } /** @@ -6548,6 +6555,11 @@ _scsih_check_pcie_access_status(struct MPT3SAS_ADAPTER *ioc, u64 wwid, break; case MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED: desc = "PCIe device blocked"; + ioc_info(ioc, + "Device with Access Status (%s): wwid(0x%016llx), " + "handle(0x%04x)\n ll only be added to the internal list", + desc, (u64)wwid, handle); + rc = 0; break; case MPI26_PCIEDEV0_ASTATUS_MEMORY_SPACE_ACCESS_FAILED: desc = "PCIe device mem space access failed"; @@ -6652,7 +6664,8 @@ _scsih_pcie_device_remove_from_sml(struct MPT3SAS_ADAPTER *ioc, pcie_device->enclosure_level, pcie_device->connector_name); - if (pcie_device->starget) + if (pcie_device->starget && (pcie_device->access_status != + MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED)) scsi_remove_target(&pcie_device->starget->dev); dewtprintk(ioc, ioc_info(ioc, "%s: exit: handle(0x%04x), wwid(0x%016llx)\n", @@ -6718,6 +6731,7 @@ _scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) if (unlikely(pcie_device->handle != handle)) { starget = pcie_device->starget; sas_target_priv_data = starget->hostdata; + pcie_device->access_status = pcie_device_pg0.AccessStatus; starget_printk(KERN_INFO, starget, "handle changed from(0x%04x) to (0x%04x)!!!\n", pcie_device->handle, handle); @@ -6859,6 +6873,7 @@ _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) pcie_device->id = ioc->pcie_target_id++; pcie_device->channel = PCIE_CHANNEL; pcie_device->handle = handle; + pcie_device->access_status = pcie_device_pg0.AccessStatus; pcie_device->device_info = le32_to_cpu(pcie_device_pg0.DeviceInfo); pcie_device->wwid = wwid; pcie_device->port_num = pcie_device_pg0.PortNum; @@ -8531,6 +8546,8 @@ _scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc, if ((pcie_device->wwid == le64_to_cpu(pcie_device_pg0->WWID)) && (pcie_device->slot == le16_to_cpu( pcie_device_pg0->Slot))) { + pcie_device->access_status = + pcie_device_pg0->AccessStatus; pcie_device->responding = 1; starget = pcie_device->starget; if (starget && starget->hostdata) { @@ -10063,6 +10080,12 @@ _scsih_probe_pcie(struct MPT3SAS_ADAPTER *ioc) pcie_device_put(pcie_device); continue; } + if (pcie_device->access_status == + MPI26_PCIEDEV0_ASTATUS_DEVICE_BLOCKED) { + pcie_device_make_active(ioc, pcie_device); + pcie_device_put(pcie_device); + continue; + } rc = scsi_add_device(ioc->shost, PCIE_CHANNEL, pcie_device->id, 0); if (rc) { From patchwork Sat Aug 3 13:59:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7357E13AC for ; Sat, 3 Aug 2019 14:00:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B74C285D6 for ; Sat, 3 Aug 2019 14:00:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A594288E1; Sat, 3 Aug 2019 14:00:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD6C4285D6 for ; Sat, 3 Aug 2019 14:00:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391068AbfHCOA1 (ORCPT ); Sat, 3 Aug 2019 10:00:27 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43840 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391048AbfHCOA1 (ORCPT ); Sat, 3 Aug 2019 10:00:27 -0400 Received: by mail-pl1-f195.google.com with SMTP id 4so27724564pld.10 for ; Sat, 03 Aug 2019 07:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DhdDwRTZnIL6mfxKCAscOtjJxfR6DI0aEr2pNtYrLy8=; b=QF12wNNhhRGdJa8mOe/neuLdSBWpJ5UKKsUlMoUwcp0gENPtSNRJ33Vg5ZJi50oPjh ZD8TNXV5YEo8GOvzfLuYuiR7eBFkkH6dwn4S66kjjLFHXWstgClSM7y0Zu4HUSg4cycQ AIxfg4RWSNGWdJ7w4hQgZ8lEDXRKcimJ0gQVc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DhdDwRTZnIL6mfxKCAscOtjJxfR6DI0aEr2pNtYrLy8=; b=d2r69nMdjHV3sH+OPBlkC1VUx6JcHLgCaisl1k4ir9f0cQbywYLfmdF4/aNu3pof9E wkJK4zA6yDv4Uq8RKuHQbyGj2V+EdvdhSLRZ2FoDD/blNYCTINzwFk6JiNFX7kM2WhG1 EPKB8rJ26LfUYASTN8ZpNHjzSU+8qqzM8tFFHa/hC55qfixm6J9y0LztepfJrVIENPv4 e0bOct4NLgJiQ7LVO4xypP6RWElqF13OJC24yQvAbWYiHhQkZowSzPJiadkUBngP6g4N PMicay2JYYmBH9UY/KvtPyxflINyEK9goL6qBFZZTD6vr60qz0P+TFJrkzK7Z8n8e9+g Zaiw== X-Gm-Message-State: APjAAAVE/M0xT7EGbH9aK9hJPDrlnsOxYi9vlo1hFnxj2j0G1eK+Aiam AheBpiC2V/tceyRKpCfZNwch+3C1lBTiuJ02vC+Ca3FJCHRMon/PdmduWxDm+v1Hg4DAOHt/Iig /+f9SUZHQLEv66JW2KEPXs5fp0F7SKwg0IMZ9TJnsZkzmD2EkdQKLK7VcVeTpooK1RBwKyijJou cACDHBMAaWVE5EzzPs3Q== X-Google-Smtp-Source: APXvYqweNBNyn1xl3amtLRbUhdmrzWQ7HZN0YbKuWJnP08UhASG0TE54mYj6VP5eo1KOHNJLGdGzLw== X-Received: by 2002:a17:902:9a84:: with SMTP id w4mr16387064plp.160.1564840826554; Sat, 03 Aug 2019 07:00:26 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:25 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 07/12] mpt3sas: Support MEMORY MOVE Tool box command Date: Sat, 3 Aug 2019 09:59:52 -0400 Message-Id: <1564840797-5876-8-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Host uses the Memory Move Tool to copy data from any source/destination combination of system memory and IOC memory. Memory Move Tool box request contains two SGE fields, First SGE field must contains the source buffer details described by an MPI Simple SGE. The second SGE field must contains the destination buffer details described by an MPI Simple SGE. Source -> Destination 1. IOC -> IOC (Both the SGE's will be filled by application) 2. HOST -> HOST (Both the SGE's will be filled by the host, application should give sgl_offset to first SGE offset) 3. IOC -> HOST (Application will fill the first SGE and set the sgl_offset to second SGE and hence driver fills the second SGE) 4. HOST -> IOC (Application will fill IOC buffer information in the first SGE and set the sgl_offset to second SGE. Then driver will fill the second SGE with Host buffer information and just before posting the command to the firmware, driver will swap these two SGEs so that first SGE contains the HOST buffer information and second SGE contains the IOC information. Driver has to take care only the 4th case, other three cases are by default supported by the current driver design. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 29ecaa4..7179e5f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -926,9 +926,32 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, MPI26_TOOLBOX_BACKEND_PCIE_LANE_MARGIN)) ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma, data_in_sz); - else + else if (toolbox_request->Tool == + MPI2_TOOLBOX_MEMORY_MOVE_TOOL) { + Mpi2ToolboxMemMoveRequest_t *mem_move_request = + (Mpi2ToolboxMemMoveRequest_t *)request; + Mpi2SGESimple64_t tmp, *src = NULL, *dst = NULL; + + ioc->build_sg_mpi(ioc, psge, data_out_dma, + data_out_sz, data_in_dma, data_in_sz); + if (data_out_sz && !data_in_sz) { + dst = + (Mpi2SGESimple64_t *)&mem_move_request->SGL; + src = (void *)dst + ioc->sge_size; + + memcpy(&tmp, src, ioc->sge_size); + memcpy(src, dst, ioc->sge_size); + memcpy(dst, &tmp, ioc->sge_size); + } + if (ioc->logging_level & MPT_DEBUG_TM) { + ioc_info(ioc, + "Mpi2ToolboxMemMoveRequest_t request msg\n"); + _debug_dump_mf(mem_move_request, + ioc->request_sz/4); + } + } else ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz, - data_in_dma, data_in_sz); + data_in_dma, data_in_sz); ioc->put_smid_default(ioc, smid); break; } From patchwork Sat Aug 3 13:59:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 292DB13AC for ; Sat, 3 Aug 2019 14:00:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 199C8285D6 for ; Sat, 3 Aug 2019 14:00:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D6FE288C7; Sat, 3 Aug 2019 14:00:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9876B285D6 for ; Sat, 3 Aug 2019 14:00:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391072AbfHCOAa (ORCPT ); Sat, 3 Aug 2019 10:00:30 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34368 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391048AbfHCOAa (ORCPT ); Sat, 3 Aug 2019 10:00:30 -0400 Received: by mail-pg1-f193.google.com with SMTP id n9so31249135pgc.1 for ; Sat, 03 Aug 2019 07:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vA//u+LjihGzn1EIeH14S/bHag5XpW93Lbs2u7dCS3M=; b=C9QK0f31yjwOfhcemDVRIpyeFJRvIhc5m/xz7Xyyq07E7ha4VRbPJpuDwAcByMKDTz JCA0SUbkhmSbOe1VPlvuAeWTJHxlXED5uEEIFNhp+XxII1jPODMz5+KNiM7oQiI9aEFD CTJJ2pFRgkk5Z7TSLPYf+ID6iVwxW69fIQYR8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vA//u+LjihGzn1EIeH14S/bHag5XpW93Lbs2u7dCS3M=; b=tOA8JqipAmP0oyZpAC/TTIF2BCD6Yj7AlFVhs+xzV+et9UnCFpq+cCCoxgG7RBArQK zhqTLGBKE6TAGklmQLVF9XrYqt5n/+fSImphw3zZ+Q+i6py85z90edUZdIAwUhrLWUzW CCFibo80K65rqQY+CTxk+StzCQ825Yab6Q49NOadMwHAzyNkqONTvVzqBNpgHhErwUIT ZnVf1f+PsQ/mZLJZk9lXT4shL4Nb70T7Vedf+5engB0LnosiK9cq7DQaF+7XNn8/jhCQ UC8A3/MlO3Ga/TPuLMFFvclNwbrumrht/MPacTBMdFf2jfbvskW4wZc/7K8L2+QwawEU R3ZQ== X-Gm-Message-State: APjAAAVDdIePv5ofWMiTw3eVBg/I37TIjicChE6v1sxm4aWDC8PZ7utt adXtqjv3auyPn7EYZ4C56xhvAmXeeEWTchOqtFt8c5vMJvhE2CwAkJ7a0dHsk3wGWBXDHVozjuB JWpFelcCqu8InO8Zg6RBAgN+OVWcMq9RZsMa6hGuFI0ntou4zhwbgDsTv6Bpv/z9nunQfe6r3uT o1HTBPtW5fHX5557b0Eg== X-Google-Smtp-Source: APXvYqzNvf0UpGOEW3AciW9PO0xRFp/pafrsvt/iuBkz+1PdhZO3VfcPQXvZzGlozzlYdgorWh4RaA== X-Received: by 2002:a65:6093:: with SMTP id t19mr49071849pgu.79.1564840828865; Sat, 03 Aug 2019 07:00:28 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:28 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 08/12] mpt3sas: Add sysfs to know supported features Date: Sat, 3 Aug 2019 09:59:53 -0400 Message-Id: <1564840797-5876-9-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently with sysfs parameter "drv_support_bitmap" driver exposes whether driver supports toolbox memory move command or not. And application should issue the toolbox memory move command only if driver tell that memory move tool box command is supported through this sysfs parameter. In future we can utilize this sysfs parameter if any new feature is added and need to notify the same to applications. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++++ drivers/scsi/mpt3sas/mpt3sas_ctl.c | 19 +++++++++++++++++++ drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 5094319..fa5f1a6 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1047,6 +1047,7 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc); * @schedule_dead_ioc_flush_running_cmds: callback to flush pending commands * @thresh_hold: Max number of reply descriptors processed * before updating Host Index + * @drv_support_bitmap: driver's supported feature bit map * @scsi_io_cb_idx: shost generated commands * @tm_cb_idx: task management commands * @scsih_cb_idx: scsih internal commands @@ -1230,6 +1231,7 @@ struct MPT3SAS_ADAPTER { bool msix_load_balance; u16 thresh_hold; u8 high_iops_queues; + u32 drv_support_bitmap; /* internal commands, callback index */ u8 scsi_io_cb_idx; @@ -1454,6 +1456,8 @@ struct MPT3SAS_ADAPTER { GET_MSIX_INDEX get_msix_index_for_smlio; }; +#define MPT_DRV_SUPPORT_BITMAP_MEMMOVE 0x00000001 + typedef u8 (*MPT_CALLBACK)(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply); diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 7179e5f..daf1959 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -3375,6 +3375,24 @@ static DEVICE_ATTR_RW(diag_trigger_mpi); /*****************************************/ +/** + * drv_support_bitmap_show - driver supported feature bitmap + * @cdev - pointer to embedded class device + * @buf - the buffer returned + * + * A sysfs 'read-only' shost attribute. + */ +static ssize_t +drv_support_bitmap_show(struct device *cdev, + struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(cdev); + struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); + + return snprintf(buf, PAGE_SIZE, "0x%08x\n", ioc->drv_support_bitmap); +} +static DEVICE_ATTR_RO(drv_support_bitmap); + struct device_attribute *mpt3sas_host_attrs[] = { &dev_attr_version_fw, &dev_attr_version_bios, @@ -3400,6 +3418,7 @@ struct device_attribute *mpt3sas_host_attrs[] = { &dev_attr_diag_trigger_event, &dev_attr_diag_trigger_scsi, &dev_attr_diag_trigger_mpi, + &dev_attr_drv_support_bitmap, &dev_attr_BRM_status, NULL, }; diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 325b5b7..9b89fa4 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -10499,6 +10499,10 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx; ioc->logging_level = logging_level; ioc->schedule_dead_ioc_flush_running_cmds = &_scsih_flush_running_cmds; + /* + * Enable MEMORY MOVE support flag. + */ + ioc->drv_support_bitmap |= MPT_DRV_SUPPORT_BITMAP_MEMMOVE; /* misc semaphores and spin locks */ mutex_init(&ioc->reset_in_progress_mutex); /* initializing pci_access_mutex lock */ From patchwork Sat Aug 3 13:59:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8338C912 for ; Sat, 3 Aug 2019 14:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F893285D6 for ; Sat, 3 Aug 2019 14:00:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6425D288C7; Sat, 3 Aug 2019 14:00:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D1DC285D6 for ; Sat, 3 Aug 2019 14:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391081AbfHCOAd (ORCPT ); Sat, 3 Aug 2019 10:00:33 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37000 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391048AbfHCOAc (ORCPT ); Sat, 3 Aug 2019 10:00:32 -0400 Received: by mail-pf1-f196.google.com with SMTP id 19so37421466pfa.4 for ; Sat, 03 Aug 2019 07:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ztnyeuKuc6TSo/zopSbLn72WwyKQgh3z/qIXNzpetHk=; b=RV9mXcB9xVKrMlDz0aX6Gsi06U+UtQoJAmvNmbuIQuKkbLJEM4n/QWOLS3qSt2bk+3 jA1rvUtHv6m0bl12sn2PkV+/HR0PVDyFGtJHEzHbCa7jB29FTbR+eNqCeR6/DHDgMh2d eQuGstUQPaqk+4Ie8DsD1nZ/aPbPNNXAw1eSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ztnyeuKuc6TSo/zopSbLn72WwyKQgh3z/qIXNzpetHk=; b=QfMxqp2Xic34mXj5Q3060M4y5+R8xXByYZ4bmu8Z8sVzUlkqaZT1ItZsNh7R72m+Za 4+jyR1IyNJkCOOmML5FRsTfGjEuCDI6lLSohq9lH5s380U5hD5GBfs5KyHa6K7Rlarht ILPIvunOnV/insYi+GI26KxoUJinyg4VAU3NmRxBWcm+ypY2nj+fvOa0zqdAlGCuhSSz Zgt8GHCgWkfMtBiKLXqygL7FXrXnY0I+l6EwKfTMDy6nz2vSK1Knd303aQgm8hIeP3hP bmkaSELK4Q3DhitzCMalAVnbhzPtxe0HScTVZxyQL/anK6TpTuuGyqp4INPSQHhVvLaZ JJZw== X-Gm-Message-State: APjAAAX2FhM0UfKrMxvjD3t0Jwegi+S1l8vYDBbqtZK/iD3uf6R+cYNI iYYBJ7hbTTJBqESaXPc+VOuKrZa9NugYDU3paoo80lLVxsiBbsbAycllHU68n6O3JyXaPAVc5Qa u8pmsAcWaBEcRDC/UTVw/xmCjcuIogdkc+W5D5Ie7T0lcXLLtW8+fV2xzyoFehAGcktVRuh7RcO xXVyh2d+mobj7sj44Gow== X-Google-Smtp-Source: APXvYqxJ03jndSQjleplxTb4Q3ViSCRQp2lbOpiFDArJUNkczqITS4v0+9WK2RVzs5nJUYVL1wEATA== X-Received: by 2002:a65:6817:: with SMTP id l23mr88170898pgt.46.1564840831305; Sat, 03 Aug 2019 07:00:31 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:30 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 09/12] mpt3sas: Handle fault during HBA initialization Date: Sat, 3 Aug 2019 09:59:54 -0400 Message-Id: <1564840797-5876-10-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During HBA initialization time, if handshake operation fails due to some firmware fault then currently driver is terminating the HBA initialization. It is possible that HBA may come up properly if diag reset is issued. So improvement is made in driver in such a way that before terminating the HBA initialization driver checks the IOC state and if IOC state is in fault state then issue diag reset for once. if diag reset is success then continue with HBA initialization else terminate the HBA initialization. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_base.c | 75 ++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 03d15f5..f913b18 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -3183,6 +3183,37 @@ mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc) } } +static int +_base_diag_reset(struct MPT3SAS_ADAPTER *ioc); + +/** + * _base_check_for_fault_and_issue_reset - check if IOC is in fault state + * and if it is in fault state then issue diag reset. + * @ioc: per adapter object + * + * Returns: 0 for success, non-zero for failure. + */ +static int +_base_check_for_fault_and_issue_reset(struct MPT3SAS_ADAPTER *ioc) +{ + u32 ioc_state; + int rc = -EFAULT; + + dinitprintk(ioc, pr_info("%s\n", __func__)); + if (ioc->pci_error_recovery) + return 0; + ioc_state = mpt3sas_base_get_iocstate(ioc, 0); + dhsprintk(ioc, pr_info("%s: ioc_state(0x%08x)\n", __func__, ioc_state)); + + if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) { + mpt3sas_base_fault_info(ioc, ioc_state & + MPI2_DOORBELL_DATA_MASK); + rc = _base_diag_reset(ioc); + } + + return rc; +} + /** * mpt3sas_base_map_resources - map in controller resources (io/irq/memap) * @ioc: per adapter object @@ -3195,7 +3226,7 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) struct pci_dev *pdev = ioc->pdev; u32 memap_sz; u32 pio_sz; - int i, r = 0; + int i, r = 0, rc; u64 pio_chip = 0; phys_addr_t chip_phys = 0; struct adapter_reply_queue *reply_q; @@ -3256,8 +3287,11 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) _base_mask_interrupts(ioc); r = _base_get_ioc_facts(ioc); - if (r) - goto out_fail; + if (r) { + rc = _base_check_for_fault_and_issue_reset(ioc); + if (rc || (_base_get_ioc_facts(ioc))) + goto out_fail; + } if (!ioc->rdpq_array_enable_assigned) { ioc->rdpq_array_enable = ioc->rdpq_array_capable; @@ -5416,8 +5450,6 @@ _base_wait_on_iocstate(struct MPT3SAS_ADAPTER *ioc, u32 ioc_state, int timeout) * * Notes: MPI2_HIS_IOC2SYS_DB_STATUS - set to one when IOC writes to doorbell. */ -static int -_base_diag_reset(struct MPT3SAS_ADAPTER *ioc); static int _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout) @@ -6693,7 +6725,7 @@ _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, enum reset_type type) static int _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc) { - int r, i, index; + int r, i, index, rc; unsigned long flags; u32 reply_address; u16 smid; @@ -6796,8 +6828,19 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc) skip_init_reply_post_free_queue: r = _base_send_ioc_init(ioc); - if (r) - return r; + if (r) { + /* + * No need to check IOC state for fault state & issue + * diag reset during host reset. This check is need + * only during driver load time. + */ + if (!ioc->is_driver_loading) + return r; + + rc = _base_check_for_fault_and_issue_reset(ioc); + if (rc || (_base_send_ioc_init(ioc))) + return r; + } /* initialize reply free host index */ ioc->reply_free_host_index = ioc->reply_free_queue_depth - 1; @@ -6889,7 +6932,7 @@ mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc) int mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) { - int r, i; + int r, i, rc; int cpu_id, last_cpu_id = 0; dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__)); @@ -6933,8 +6976,11 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) pci_set_drvdata(ioc->pdev, ioc->shost); r = _base_get_ioc_facts(ioc); - if (r) - goto out_free_resources; + if (r) { + rc = _base_check_for_fault_and_issue_reset(ioc); + if (rc || (_base_get_ioc_facts(ioc))) + goto out_free_resources; + } switch (ioc->hba_mpi_version_belonged) { case MPI2_VERSION: @@ -7002,8 +7048,11 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) { r = _base_get_port_facts(ioc, i); - if (r) - goto out_free_resources; + if (r) { + rc = _base_check_for_fault_and_issue_reset(ioc); + if (rc || (_base_get_port_facts(ioc, i))) + goto out_free_resources; + } } r = _base_allocate_memory_pools(ioc); From patchwork Sat Aug 3 13:59:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D8E4C912 for ; Sat, 3 Aug 2019 14:00:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9773285D6 for ; Sat, 3 Aug 2019 14:00:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDA3E288C7; Sat, 3 Aug 2019 14:00:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61B12285D6 for ; Sat, 3 Aug 2019 14:00:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391099AbfHCOAf (ORCPT ); Sat, 3 Aug 2019 10:00:35 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37899 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391048AbfHCOAe (ORCPT ); Sat, 3 Aug 2019 10:00:34 -0400 Received: by mail-pf1-f196.google.com with SMTP id y15so37438172pfn.5 for ; Sat, 03 Aug 2019 07:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=INePfg+hYB0XZZdpfxRYjoB5rJIHkZ+5ZTU+FZMUUU8=; b=ZT1QfVT/piayo5hC2D4T2yYHp1sc0vTEgt+mCZ3KLTEYhQ1n8vOatXEZwKpF0OGRv5 werkjq5w+uu+9yb+u9HP8QJCyfb5eGv7JC1M33hjVgYxLLs4uHJGvf0I9KOushZWMtaX Q2yPS4NpGLxJd32yiKCbjfNhqjzTaPf9z/c4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=INePfg+hYB0XZZdpfxRYjoB5rJIHkZ+5ZTU+FZMUUU8=; b=nH43NXHVjV/b7b8ydLQMTQc+DWCbeTbQbWr/dry8DH1veWCR/t+ab3P+PP3i/KSTvY sR0ka7fjx6UONNzvUb1e5dgmu6Qog00cdqVVJ609ytyYkpWYWuvd6kIhhCRbFD0D71ea ntyYimUZsYwEoPQt1YC7CfOZNmoUXpK7HOMq50oqak7OE9ROQBADohUjkYRgz6Lxaeb7 hfUgxXR8cu7kliV5CRbsis0Qp9DSQnXosT0pxKHmoocEklYjyCcEShz3mrYtWIOH8F1m 3yv/gEntZGayUDi/xUtureZd0kmB4TrIc0q+EWpMdwwjWRu+MLTcARw7sYhaQFOyqVTd Jt1Q== X-Gm-Message-State: APjAAAWJjXHBMG2DJ/RV9h8bow1mtghuvvng4XARm+NvSegJt7pk4MI0 UskCYKNNQPYiCBRtTWZYy40TnYsw4i4AKzmjmhUL3TRhuqTXoJzv7WhT8Z1dip4sKM3OszZAMUD fPRGOdDewcP2yz3GHP2psMMcQnCWwW0TqmTsrpZg+DjU9twtSFjKZ5iLWGy3QkNDgb/4Rvx5/mi eaOlos5P1Mi/CIfe5a/A== X-Google-Smtp-Source: APXvYqzihn7Y0KCns8+LsAhIB8dBQ+Atkus//ogt+rWCkPPcR2dHQOxaKtnk/WIqNw9TCEe68sZeFg== X-Received: by 2002:a63:c84d:: with SMTP id l13mr123933226pgi.154.1564840833838; Sat, 03 Aug 2019 07:00:33 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:33 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 10/12] mpt3sas: Reduce the performance dip Date: Sat, 3 Aug 2019 09:59:55 -0400 Message-Id: <1564840797-5876-11-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is to reduce the performance dip depth observed on SATA HDD when ATA PT command is outstanding. Driver returns IO commands with status "SAM_STAT_BUSY" whenever ATA PT command is outstanding. With this, IO commands will be retried until this outstanding ATA PT to complete and hence we will observe dip in performance. As the driver is completing the subsequent IOs commands with SAM_STAT_BUSY status, these IOs has to go though the block layer. Hence it adds latency to the IOs and large performance dip depth is observed. So to reduce this performance dip depth, added improvement in driver to return the subsequent IOs with SCSI_MLQUEUE_DEVICE_BUSY status instead of completing the IOs with SAM_STAT_BUSY status when ATA PT command is outstanding. Sending command back with SCSI_MLQUEUE_DEVICE_BUSY does not go through complete block layer stack (as scsi_done won't be called) SML immediately push the command and this method will avoid latency of Block layer stack and the performance dip depth will be reduced. On Local setup, ran 512k sequential read IO operation on HGST SATA drive with existing driver & with this improvement drivers and here is the result, 1. With existing driver: IOs are running at bandwidth of ~230 rMB/s and whenever any ATA PT command is outstanding (e.g issued from systemd-udevd daemon) then this bandwidth drops to ~150 rMB/s. 2. With this improvement driver: IOs are running at bandwidth of ~230 rMB/s and whenever any ATA PT command is outstanding then this bandwidth drops to just ~190 rMB/s. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 9b89fa4..24b5f5f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -4670,11 +4670,8 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) * since we're lockless at this point */ do { - if (test_bit(0, &sas_device_priv_data->ata_command_pending)) { - scmd->result = SAM_STAT_BUSY; - scmd->scsi_done(scmd); - return 0; - } + if (test_bit(0, &sas_device_priv_data->ata_command_pending)) + return SCSI_MLQUEUE_DEVICE_BUSY; } while (_scsih_set_satl_pending(scmd, true)); if (scmd->sc_data_direction == DMA_FROM_DEVICE) From patchwork Sat Aug 3 13:59:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49C9C13AC for ; Sat, 3 Aug 2019 14:00:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36983285D6 for ; Sat, 3 Aug 2019 14:00:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 279CD286BD; Sat, 3 Aug 2019 14:00:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10FAF285D6 for ; Sat, 3 Aug 2019 14:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391112AbfHCOAh (ORCPT ); Sat, 3 Aug 2019 10:00:37 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44704 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391038AbfHCOAh (ORCPT ); Sat, 3 Aug 2019 10:00:37 -0400 Received: by mail-pg1-f195.google.com with SMTP id i18so37472442pgl.11 for ; Sat, 03 Aug 2019 07:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WWFNrMfs7MpoNynZtF5FK1CvE/E5FEYETo7HSNeuckw=; b=ElSkCQBmbDMrbJ8T4yXGieW0aZQw34Nt0xZDpD0j3AwYbx4E2w5rrPdDDy1XUTF5wR wKM5LYpYqpFUPzg9DkCQ36OgiM1tf7Yn6HGyNqsDDSiKLOmUO3Yk4XYHlRSravSaondO RKPU+4Gwu+uKzAfUVNg2VlBPJasYu4MRZE5XY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WWFNrMfs7MpoNynZtF5FK1CvE/E5FEYETo7HSNeuckw=; b=Yv/GN6gVpAdI5L7QtN2riK4IdFvHbm8RqJoDoPPQHyiUZtb0Ls9ROyKWxofISZgMQW 17CSHRFy1nHRKcB/eOtwHR/bsJi3ZyLbRqOQcC7HphRgP2HP8yzwiWRbE/jsbhYGsyo0 Mc91u9l7fQj6ZE0FAxv+MCYr1lohchGLSya0ugE2xqnU74nZMx5FzaigsZH4GNCGW/U5 jpR5ZR/WyzuYBJQnUhKckJ1G94O/BXgNYUyqTQunYKHZ2BbwqSFD7WVdhtWKo5fuTSzm H2298wdKZgYVn/Ut6BKQeUYFgHUkj9vofmotVfDdY1pvrMmJ2CkKJEaMuk6gYXj+U7Me DEpw== X-Gm-Message-State: APjAAAWuOMjZytrBwM0q3D6uNfjh/ld9CgwbbvXO4/vZVIbzWcLJuxwz Viam92dFo5hGg07ge3InXtfEu8ViY2Eu6YRVds0qC2fdFe4diYunI0XlxAiUtoGzCO7+OvKM3+y /CR5Gj7oaRsorc1NAwNaee9CsHhXcD37+VbtKd4JF6vsZZ6l3KwzOqmEO3zzWJ7YH42VtQwtWri md22D7s5kaQHsPeWR3GA== X-Google-Smtp-Source: APXvYqz9qKhE+6zLtaXRULHBQkCH5HShjvOpW4BFeSZZqai1FO5EVBd7CWNqd6llnkd142bAca/P+g== X-Received: by 2002:a65:500a:: with SMTP id f10mr98059201pgo.105.1564840836228; Sat, 03 Aug 2019 07:00:36 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:35 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 11/12] mpt3sas:Run SAS DEVICE STATUS CHANGE EVENT from ISR Date: Sat, 3 Aug 2019 09:59:56 -0400 Message-Id: <1564840797-5876-12-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some case like while performing extensive expander reset or phy reset user may observe that drives are not visible in OS and driver's firmware-worker thread got blocked for more than 120 seconds call trace for below scenarios, 1. Received target add event for Device A and hence driver has registered this device to SML by calling sas_rphy_add(). SML has half added this device and returned the control to the driver by quitting from sas_rphy_add() API, and started some background scanning on this device A. 2. While background scanning is going on device A, driver has received SAS DEVICE STATUS CHANGE EVENT with RC code "Internal device reset" event and hence driver has set tm_busy flag for this Device A from FW worker thread context. When tm_busy flag is set then driver return scsi commands with device busy status asking the kernel to retry the same command after some time. So background scanning for device A will be waiting for this tm_busy to be cleared. 3. Meanwhile driver has received a target add event for Device B and hence driver called sas_rphy_add() API to register this device with SML. Bust since background scanning for Device A is still pending and hence SML is not quitting from this sas_rphy_add() and hence driver’s firmware worker thread got blocked. 4. Now driver has received SAS DEVICE STATUS CHANGE EVENT with RC code "Internal device reset complete" event, But as driver’s firmware worker thread got blocked in Step3, so it can’t process this event and it was not clearing the tm_busy flag and deadlock has occurred. (where SML was waiting for tm_busy flag to be cleared and our FW worker thread is waiting for SML to quit from sas_device_rphy_add() API). Same deadlock will be observed even if device B is getting removed in step3. So to limit these types of deadlocks driver will process the SAS DEVICE STATUS CHANGE EVENT events from ISR context instead of processing this event from worker thread context. This improvement avoids above deadlock. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 24b5f5f..09b3d3f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -6469,24 +6469,17 @@ _scsih_sas_device_status_change_event_debug(struct MPT3SAS_ADAPTER *ioc, /** * _scsih_sas_device_status_change_event - handle device status change * @ioc: per adapter object - * @fw_event: The fw_event_work object + * @event_data: The fw event * Context: user. */ static void _scsih_sas_device_status_change_event(struct MPT3SAS_ADAPTER *ioc, - struct fw_event_work *fw_event) + Mpi2EventDataSasDeviceStatusChange_t *event_data) { struct MPT3SAS_TARGET *target_priv_data; struct _sas_device *sas_device; u64 sas_address; unsigned long flags; - Mpi2EventDataSasDeviceStatusChange_t *event_data = - (Mpi2EventDataSasDeviceStatusChange_t *) - fw_event->event_data; - - if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) - _scsih_sas_device_status_change_event_debug(ioc, - event_data); /* In MPI Revision K (0xC), the internal device reset complete was * implemented, so avoid setting tm_busy flag for older firmware. @@ -6518,6 +6511,12 @@ _scsih_sas_device_status_change_event(struct MPT3SAS_ADAPTER *ioc, else target_priv_data->tm_busy = 0; + if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) + ioc_info(ioc, + "%s tm_busy flag for handle(0x%04x)\n", + (target_priv_data->tm_busy == 1) ? "Enable" : "Disable", + target_priv_data->handle); + out: if (sas_device) sas_device_put(sas_device); @@ -9346,7 +9345,10 @@ _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event) _scsih_sas_topology_change_event(ioc, fw_event); break; case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE: - _scsih_sas_device_status_change_event(ioc, fw_event); + if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) + _scsih_sas_device_status_change_event_debug(ioc, + (Mpi2EventDataSasDeviceStatusChange_t *) + fw_event->event_data); break; case MPI2_EVENT_SAS_DISCOVERY: _scsih_sas_discovery_event(ioc, fw_event); @@ -9519,6 +9521,10 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, break; } case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE: + _scsih_sas_device_status_change_event(ioc, + (Mpi2EventDataSasDeviceStatusChange_t *) + mpi_reply->EventData); + break; case MPI2_EVENT_IR_OPERATION_STATUS: case MPI2_EVENT_SAS_DISCOVERY: case MPI2_EVENT_SAS_DEVICE_DISCOVERY_ERROR: From patchwork Sat Aug 3 13:59:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 11074445 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF1AA13AC for ; Sat, 3 Aug 2019 14:00:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB815285D6 for ; Sat, 3 Aug 2019 14:00:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD537286BD; Sat, 3 Aug 2019 14:00:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65AD1285D6 for ; Sat, 3 Aug 2019 14:00:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391120AbfHCOAl (ORCPT ); Sat, 3 Aug 2019 10:00:41 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41133 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391038AbfHCOAl (ORCPT ); Sat, 3 Aug 2019 10:00:41 -0400 Received: by mail-pg1-f195.google.com with SMTP id x15so27124091pgg.8 for ; Sat, 03 Aug 2019 07:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8WNRGffXg/AxN0DaURiktnqcuFFQbQVClioQk+0sbEs=; b=Otli1NVaeBoK/+VgX2qk6S7unWMD4gT0aw2aIBXeAu9Sa3dO8jOpOuqE95eLp1Fina 6j8YzlNlf3rpkr868E3X1EUSDdRljl5F00x5+0O8OZHfHdB6tUAaZVpmsKsafgPBt4b/ qkQqC9calpxDwpGEdWHT39rhv7UNnz4UGlYT8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8WNRGffXg/AxN0DaURiktnqcuFFQbQVClioQk+0sbEs=; b=h84TtFF5hars0fR0eKJ/pqDnRDlkDkZw1JnUEesx89ru3DCs1iQQ+fez9l4BJ6/bRw 7akKB/Ca8BxY+0FL9LaO3zCtscpVmmx1BJog/buyMAq0XiMQqmb/vhRVfjGRC//+3RRF vABMU0P2imIvTJkdo0FAIH7R/S25fWyFDJHHYzJdCZnw/CuQitUJeuh8IXbs74j8gRQD HzP6bqdCvhyNcrbr2XKXIYOqv6P7T6qXJIqDYkrEJF7TfSNw9DhcxW/LlNjPrFsJHjtf 9cTBf1izpN5sy4OwKkdqiE0bBWIXejtlWgi5iLztCC2SsyGoH+isREuFo1l/SXKDgdIC 1LTA== X-Gm-Message-State: APjAAAVvl9RUA7Br50lpHjNGogAMuk0Bx/3mCm241Kqf2d9cILySf+rj bUxNtdCL8CGtRKywU/bcDkdbw/vCtG4UwY2W20HIuCZQq/9bV+NBl+t/IIy3FPoT2/FeHPSVXt5 2auPCVFPtkYJONKfqgWdR8iXGTTU4QWKWLiidzjlh3BbJq+bnwlBRQR4b9vW5hGegfI/eZ0Mieu cMgwomHMNuQVUR3jXQ4A== X-Google-Smtp-Source: APXvYqy2M/8TP2QsliJiLmvL5XC737gW7PCZOJ+EaS4FrC9dpozSJQbHYrk7eq/R4iL3UfW6eYrA2w== X-Received: by 2002:a63:2b8e:: with SMTP id r136mr95082977pgr.216.1564840839902; Sat, 03 Aug 2019 07:00:39 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c69sm11711615pje.6.2019.08.03.07.00.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 07:00:38 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, kashyap.desai@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH 12/12] mpt3sas: Update driver version to 31.100.00.00 Date: Sat, 3 Aug 2019 09:59:57 -0400 Message-Id: <1564840797-5876-13-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1564840797-5876-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Updated driver version from 29.100.00.00 to 31.100.00.00 which is equivalent to Phase 12 OOB. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index fa5f1a6..b156d72 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -76,8 +76,8 @@ #define MPT3SAS_DRIVER_NAME "mpt3sas" #define MPT3SAS_AUTHOR "Avago Technologies " #define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver" -#define MPT3SAS_DRIVER_VERSION "29.100.00.00" -#define MPT3SAS_MAJOR_VERSION 29 +#define MPT3SAS_DRIVER_VERSION "31.100.00.00" +#define MPT3SAS_MAJOR_VERSION 31 #define MPT3SAS_MINOR_VERSION 100 #define MPT3SAS_BUILD_VERSION 0 #define MPT3SAS_RELEASE_VERSION 00