From patchwork Fri Sep 13 13:04:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144767 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F158E16C1 for ; Fri, 13 Sep 2019 13:05:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C68A82084F for ; Fri, 13 Sep 2019 13:05:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="YkDGVD2z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387523AbfIMNFE (ORCPT ); Fri, 13 Sep 2019 09:05:04 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35449 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726771AbfIMNFE (ORCPT ); Fri, 13 Sep 2019 09:05:04 -0400 Received: by mail-pl1-f196.google.com with SMTP id s17so8307162plp.2 for ; Fri, 13 Sep 2019 06:05:03 -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=m5BxlXXWVtoXchtDeVJ0hdDUs/0oB6T6ue8zThb29qU=; b=YkDGVD2zWs+j7Jlv/vKt6/PQ8BwxSK6dobOdcMq0DhNB1W4Pkd00woUQZh6v7nzxj6 FGgIowho2jdRtIktO+pcFUFO+tx3RitwjOBgx79dy6F12ufctsvRsp1d3WFfHVb3cO6v k3rlIzLos5jU/LB8LtdhfWrJ2oobNegcVMD58= 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=m5BxlXXWVtoXchtDeVJ0hdDUs/0oB6T6ue8zThb29qU=; b=meUnu/DelfyYwZO0uGI8iZlgnx2nZAXFZQaOBgGgyDwycR6qpeZvU2KxwS350z0H8a PMc8wg5EkYFsyLX4oidrJyuRXnrouy1gEBbQHcs9dzc6AUocW5JvfPAVlSgLwDI30T0x MZCosyBsvqYO69xZ78jTg/pmRuq/a5k1sOASkcJW+9UL321G4Fx7rEEg4MGCtqSTSv5z g6SlfcdPFrHzRMqtyIE44Hf+3aH3NItMlfN1jgXY1iDJCMaucxf6LapADgXvhmW/6XvI pl/nsWRjb0E4d7yh9l+RwCCtny0OB5FcCWkbozN3OorhgD3ZL5GdOsPZ0Md9KMB4hX9C qbZg== X-Gm-Message-State: APjAAAVgawbZJwwyR9i4ubkSf+299jbMqOvs514PwIblRGkyr/gJ+a9q huTKD6R5iKpAfa8+66eJk7i0ZQ== X-Google-Smtp-Source: APXvYqxupER9LD+Tt2LhgETXM3FT79jKzeovNk2AWlJBwOyGb10FHGH8DfeuSMAZ9pfKsMuewjtBpQ== X-Received: by 2002:a17:902:8bc7:: with SMTP id r7mr40842525plo.85.1568379903364; Fri, 13 Sep 2019 06:05:03 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:02 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 01/13] mpt3sas: Register trace buffer based on NVDATA settings Date: Fri, 13 Sep 2019 09:04:38 -0400 Message-Id: <1568379890-18347-2-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Currently if user has to enable the host trace buffer during driver load time then user has to load the driver with module parameter 'diag_buffer_enable' set to one. Alternatively now user can enable host trace buffer by enabling below fields in manufacture page11 in NVDATA (nvdata xml is used while building HBA firmware image), * HostTraceBufferMaxSizeKB - Maximum trace buffer size in KB that host can allocate, * HostTraceBufferMinSizeKB - Minimum trace buffer size in KB atleast host should allocate, * HostTraceBufferDecrementSizeKB - size by which host can reduce from buffer size and retry the buffer allocation when buffer allocation failed with previous calculated buffer size. So that driver will register the trace buffer automatically without any module parameter during boot time when above fields are enabled in the manufacture page11 in HBA firmware. Driver follows below algorithm for enabling the host trace buffer during driver load time, * If user has loaded the driver with module parameter 'diag_buffer_enable' set to one then driver allocates 2MB buffer and register this buffer with HBA firmware for capturing the firmware trace logs. * Else driver reads manufacture page11 data and checks whether HostTraceBufferMaxSizeKB filed is zero or not? - if HostTraceBufferMaxSizeKB is non zero then driver tries to allocate HostTraceBufferMaxSizeKB size of memory. If the buffer allocation is successfully then it will register this buffer with HBA firmware, else in a loop driver will try again by reducing the current buffer size with HostTraceBufferDecrementSizeKB size until memory allocation is successful (or) buffer size falls below HostTraceBufferMinSizeKB. if the memory allocation is successful then the buffer will be registered with the firmware. Else if the buffer size falls below the HostTraceBufferMinSizeKB then driver won't register trace buffer with HBA firmware. - if HostTraceBufferMaxSizeKB is zero then driver won't register trace buffer with HBA firmware. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.h | 9 +++-- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 71 ++++++++++++++++++++++++++++++++++-- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 + 3 files changed, 75 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index faca0a5..a501c25 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -391,9 +391,12 @@ struct Mpi2ManufacturingPage11_t { u8 Reserved6; /* 2Fh */ __le32 Reserved7[7]; /* 30h - 4Bh */ u8 NVMeAbortTO; /* 4Ch */ - u8 Reserved8; /* 4Dh */ - u16 Reserved9; /* 4Eh */ - __le32 Reserved10[4]; /* 50h - 60h */ + u8 NumPerDevEvents; /* 4Dh */ + u8 HostTraceBufferDecrementSizeKB; /* 4Eh */ + u8 HostTraceBufferFlags; /* 4Fh */ + u16 HostTraceBufferMaxSizeKB; /* 50h */ + u16 HostTraceBufferMinSizeKB; /* 52h */ + __le32 Reserved10[2]; /* 54h - 5Bh */ }; /** diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 7d69695..285edd7 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -1669,6 +1669,10 @@ void mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc, u8 bits_to_register) { struct mpt3_diag_register diag_register; + u32 ret_val; + u32 trace_buff_size = ioc->manu_pg11.HostTraceBufferMaxSizeKB<<10; + u32 min_trace_buff_size = 0; + u32 decr_trace_buff_size = 0; memset(&diag_register, 0, sizeof(struct mpt3_diag_register)); @@ -1677,10 +1681,61 @@ mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc, u8 bits_to_register) ioc->diag_trigger_master.MasterData = (MASTER_TRIGGER_FW_FAULT + MASTER_TRIGGER_ADAPTER_RESET); diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_TRACE; - /* register for 2MB buffers */ - diag_register.requested_buffer_size = 2 * (1024 * 1024); diag_register.unique_id = 0x7075900; - _ctl_diag_register_2(ioc, &diag_register); + + if (trace_buff_size != 0) { + diag_register.requested_buffer_size = trace_buff_size; + min_trace_buff_size = + ioc->manu_pg11.HostTraceBufferMinSizeKB<<10; + decr_trace_buff_size = + ioc->manu_pg11.HostTraceBufferDecrementSizeKB<<10; + + if (min_trace_buff_size > trace_buff_size) { + /* The buff size is not set correctly */ + ioc_err(ioc, + "Min Trace Buff size (%d KB) greater than Max Trace Buff size (%d KB)\n", + min_trace_buff_size>>10, + trace_buff_size>>10); + ioc_err(ioc, + "Using zero Min Trace Buff Size\n"); + min_trace_buff_size = 0; + } + + if (decr_trace_buff_size == 0) { + /* + * retry the min size if decrement + * is not available. + */ + decr_trace_buff_size = + trace_buff_size - min_trace_buff_size; + } + } else { + /* register for 2MB buffers */ + diag_register.requested_buffer_size = 2 * (1024 * 1024); + } + + do { + ret_val = _ctl_diag_register_2(ioc, &diag_register); + + if (ret_val == -ENOMEM && min_trace_buff_size && + (trace_buff_size - decr_trace_buff_size) >= + min_trace_buff_size) { + /* adjust the buffer size */ + trace_buff_size -= decr_trace_buff_size; + diag_register.requested_buffer_size = + trace_buff_size; + } else + break; + } while (true); + + if (ret_val == -ENOMEM) + ioc_err(ioc, + "Cannot allocate trace buffer memory. Last memory tried = %d KB\n", + diag_register.requested_buffer_size>>10); + else if (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] + & MPT3_DIAG_BUFFER_IS_REGISTERED) + ioc_err(ioc, "Trace buffer memory %d KB allocated\n", + diag_register.requested_buffer_size>>10); } if (bits_to_register & 2) { @@ -3130,7 +3185,15 @@ host_trace_buffer_enable_store(struct device *cdev, memset(&diag_register, 0, sizeof(struct mpt3_diag_register)); ioc_info(ioc, "posting host trace buffers\n"); diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_TRACE; - diag_register.requested_buffer_size = (1024 * 1024); + + if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0 && + ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE] != 0) { + /* post the same buffer allocated previously */ + diag_register.requested_buffer_size = + ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE]; + } else + diag_register.requested_buffer_size = (1024 * 1024); + diag_register.unique_id = 0x7075900; ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] = 0; _ctl_diag_register_2(ioc, &diag_register); diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index d0c2f8d..2504cd7 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -10194,6 +10194,8 @@ scsih_scan_start(struct Scsi_Host *shost) int rc; if (diag_buffer_enable != -1 && diag_buffer_enable != 0) mpt3sas_enable_diag_buffer(ioc, diag_buffer_enable); + else if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0) + mpt3sas_enable_diag_buffer(ioc, 1); if (disable_discovery > 0) return; From patchwork Fri Sep 13 13:04:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144769 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4623C14E5 for ; Fri, 13 Sep 2019 13:05:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2555C2084F for ; Fri, 13 Sep 2019 13:05:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="N6jIqaL7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387655AbfIMNFH (ORCPT ); Fri, 13 Sep 2019 09:05:07 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:36171 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFH (ORCPT ); Fri, 13 Sep 2019 09:05:07 -0400 Received: by mail-pg1-f195.google.com with SMTP id j191so4690249pgd.3 for ; Fri, 13 Sep 2019 06:05:05 -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=7E/8Ckfzt8adr5wGWMwUFC7mUqpfHULJuU0jKyQCS7I=; b=N6jIqaL7cKEW5JffYfpI6te8dPbfq0xwkrMlq6t0Hvn4Yj8rD08ShMeYvMcPvmoAhI ZwieyHDeNVbZuAEoXg3/EZ9m26cH5lFg+U96x3M01liTFR9XXA3dk6rp80TixGxegZUu D6LC+LAsShb9xcwm3UKZ2wJFT9zaDML2ue16I= 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=7E/8Ckfzt8adr5wGWMwUFC7mUqpfHULJuU0jKyQCS7I=; b=VFeiNhjcwbQ61KWyD8J30qUks5DNlpfPgl2RihYGyui7DtaydAH9f2IgDNqbOEfwMv SGdAYYkuqtlkYffvZsGbMTEIpoTKSbV0ISiJTrLrtbXrGjv0HgECVN7VTbwkJ9SY2zyr DjkoPflYm8gRfpHsxDRgmj/0XGNH57yezt8zjWEjkM33Gga+ix8pSDNTkhwqAY4fKPKw OfqMnTf5RQTrcrk1bB1Js/py+tIyJtt29vczUjwfcbQqm9EKdMKgu1RhaDZjQ1wSoraY oLwEvCRo8JZdvrVxYhGD899JT5/bc3K8WvuxSzh0Bng+weIlLzwgxxDoLvfMyd0whNCN uQ8A== X-Gm-Message-State: APjAAAXSK8/jHQ73HjHoTFCR2lg6mMGVhTbSsrZMtm9a6tH3mmB0sogo jZAwVL6OaDrxZRTdu6/A1vSiIQ== X-Google-Smtp-Source: APXvYqx2sBfphd7VK9U+A7gBcmzI/RwGeCBWWofhn4ORKfBNw/WvCcOif2xU3BQ5KXJIZv+X0buywA== X-Received: by 2002:aa7:96f3:: with SMTP id i19mr57076587pfq.32.1568379905501; Fri, 13 Sep 2019 06:05:05 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:05 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 02/13] mpt3sas: Display message before releasing diag buffer Date: Fri, 13 Sep 2019 09:04:39 -0400 Message-Id: <1568379890-18347-3-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Display message before releasing the diag buffer so that user knows which event caused the release of diag buffer. Releasing of diag buffer means HBA firmware stops posting the firmware logs on the registered diag buffer. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 7 +++++++ drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 285edd7..76ca416 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -466,6 +466,13 @@ void mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc) if ((ioc->diag_buffer_status[i] & MPT3_DIAG_BUFFER_IS_RELEASED)) continue; + + /* + * add a log message to indicate the release + */ + ioc_info(ioc, + "%s: Releasing the trace buffer due to adapter reset.", + __func__); mpt3sas_send_diag_release(ioc, i, &issue_reset); } } diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c index 6ac453f..8ec9bab 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c +++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c @@ -113,15 +113,21 @@ mpt3sas_process_trigger_data(struct MPT3SAS_ADAPTER *ioc, struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data) { u8 issue_reset = 0; + u32 *trig_data = (u32 *)&event_data->u.master; dTriggerDiagPrintk(ioc, ioc_info(ioc, "%s: enter\n", __func__)); /* release the diag buffer trace */ if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & MPT3_DIAG_BUFFER_IS_RELEASED) == 0) { - dTriggerDiagPrintk(ioc, - ioc_info(ioc, "%s: release trace diag buffer\n", - __func__)); + /* + * add a log message so that user knows which event caused + * the release + */ + ioc_info(ioc, + "%s: Releasing the trace buffer. Trigger_Type 0x%08x, Data[0] 0x%08x, Data[1] 0x%08x\n", + __func__, event_data->trigger_type, + trig_data[0], trig_data[1]); mpt3sas_send_diag_release(ioc, MPI2_DIAG_BUF_TYPE_TRACE, &issue_reset); } From patchwork Fri Sep 13 13:04:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144771 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4531114E5 for ; Fri, 13 Sep 2019 13:05:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 243E42084F for ; Fri, 13 Sep 2019 13:05:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="cTFoWxn3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387795AbfIMNFI (ORCPT ); Fri, 13 Sep 2019 09:05:08 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41147 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFI (ORCPT ); Fri, 13 Sep 2019 09:05:08 -0400 Received: by mail-pg1-f193.google.com with SMTP id x15so15227066pgg.8 for ; Fri, 13 Sep 2019 06:05:08 -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=uZ0ryVDhFnGzLZcrMR5qrWRgUAYTaxLSApMq9rjkF/Y=; b=cTFoWxn3J6s52d1shTziQJPn3dgAqxdUZaoORlOsQe2zk3qw22b9wEiP7J9uqyCqKl 8zXHeAmmfQI5br1IRR/LxcXsUM58/Zg2EpO/f9PLNqILgf0wDb+NudiYiRJgMrrp9T+r XtXySw6h7pZaQ1Ac22WZP5L6hhmyhmgAsF4Ls= 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=uZ0ryVDhFnGzLZcrMR5qrWRgUAYTaxLSApMq9rjkF/Y=; b=FyQB4pIWZsI5OSsQUs5PNze2poyttNdq9wVmg29Y2djwEvVdU0SFj4vClyWXzjLb33 sOLwHoww4IYmLDhvCOSYCA1QTBRK1SQvC1C3FyRIkLDANd/6sldv9wR7QIT5CTX2WeUs nC14x8cKwAWllrU7X6KZzDKp2J0umq1VhjdDVLu3TMrhA9wKdpoJvXGcFZTsEYbtza5t OcbeUYW5htOJmvG8YwWXE8KtpPCjR4bWYMypJ4SKm/E98YK2thM25IbISZbOds7TBa7F gunS2X4Jdak1bzx1C55Pg9qB+8WFsAvdF9blMekyy/lNVdJwnxLMcXfRY30k/zjLe2LO T6Ug== X-Gm-Message-State: APjAAAV9T+yMHU690HNroZxWB8Ky470mFWgcZ3hzqGamDlQmVgitxN9c QsqjIQsGvws8MFII6j8w8TguHZn0nxY= X-Google-Smtp-Source: APXvYqxqyKfx3pcbt8lvGKqRc3SQKPByaFBOlKooaZzBXG35f0OLt5+d3PRchnmxQN1IF/rSER3HtA== X-Received: by 2002:a63:a011:: with SMTP id r17mr44190989pge.219.1568379907852; Fri, 13 Sep 2019 06:05:07 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:07 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 03/13] mpt3sas: Fix clear pending bit in ioctl status Date: Fri, 13 Sep 2019 09:04:40 -0400 Message-Id: <1568379890-18347-4-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Issue: when user issues diag register command from application with required size and if driver unable to allocate the memory then it will fail the register command. While failing the register command currently driver is not clearing MPT3_CMD_PENDING bit in ctl_cmds.status variable which was set before trying to allocate the memory. As this bit is set so subsequent register command will be failed with BUSY status even when user wants to register the trace buffer will less memory. Fix: Clear MPT3_CMD_PENDING bit in ctl_cmds.status before returning the diag register command with no memory status. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 76ca416..a195cae 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -1591,7 +1591,8 @@ _ctl_diag_register_2(struct MPT3SAS_ADAPTER *ioc, ioc_err(ioc, "%s: failed allocating memory for diag buffers, requested size(%d)\n", __func__, request_data_sz); mpt3sas_base_free_smid(ioc, smid); - return -ENOMEM; + rc = -ENOMEM; + goto out; } ioc->diag_buffer[buffer_type] = request_data; ioc->diag_buffer_sz[buffer_type] = request_data_sz; From patchwork Fri Sep 13 13:04:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50D0316C1 for ; Fri, 13 Sep 2019 13:05:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F3C02084F for ; Fri, 13 Sep 2019 13:05:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="cxzo3ib9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387841AbfIMNFK (ORCPT ); Fri, 13 Sep 2019 09:05:10 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35464 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFK (ORCPT ); Fri, 13 Sep 2019 09:05:10 -0400 Received: by mail-pf1-f196.google.com with SMTP id 205so18053033pfw.2 for ; Fri, 13 Sep 2019 06:05:10 -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=CRkb4M6GPrEjWRWFRgB6VomGtlcUoHIQDhVlL7C0iJA=; b=cxzo3ib9DZu91rUuFP6TsWXwGXEKxY4Ha+vkwb1nSqdcp7sQbEYv7z5n7l/F16x1rs LcgnwpEhAd/Gf15yHGoQpND3px6NfncJhhbO4clS3A6xqT9WqySm4SfvYyUN6Q38Jv0k paV/Oh7zLfWmA9JsJocI5xhoSYQp3kVQIv3PY= 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=CRkb4M6GPrEjWRWFRgB6VomGtlcUoHIQDhVlL7C0iJA=; b=Jmkdg+oJZWmDZVNLOiIUTJDSit8f2jFKD3hvY8fot8CdBNh17p5FhBBllC4rZsxQpu //5mKBZgW+Vp5WBcTQdFF0OG0uEx2de2EH8zi720x5aJX3rFVFEudJ79AKuldqXQpMIA Bte0wTZxOBiudJPkUTdIBamjbd1B/4/PcWB4utjZjbLl8z/Qvp1hhKgcQHaY+7Ez1wnJ 8Su7Vzt4bTd8Rst8FYA0+7I4ectQBpMGDnfPimjyMoRIHLbpyTTZ3NTRRKI1W6pT3ipo OqCsxWMaSHC+GAmtPr4ORra8IqCOtvofSVWWJ5AaVylsaBLy2oeICNXzQXGqHjiBXOTB 8xlA== X-Gm-Message-State: APjAAAWMDqkDT5mShp3OGC+VzYZmAeJ8DXJ0UDjbeJ20AU+JawCFPWb2 AtTOO141YsI6+zkMx73kSt/v+w== X-Google-Smtp-Source: APXvYqw/hnsnE/GBTVjw1QyVjGdnM0M3IOJV/nPqUWyVl7j/QleBfLscDgs3iI4dWyuhkbgOWHHvtQ== X-Received: by 2002:a17:90a:804c:: with SMTP id e12mr4831309pjw.3.1568379910011; Fri, 13 Sep 2019 06:05:10 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:09 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 04/13] mpt3sas: Free diag buffer without any status check Date: Fri, 13 Sep 2019 09:04:41 -0400 Message-Id: <1568379890-18347-5-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Issue: Memory leak can happen when diag buffer is released but not unregistered(where buffer is deallocated) by the user. since during module unload time driver is not deallocating the buffer if the buffer is in released state. Fix: Deallocate the diag buffer during module unload time without any diag buffer status checks. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index a195cae..9b37a32 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -3773,12 +3773,6 @@ mpt3sas_ctl_exit(ushort hbas_to_enumerate) for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { if (!ioc->diag_buffer[i]) continue; - if (!(ioc->diag_buffer_status[i] & - MPT3_DIAG_BUFFER_IS_REGISTERED)) - continue; - if ((ioc->diag_buffer_status[i] & - MPT3_DIAG_BUFFER_IS_RELEASED)) - continue; dma_free_coherent(&ioc->pdev->dev, ioc->diag_buffer_sz[i], ioc->diag_buffer[i], From patchwork Fri Sep 13 13:04:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144775 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FD1316C1 for ; Fri, 13 Sep 2019 13:05:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 74DCD2084F for ; Fri, 13 Sep 2019 13:05:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="DAiA/oRM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387950AbfIMNFN (ORCPT ); Fri, 13 Sep 2019 09:05:13 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38495 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFN (ORCPT ); Fri, 13 Sep 2019 09:05:13 -0400 Received: by mail-pl1-f193.google.com with SMTP id w10so2119462plq.5 for ; Fri, 13 Sep 2019 06:05: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=FfSMgZ+bE6w5/hLtuP+nJc4ywC8zx9fcUfA8hJZsl+0=; b=DAiA/oRMaBOkoYljXYiPvnA/36bTIg20lAy7rk2ouYFLlYse6qaMkvl2fMXpUr6gMv fO3g+dCXEOUxB/7H/DgMwEdT0yOD6DveURIja40M2vTkRKxRINyzgZp6/e14IU8W9EPd ob4Vds0ra7TqmTZQkbUUIf3DdV0yL1YZHvrws= 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=FfSMgZ+bE6w5/hLtuP+nJc4ywC8zx9fcUfA8hJZsl+0=; b=KGQAc9JIZUBy3bGFUCzqlX+hRfiByuVhaPiPJxPaZtsLz4MoUse1ebNgABRqOMyaPu WmRzwz/nsckjcyKwKOCXvipCdx+R+00901CyR2UkGOMVc0S6UgFDj6s6EjamG0iYPpZ2 veS86deXEAYEPpfVSi2Uxb3p7yMnWLxHzrY0AkorcCxNQSVw9/1wQ6LZaj4hB1zD5fJY iuRvTzPK5vuk9TS3kdKfOcJ8XW49vGD9aKzUv2jBaI1A88CAnTBnSn3pTnlA6+kW+7x3 85ybmYtvMX0VFbinCiCUr1vXd5W2kvjOui7nWfCa9Fk7E0DfHE5Xx4tUKEry+fbT5LWF LwJw== X-Gm-Message-State: APjAAAVq1WqhV+kYuPrsq/PPJ/Sh7qZ9yWN1442qo8mHm5LSJNeQFa69 al1bpva7aYS8OZfOtoT01z7FBQ== X-Google-Smtp-Source: APXvYqzUAlNf9XUbifWbyU4eQBMd05qd62MNvnXSP1HkDCVZVa6ngsLkTmYGbZK8tnUI00UoAsX1ew== X-Received: by 2002:a17:902:7085:: with SMTP id z5mr49462723plk.102.1568379912167; Fri, 13 Sep 2019 06:05:12 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:11 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 05/13] mpt3sas: Maintain owner of buffer through UniqueID Date: Fri, 13 Sep 2019 09:04:42 -0400 Message-Id: <1568379890-18347-6-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Problem statement: Application A has registered a diag buffer and looking for particular event to happen to release & read the trace buffer. Meanwhile application B has unregister the diag buffer and now Application A can't get the required diag buffer. So proper diag buffer ownership is missing. Improvement: Each application has to maintain it's own Unique ID, Now driver has to save the Application's UniqueID for each diag buffer type when diag buffer is registered. And driver has to allow 'release', 'read' & 'unregister' diag commands only if application's UniqueID matches with saved UniqueID for the corresponding diag buffer type. When diag buffer is registered by the driver then the UniqueID saved by the driver is "BRCM" (i.e. 0x4252434D) for SAS3 and above generations HBA devices. For SAS2 HBA's driver keeps the legacy UniqueID 0x07075900 for maintaining compatibility with the legacy SAS2 application and this improvement won't be applicable for SAS2 HBA devices. Any application can own the buffer registered by the driver by sending diag register request to driver with same buffer type and size (Application can get the buffer size by sending 'query' command). Then driver changes the ownership of the buffer by saving application's UniqueID for that corresponding buffer type. Also application can re-register the diag buffer with same size without un-registering it, but diag buffer should be released before re-registering it. By allowing this, driver no need to deallocate and allocate a new buffer for re-register command, same buffer can be re-used. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 114 ++++++++++++++++++++++++++++++++++--- drivers/scsi/mpt3sas/mpt3sas_ctl.h | 8 +++ 2 files changed, 113 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 9b37a32..a14ff88 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -1491,6 +1491,26 @@ _ctl_diag_capability(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type) return rc; } +/** + * _ctl_diag_get_bufftype - return diag buffer type + * either TRACE, SNAPSHOT, or EXTENDED + * @ioc: per adapter object + * @unique_id: specifies the unique_id for the buffer + * + * returns MPT3_DIAG_UID_NOT_FOUND if the id not found + */ +static u8 +_ctl_diag_get_bufftype(struct MPT3SAS_ADAPTER *ioc, u32 unique_id) +{ + u8 index; + + for (index = 0; index < MPI2_DIAG_BUF_TYPE_COUNT; index++) { + if (ioc->unique_id[index] == unique_id) + return index; + } + + return MPT3_DIAG_UID_NOT_FOUND; +} /** * _ctl_diag_register_2 - wrapper for registering diag buffer support @@ -1538,11 +1558,65 @@ _ctl_diag_register_2(struct MPT3SAS_ADAPTER *ioc, return -EPERM; } + if (diag_register->unique_id == 0) { + ioc_err(ioc, + "%s: Invalid UID(0x%08x), buffer_type(0x%02x)\n", __func__, + diag_register->unique_id, buffer_type); + return -EINVAL; + } + if (ioc->diag_buffer_status[buffer_type] & MPT3_DIAG_BUFFER_IS_REGISTERED) { - ioc_err(ioc, "%s: already has a registered buffer for buffer_type(0x%02x)\n", - __func__, buffer_type); - return -EINVAL; + /* + * If driver posts buffer initially, then an application wants + * to Register that buffer (own it) without Releasing first, + * the application Register command MUST have the same buffer + * type and size in the Register command (obtained from the + * Query command). Otherwise that Register command will be + * failed. If the application has released the buffer but wants + * to re-register it, it should be allowed as long as the + * Unique-Id/Size match. + */ + + if (ioc->unique_id[buffer_type] == MPT3DIAGBUFFUNIQUEID && + ioc->diag_buffer_sz[buffer_type] == + diag_register->requested_buffer_size) { + + if (!(ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_RELEASED)) { + dctlprintk(ioc, ioc_info(ioc, + "%s: diag_buffer (%d) ownership changed. old-ID(0x%08x), new-ID(0x%08x)\n", + __func__, buffer_type, + ioc->unique_id[buffer_type], + diag_register->unique_id)); + + /* + * Application wants to own the buffer with + * the same size. + */ + ioc->unique_id[buffer_type] = + diag_register->unique_id; + rc = 0; /* success */ + goto out; + } + } else if (ioc->unique_id[buffer_type] != + MPT3DIAGBUFFUNIQUEID) { + if (ioc->unique_id[buffer_type] != + diag_register->unique_id || + ioc->diag_buffer_sz[buffer_type] != + diag_register->requested_buffer_size || + !(ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_RELEASED)) { + ioc_err(ioc, + "%s: already has a registered buffer for buffer_type(0x%02x)\n", + __func__, buffer_type); + return -EINVAL; + } + } else { + ioc_err(ioc, "%s: already has a registered buffer for buffer_type(0x%02x)\n", + __func__, buffer_type); + return -EINVAL; + } } if (diag_register->requested_buffer_size % 4) { @@ -1689,7 +1763,9 @@ mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc, u8 bits_to_register) ioc->diag_trigger_master.MasterData = (MASTER_TRIGGER_FW_FAULT + MASTER_TRIGGER_ADAPTER_RESET); diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_TRACE; - diag_register.unique_id = 0x7075900; + diag_register.unique_id = + (ioc->hba_mpi_version_belonged == MPI2_VERSION) ? + (MPT2DIAGBUFFUNIQUEID):(MPT3DIAGBUFFUNIQUEID); if (trace_buff_size != 0) { diag_register.requested_buffer_size = trace_buff_size; @@ -1815,7 +1891,13 @@ _ctl_diag_unregister(struct MPT3SAS_ADAPTER *ioc, void __user *arg) dctlprintk(ioc, ioc_info(ioc, "%s\n", __func__)); - buffer_type = karg.unique_id & 0x000000ff; + buffer_type = _ctl_diag_get_bufftype(ioc, karg.unique_id); + if (buffer_type == MPT3_DIAG_UID_NOT_FOUND) { + ioc_err(ioc, "%s: buffer with unique_id(0x%08x) not found\n", + __func__, karg.unique_id); + return -EINVAL; + } + if (!_ctl_diag_capability(ioc, buffer_type)) { ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n", __func__, buffer_type); @@ -1899,7 +1981,7 @@ _ctl_diag_query(struct MPT3SAS_ADAPTER *ioc, void __user *arg) return -EINVAL; } - if (karg.unique_id & 0xffffff00) { + if (karg.unique_id) { if (karg.unique_id != ioc->unique_id[buffer_type]) { ioc_err(ioc, "%s: unique_id(0x%08x) is not registered\n", __func__, karg.unique_id); @@ -2065,7 +2147,13 @@ _ctl_diag_release(struct MPT3SAS_ADAPTER *ioc, void __user *arg) dctlprintk(ioc, ioc_info(ioc, "%s\n", __func__)); - buffer_type = karg.unique_id & 0x000000ff; + buffer_type = _ctl_diag_get_bufftype(ioc, karg.unique_id); + if (buffer_type == MPT3_DIAG_UID_NOT_FOUND) { + ioc_err(ioc, "%s: buffer with unique_id(0x%08x) not found\n", + __func__, karg.unique_id); + return -EINVAL; + } + if (!_ctl_diag_capability(ioc, buffer_type)) { ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n", __func__, buffer_type); @@ -2149,7 +2237,13 @@ _ctl_diag_read_buffer(struct MPT3SAS_ADAPTER *ioc, void __user *arg) dctlprintk(ioc, ioc_info(ioc, "%s\n", __func__)); - buffer_type = karg.unique_id & 0x000000ff; + buffer_type = _ctl_diag_get_bufftype(ioc, karg.unique_id); + if (buffer_type == MPT3_DIAG_UID_NOT_FOUND) { + ioc_err(ioc, "%s: buffer with unique_id(0x%08x) not found\n", + __func__, karg.unique_id); + return -EINVAL; + } + if (!_ctl_diag_capability(ioc, buffer_type)) { ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n", __func__, buffer_type); @@ -3202,7 +3296,9 @@ host_trace_buffer_enable_store(struct device *cdev, } else diag_register.requested_buffer_size = (1024 * 1024); - diag_register.unique_id = 0x7075900; + diag_register.unique_id = + (ioc->hba_mpi_version_belonged == MPI2_VERSION) ? + (MPT2DIAGBUFFUNIQUEID):(MPT3DIAGBUFFUNIQUEID); ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] = 0; _ctl_diag_register_2(ioc, &diag_register); } else if (!strcmp(str, "release")) { diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h b/drivers/scsi/mpt3sas/mpt3sas_ctl.h index 18b46fa..d1a6ab1 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.h +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h @@ -95,6 +95,14 @@ #define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \ struct mpt3_diag_read_buffer) +/* Trace Buffer default UniqueId */ +#define MPT2DIAGBUFFUNIQUEID (0x07075900) +#define MPT3DIAGBUFFUNIQUEID (0x4252434D) + +/* UID not found */ +#define MPT3_DIAG_UID_NOT_FOUND (0xFF) + + /** * struct mpt3_ioctl_header - main header structure * @ioc_number - IOC unit number From patchwork Fri Sep 13 13:04:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144777 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 196E014E5 for ; Fri, 13 Sep 2019 13:05:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECC7D2084F for ; Fri, 13 Sep 2019 13:05:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="G6O6PB4H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388092AbfIMNFP (ORCPT ); Fri, 13 Sep 2019 09:05:15 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38836 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFP (ORCPT ); Fri, 13 Sep 2019 09:05:15 -0400 Received: by mail-pf1-f193.google.com with SMTP id h195so18052548pfe.5 for ; Fri, 13 Sep 2019 06:05: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=WB/QzWn0vqzOOZqEIpVDtJkPkOSan2Oxa3T5EQcsz20=; b=G6O6PB4HPMetl2GNzCONq56MyAFJ7dPNhqpfzH9t0O7we3ZOWQ36ctT02O0ctxMiJg cnr+oakXysXk9QRjBsE9xRtTH5rVUDYrXLRSumpSHdMnnUdiwJXlVodzsXHPp3C/DP4L LTm5+Y4EkAqeKdrSbTZYLSleJ7BwOM92hSzts= 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=WB/QzWn0vqzOOZqEIpVDtJkPkOSan2Oxa3T5EQcsz20=; b=duqIfiynNE/rFPYOhjnubWxfhzCzcUpW+gP753lIUSfoirZWd9GFBVOaFelXjfoq0j T1ySphxqFZZpOd4qFH3hMKegq2P2zdZ93RY/nIJKKc0kKgmXeQOVV1EKU4fVGFnEYlgI ZVsnOgWBBN360/B8XDlzEsalj9BmYUljV/TThQZ2kp2pf0clJHD4jhQ/IY+HAVxoSdoS qsT63xih6sCtsYs4RsZfHJ/jZAtQ8eNP1ICLtRO9NmsMltp1btaG+06gG/Q49y7hNaeV 1d6T4BS4fxPsemoi7vZKgyZ09LzeqCoT/5yXIrRn4Lwurilnctc+m2+mI2xAIrhjHKP9 O0iQ== X-Gm-Message-State: APjAAAWE7n5bIw76dRoeyNUjrSA+fdTN5DV11AAIUap++xFpTxO4S5Ki 37tIh184qoF7ok7SSY86tXySIA== X-Google-Smtp-Source: APXvYqyLlOe3kdwSwqL4VYtKgSGH1ghY8dwjqwR1tRQaefgSNNUJAbJLYFQJifCM4l9rj4V4/3HKGg== X-Received: by 2002:a63:550e:: with SMTP id j14mr38888204pgb.302.1568379914644; Fri, 13 Sep 2019 06:05:14 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:13 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 06/13] mpt3sas: clear release bit when buffer reregistered Date: Fri, 13 Sep 2019 09:04:43 -0400 Message-Id: <1568379890-18347-7-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Clear MPT3_DIAG_BUFFER_IS_RELEASED bit once diag buffer is re-registered after reading the buffer, else driver won't release the buffer and return the ' diag release' command with -EINVAL status saying that buffer is already released. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index a14ff88..504e035 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -2367,6 +2367,8 @@ _ctl_diag_read_buffer(struct MPT3SAS_ADAPTER *ioc, void __user *arg) if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { ioc->diag_buffer_status[buffer_type] |= MPT3_DIAG_BUFFER_IS_REGISTERED; + ioc->diag_buffer_status[buffer_type] &= + ~MPT3_DIAG_BUFFER_IS_RELEASED; dctlprintk(ioc, ioc_info(ioc, "%s: success\n", __func__)); } else { ioc_info(ioc, "%s: ioc_status(0x%04x) log_info(0x%08x)\n", From patchwork Fri Sep 13 13:04:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144779 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A91916C1 for ; Fri, 13 Sep 2019 13:05:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4FA20206BB for ; Fri, 13 Sep 2019 13:05:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="F0K3fw0B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388096AbfIMNFS (ORCPT ); Fri, 13 Sep 2019 09:05:18 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45759 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFR (ORCPT ); Fri, 13 Sep 2019 09:05:17 -0400 Received: by mail-pf1-f196.google.com with SMTP id y72so18006202pfb.12 for ; Fri, 13 Sep 2019 06:05: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=asrLyvq7JzpY38ezcQ9IkaJ3l7Q0BduBVN6nErk1Ge4=; b=F0K3fw0BkFXZnRoT543BIokt6H9g0qNBNu8+o1RHD6iFpYkvErlIZvtnx1GceoZyzj zGxvDl3R76IHEVNGzQvGIncfDuwQACcTJawL0j5DLT8zK8agn8+FQiCBCN1iyM08C+jG aq2a3gqPHxEOPIITkLFGhbxzxZC1+CcFIevMI= 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=asrLyvq7JzpY38ezcQ9IkaJ3l7Q0BduBVN6nErk1Ge4=; b=HylHYhwQkH9HtYY6Kv4g4rWMjWtFJxHQ7YB0MymipzbgeSsfRffGHrWp0ULe6sImQJ 2lXpWXRqW4JWPWuZmsyp2Jmy9Gj2DJf836n9grQEKvzq8hJ2bS66IAkaDoar69pCLpXW cxaHNj7AKVTn8hQUCoEkMgRVWmWEvHye+amxNQEld5vCaDgx4XaDQ1IiKprmQQJyjc2k pjXvubEvRtKsG3qMZj+9BJqWLm8uaVZqsnZtWtBLmIAEZ2N3CiYmKjxaoVOK5ZqjVfcV xG0qocYDJO8njl49n0WY+Vm8ADS+KQt20EtJQOykpLEKPoSKz4+dCpXQOg/QB3ypbH/4 fqwg== X-Gm-Message-State: APjAAAXYTdjoWMVRyHT2BYY1wLo/jeNusD5GZfyCHXTaGIY7F6moOogz /ZZeyA427G7Wy663R2hSD67FqA== X-Google-Smtp-Source: APXvYqwtiHcBJrXFXL+pNrxBV6Iet/+wOcoG2bwn94tqwAm/XEzDUfnYjdYk3EKAbGtbzbpt0bjQYA== X-Received: by 2002:a65:4c4d:: with SMTP id l13mr42600042pgr.156.1568379916842; Fri, 13 Sep 2019 06:05:16 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:16 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 07/13] mpt3sas: Reuse diag buffer allocated at load time Date: Fri, 13 Sep 2019 09:04:44 -0400 Message-Id: <1568379890-18347-8-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The diag buffer which is allocated during driver load time or through sysfs parameter is marked as driver allocated diag buffer. MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED bit will be set for this buffer. This buffer won't be de-allocated even when application issues unregister command, driver just clear's the registered status bit. Same buffer will be reused while re-registering the same diag buffer type by any application. While re-registering the same diag buffer type application has to register with the same size that the buffer was allocated during driver load time. This buffer size can be read by the application by issuing diag 'query' command. This always make sure that the memory is available for applications for collecting the firmware logs. Only thing is that this won't allow the application to re-register the diag buffer with different size, but the buffer size which is allocated during driver load time will be enough for most of the cases for collecting the firmware logs. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.h | 1 + drivers/scsi/mpt3sas/mpt3sas_ctl.c | 88 ++++++++++++++++++++++++++++--------- drivers/scsi/mpt3sas/mpt3sas_ctl.h | 1 + 3 files changed, 69 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index a501c25..eaeb71f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -303,6 +303,7 @@ struct mpt3sas_nvme_cmd { #define MPT3_DIAG_BUFFER_IS_REGISTERED (0x01) #define MPT3_DIAG_BUFFER_IS_RELEASED (0x02) #define MPT3_DIAG_BUFFER_IS_DIAG_RESET (0x04) +#define MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED (0x08) /* * HP HBA branding diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 504e035..b5492f1 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -1617,6 +1617,19 @@ _ctl_diag_register_2(struct MPT3SAS_ADAPTER *ioc, __func__, buffer_type); return -EINVAL; } + } else if (ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED) { + + if (ioc->unique_id[buffer_type] != MPT3DIAGBUFFUNIQUEID || + ioc->diag_buffer_sz[buffer_type] != + diag_register->requested_buffer_size) { + + ioc_err(ioc, + "%s: already a buffer is allocated for buffer_type(0x%02x) of size %d bytes, so please try registering again with same size\n", + __func__, buffer_type, + ioc->diag_buffer_sz[buffer_type]); + return -EINVAL; + } } if (diag_register->requested_buffer_size % 4) { @@ -1641,7 +1654,8 @@ _ctl_diag_register_2(struct MPT3SAS_ADAPTER *ioc, request_data = ioc->diag_buffer[buffer_type]; request_data_sz = diag_register->requested_buffer_size; ioc->unique_id[buffer_type] = diag_register->unique_id; - ioc->diag_buffer_status[buffer_type] = 0; + ioc->diag_buffer_status[buffer_type] &= + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED; memcpy(ioc->product_specific[buffer_type], diag_register->product_specific, MPT3_PRODUCT_SPECIFIC_DWORDS); ioc->diagnostic_flags[buffer_type] = diag_register->diagnostic_flags; @@ -1731,9 +1745,12 @@ _ctl_diag_register_2(struct MPT3SAS_ADAPTER *ioc, out: - if (rc && request_data) + if (rc && request_data) { dma_free_coherent(&ioc->pdev->dev, request_data_sz, request_data, request_data_dma); + ioc->diag_buffer_status[buffer_type] &= + ~MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED; + } ioc->ctl_cmds.status = MPT3_CMD_NOT_USED; return rc; @@ -1817,9 +1834,14 @@ mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc, u8 bits_to_register) "Cannot allocate trace buffer memory. Last memory tried = %d KB\n", diag_register.requested_buffer_size>>10); else if (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] - & MPT3_DIAG_BUFFER_IS_REGISTERED) + & MPT3_DIAG_BUFFER_IS_REGISTERED) { ioc_err(ioc, "Trace buffer memory %d KB allocated\n", diag_register.requested_buffer_size>>10); + if (ioc->hba_mpi_version_belonged != MPI2_VERSION) + ioc->diag_buffer_status[ + MPI2_DIAG_BUF_TYPE_TRACE] |= + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED; + } } if (bits_to_register & 2) { @@ -1930,12 +1952,19 @@ _ctl_diag_unregister(struct MPT3SAS_ADAPTER *ioc, void __user *arg) return -ENOMEM; } - request_data_sz = ioc->diag_buffer_sz[buffer_type]; - request_data_dma = ioc->diag_buffer_dma[buffer_type]; - dma_free_coherent(&ioc->pdev->dev, request_data_sz, - request_data, request_data_dma); - ioc->diag_buffer[buffer_type] = NULL; - ioc->diag_buffer_status[buffer_type] = 0; + if (ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED) { + ioc->unique_id[buffer_type] = MPT3DIAGBUFFUNIQUEID; + ioc->diag_buffer_status[buffer_type] &= + ~MPT3_DIAG_BUFFER_IS_REGISTERED; + } else { + request_data_sz = ioc->diag_buffer_sz[buffer_type]; + request_data_dma = ioc->diag_buffer_dma[buffer_type]; + dma_free_coherent(&ioc->pdev->dev, request_data_sz, + request_data, request_data_dma); + ioc->diag_buffer[buffer_type] = NULL; + ioc->diag_buffer_status[buffer_type] = 0; + } return 0; } @@ -1974,11 +2003,14 @@ _ctl_diag_query(struct MPT3SAS_ADAPTER *ioc, void __user *arg) return -EPERM; } - if ((ioc->diag_buffer_status[buffer_type] & - MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) { - ioc_err(ioc, "%s: buffer_type(0x%02x) is not registered\n", - __func__, buffer_type); - return -EINVAL; + if (!(ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED)) { + if ((ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) { + ioc_err(ioc, "%s: buffer_type(0x%02x) is not registered\n", + __func__, buffer_type); + return -EINVAL; + } } if (karg.unique_id) { @@ -1996,13 +2028,17 @@ _ctl_diag_query(struct MPT3SAS_ADAPTER *ioc, void __user *arg) return -ENOMEM; } - if (ioc->diag_buffer_status[buffer_type] & MPT3_DIAG_BUFFER_IS_RELEASED) - karg.application_flags = (MPT3_APP_FLAGS_APP_OWNED | - MPT3_APP_FLAGS_BUFFER_VALID); - else - karg.application_flags = (MPT3_APP_FLAGS_APP_OWNED | - MPT3_APP_FLAGS_BUFFER_VALID | - MPT3_APP_FLAGS_FW_BUFFER_ACCESS); + if ((ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_REGISTERED)) + karg.application_flags |= MPT3_APP_FLAGS_BUFFER_VALID; + + if (!(ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_RELEASED)) + karg.application_flags |= MPT3_APP_FLAGS_FW_BUFFER_ACCESS; + + if (!(ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED)) + karg.application_flags |= MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC; for (i = 0; i < MPT3_PRODUCT_SPECIFIC_DWORDS; i++) karg.product_specific[i] = @@ -3303,6 +3339,16 @@ host_trace_buffer_enable_store(struct device *cdev, (MPT2DIAGBUFFUNIQUEID):(MPT3DIAGBUFFUNIQUEID); ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] = 0; _ctl_diag_register_2(ioc, &diag_register); + if (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & + MPT3_DIAG_BUFFER_IS_REGISTERED) { + ioc_info(ioc, + "Trace buffer %d KB allocated through sysfs\n", + diag_register.requested_buffer_size>>10); + if (ioc->hba_mpi_version_belonged != MPI2_VERSION) + ioc->diag_buffer_status[ + MPI2_DIAG_BUF_TYPE_TRACE] |= + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED; + } } else if (!strcmp(str, "release")) { /* exit out if host buffers are already released */ if (!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h b/drivers/scsi/mpt3sas/mpt3sas_ctl.h index d1a6ab1..0f7aa4d 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.h +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h @@ -318,6 +318,7 @@ struct mpt3_ioctl_btdh_mapping { #define MPT3_APP_FLAGS_APP_OWNED (0x0001) #define MPT3_APP_FLAGS_BUFFER_VALID (0x0002) #define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004) +#define MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC (0x0008) /* flags for mpt3_diag_read_buffer */ #define MPT3_FLAGS_REREGISTER (0x0001) From patchwork Fri Sep 13 13:04:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144781 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADA2A16C1 for ; Fri, 13 Sep 2019 13:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D22D2084F for ; Fri, 13 Sep 2019 13:05:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="f3scPEko" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388130AbfIMNFU (ORCPT ); Fri, 13 Sep 2019 09:05:20 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40212 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFU (ORCPT ); Fri, 13 Sep 2019 09:05:20 -0400 Received: by mail-pg1-f193.google.com with SMTP id w10so15241142pgj.7 for ; Fri, 13 Sep 2019 06:05:19 -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=Dh9NmDmP8haPBL7ZkqQvAf4+1d98JV3KSNHC9waDqmY=; b=f3scPEkoutxC5VWfGb1/lgzFjaN9m01ceYE5X3jVA74MTnr1Qu1TCEMMQiu6rth7Gw Vjq7VjImf5/cBHTW3E4Nt4B9Eubn6oKQ0qsqDkXD1caA10R94Yh1SlnaumaDuahsJwGC uApFgp/RvrlN6fNl/N9vv+/bxtliWeSFVPxMI= 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=Dh9NmDmP8haPBL7ZkqQvAf4+1d98JV3KSNHC9waDqmY=; b=Q+0FPfq6r72dBbLXUwb6+hpCN6rbMm2l+aTckCVVF+aa5l0S+JhQ3ag35vNCbdgCkB WGi6W6wQHYp1RkYa7g2t1dGmSd9OuzKy8lgTB9oSdn/ygFSnB9zgxQj5n/AewNzWXIiM FNZa+3nZ4cFxaZy7aE7U3jsmDFTtb5nSDMfeZ9nZLt85+6Oj7gTC22XpWP+Tfcqh0M1u aQgma/7NyfDCWTVxQDCKZPtJt6FBB/+PdpsKvNWyt3JnloHkihRdH0EbVl8VG0rMNl4D 7yTSkxOaqMmcpUTyDnfGLm01LYlZQfvh+5oMNg79mbPetGG3RR6IyrZ3T2rshkrgTt4d gckA== X-Gm-Message-State: APjAAAXE0avA4xxqNzLnyC5b09GRlLQf7qQaec9xWqezo0GxsyzNh9Wa 4wWwGePJ6N4vxnsCHNG4ykDBUg== X-Google-Smtp-Source: APXvYqxUCqk8AkxvInDH3DAknxjZkJIZnsbO/gwkrbsKiaVJkBH2Y31lHa/OepLEXVLX0XtDlmVSWQ== X-Received: by 2002:a62:d4:: with SMTP id 203mr55334548pfa.210.1568379919054; Fri, 13 Sep 2019 06:05:19 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:18 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 08/13] mpt3sas: Add app owned flag support for diag buffer Date: Fri, 13 Sep 2019 09:04:45 -0400 Message-Id: <1568379890-18347-9-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new status flag named MPT3_DIAG_BUFFER_IS_APP_OWNED and it will set whenever application registers the diag buffer & it will be cleared when application unregisters the buffer. When this flag is enabled and if application issues diag buffer register command without releasing the buffer then register command will be failed with -EINVAL status by saying that this buffer is already registered by the application. When user issues a trace buffer register command through sysfs parameter and if trace buffer is in released stated but not yet unregistered by the application which was owning it then driver will unregister the buffer by itself and freshly registers the 1MB sized trace buffer with the HBA firmware. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.h | 1 + drivers/scsi/mpt3sas/mpt3sas_ctl.c | 43 ++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index eaeb71f..91f6636 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -304,6 +304,7 @@ struct mpt3sas_nvme_cmd { #define MPT3_DIAG_BUFFER_IS_RELEASED (0x02) #define MPT3_DIAG_BUFFER_IS_DIAG_RESET (0x04) #define MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED (0x08) +#define MPT3_DIAG_BUFFER_IS_APP_OWNED (0x10) /* * HP HBA branding diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index b5492f1..62e878d 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -1565,6 +1565,16 @@ _ctl_diag_register_2(struct MPT3SAS_ADAPTER *ioc, return -EINVAL; } + if ((ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_APP_OWNED) && + !(ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_RELEASED)) { + ioc_err(ioc, + "%s: buffer_type(0x%02x) is already registered by application with UID(0x%08x)\n", + __func__, buffer_type, ioc->unique_id[buffer_type]); + return -EINVAL; + } + if (ioc->diag_buffer_status[buffer_type] & MPT3_DIAG_BUFFER_IS_REGISTERED) { /* @@ -1884,6 +1894,12 @@ _ctl_diag_register(struct MPT3SAS_ADAPTER *ioc, void __user *arg) } rc = _ctl_diag_register_2(ioc, &karg); + + if (!rc && (ioc->diag_buffer_status[karg.buffer_type] & + MPT3_DIAG_BUFFER_IS_REGISTERED)) + ioc->diag_buffer_status[karg.buffer_type] |= + MPT3_DIAG_BUFFER_IS_APP_OWNED; + return rc; } @@ -1956,6 +1972,8 @@ _ctl_diag_unregister(struct MPT3SAS_ADAPTER *ioc, void __user *arg) MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED) { ioc->unique_id[buffer_type] = MPT3DIAGBUFFUNIQUEID; ioc->diag_buffer_status[buffer_type] &= + ~MPT3_DIAG_BUFFER_IS_APP_OWNED; + ioc->diag_buffer_status[buffer_type] &= ~MPT3_DIAG_BUFFER_IS_REGISTERED; } else { request_data_sz = ioc->diag_buffer_sz[buffer_type]; @@ -2040,6 +2058,10 @@ _ctl_diag_query(struct MPT3SAS_ADAPTER *ioc, void __user *arg) MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED)) karg.application_flags |= MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC; + if ((ioc->diag_buffer_status[buffer_type] & + MPT3_DIAG_BUFFER_IS_APP_OWNED)) + karg.application_flags |= MPT3_APP_FLAGS_APP_OWNED; + for (i = 0; i < MPT3_PRODUCT_SPECIFIC_DWORDS; i++) karg.product_specific[i] = ioc->product_specific[buffer_type][i]; @@ -3331,8 +3353,27 @@ host_trace_buffer_enable_store(struct device *cdev, /* post the same buffer allocated previously */ diag_register.requested_buffer_size = ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE]; - } else + } else { + /* + * Free the diag buffer memory which was previously + * allocated by an application. + */ + if ((ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE] != 0) + && + (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & + MPT3_DIAG_BUFFER_IS_APP_OWNED)) { + pci_free_consistent(ioc->pdev, + ioc->diag_buffer_sz[ + MPI2_DIAG_BUF_TYPE_TRACE], + ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE], + ioc->diag_buffer_dma[ + MPI2_DIAG_BUF_TYPE_TRACE]); + ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE] = + NULL; + } + diag_register.requested_buffer_size = (1024 * 1024); + } diag_register.unique_id = (ioc->hba_mpi_version_belonged == MPI2_VERSION) ? From patchwork Fri Sep 13 13:04:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144783 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90A5714E5 for ; Fri, 13 Sep 2019 13:05:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6FF422084F for ; Fri, 13 Sep 2019 13:05:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="I3pTeEhn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388176AbfIMNFW (ORCPT ); Fri, 13 Sep 2019 09:05:22 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:33932 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFV (ORCPT ); Fri, 13 Sep 2019 09:05:21 -0400 Received: by mail-pl1-f195.google.com with SMTP id d3so13251261plr.1 for ; Fri, 13 Sep 2019 06:05:21 -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=r8Wub1Gv5kwU8NTkyDFBFj/6r+g1Rvev9JdO4bQzznQ=; b=I3pTeEhntjEsHM8orJ0gMOuQG8fXYxce+sEugG3OhKxcBnUDmIos0gMwZWjNv5cVZK Z05C3Ti/fEcBybmiWLefYrJlhtcRXVLPnlFcbVGm2iaUn0k7RNl9qGuuJYIuzZkzRQm/ 5dzx/PsIj88pEAFEjrXGTTyK4YvYw/Clgtpvs= 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=r8Wub1Gv5kwU8NTkyDFBFj/6r+g1Rvev9JdO4bQzznQ=; b=hGmKN0L8d8BLTsc/LxHLFthOhucsRU1WvLRThyo+UQ5O+t6uw4kg8XnJgr4vxshV5M Ltx9D0qZf/A4hwkKo3sYY0y6mqKX/bPmqZD8k26wIskzdpkpS8izprHHoXCJF5rRz528 /lj76iVwi1g4cEyqgFEfIcbhbrqMka58o//CbVEIWF/O++yyyDLmtrMHdzyOEtF52+7T m0xQV2TGW8hSTPt6k3dKq1YEslgVdiUOeMNr5FDYjRKDLQm9AphXy8oQLBRT/+uylg+v q0+wBBiBkcow+q5HjXesrr0dCTI00gULYEwTuW5J5y/Sa8cAHtbu3m7oEmXYf7TjErnN aGyQ== X-Gm-Message-State: APjAAAXX2h6gtEZnLFw+Gq9kwPOmQA7kuN1oYuER6EDjmU+Ij31McBOK YgaWZMlMRdNWAXwQRxu6spnykQ== X-Google-Smtp-Source: APXvYqztuNW8prUwBNAxYPE+MUgpZdsdYRxfJS1teJgyYoa/YjFN+1qSy+C/bS7nKGm31fhQs7L1Tg== X-Received: by 2002:a17:902:b685:: with SMTP id c5mr10244592pls.16.1568379921138; Fri, 13 Sep 2019 06:05:21 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:20 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 09/13] mpt3sas: Fail release cmnd if diag buffer is released Date: Fri, 13 Sep 2019 09:04:46 -0400 Message-Id: <1568379890-18347-10-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Return the diag buffer release command with -EINVAL status if the buffer is already released. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 62e878d..9267ffe 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -2235,7 +2235,7 @@ _ctl_diag_release(struct MPT3SAS_ADAPTER *ioc, void __user *arg) MPT3_DIAG_BUFFER_IS_RELEASED) { ioc_err(ioc, "%s: buffer_type(0x%02x) is already released\n", __func__, buffer_type); - return 0; + return -EINVAL; } request_data = ioc->diag_buffer[buffer_type]; From patchwork Fri Sep 13 13:04:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144785 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A92A516C1 for ; Fri, 13 Sep 2019 13:05:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8861F2084F for ; Fri, 13 Sep 2019 13:05:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="YCjfbV0j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388226AbfIMNFY (ORCPT ); Fri, 13 Sep 2019 09:05:24 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:33672 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFY (ORCPT ); Fri, 13 Sep 2019 09:05:24 -0400 Received: by mail-pl1-f195.google.com with SMTP id t11so13221214plo.0 for ; Fri, 13 Sep 2019 06:05:23 -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=nF4pPTdBa4lzcPkGV3lnV7l1njdYOU5p16G8/xw5G0k=; b=YCjfbV0jinqJF9DGqcZ8Gjn1AfQ5VF3cno2kYNUZ/ZrkjF3lhHTFx8YrbJjb70Aw2W FyT6Q9g0HCxWdvHlyYMzEnGIfheV46zUUF1zs94cf5WUy7dablfYOqHZ7uiGxpKml9Nn eCQBCAfOOjahJ+QpLTg2e3FagGIR80qZrgT38= 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=nF4pPTdBa4lzcPkGV3lnV7l1njdYOU5p16G8/xw5G0k=; b=cAs6aN1oNdlH7b0v1Lx8cLNXPHXtT6tc+jOqjiBAh5nrG8oifQruLdOq8ZAZOE6GSv 9s/9WivwG1NuVammAp/haxy7yVPxcVvAUmGDmzhGiQxBIXLtxZqhnfhLWQE4vV7qxehg z6dh+mdxNSKqerTxA6nLop9WQgiy0b3GLcLPyOc+cNO+QgFH5F6QKIh/f3bSb72LPehz 50NEHOjIypXr+qZjTqjvWlrUmn22hITUadKuMFczLRf2E/PGfmaIZBhIroyWZguNJft3 mqMpM3cPFg7WOHz83anI7MQccz1dvSDOu65UxxvCyytmDmmWwKz4mqNnbQC+OyUUVIpR vamQ== X-Gm-Message-State: APjAAAW3kEMkX7K9Y+4XtNdYPetbE3mDttVuxVe5UpCeBYdsh6KRpQha W5dgtYKEhM+62RYhq2heOAPWnA== X-Google-Smtp-Source: APXvYqxgu2wkwL4+Lq4w7wa4OAsLlgOlJMJSzxhaSwEVhrQkZqil/yom0Nl8mh+ucZ6jGJk31hWeWQ== X-Received: by 2002:a17:902:7596:: with SMTP id j22mr36513907pll.280.1568379923283; Fri, 13 Sep 2019 06:05:23 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:22 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 10/13] mpt3sas: Use Component img header to get Package ver Date: Fri, 13 Sep 2019 09:04:47 -0400 Message-Id: <1568379890-18347-11-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The firmware image layout has been changed for Aero controllers. All compatible HBA's has to get Firmware Package version from Component Image Header layout. The Signature field in FW header is set to 0xEB000042 for products compatible with Component Image Header. For compatible Controllers, Driver fetches firmware package version from ApplicationSpecific field of Component Image Header. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 848f211..6eb0cef 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -4240,10 +4240,12 @@ _base_display_OEMs_branding(struct MPT3SAS_ADAPTER *ioc) static int _base_display_fwpkg_version(struct MPT3SAS_ADAPTER *ioc) { - Mpi2FWImageHeader_t *FWImgHdr; + Mpi2FWImageHeader_t *fw_img_hdr; + Mpi26ComponentImageHeader_t *cmp_img_hdr; Mpi25FWUploadRequest_t *mpi_request; Mpi2FWUploadReply_t mpi_reply; int r = 0; + u32 package_version = 0; void *fwpkg_data = NULL; dma_addr_t fwpkg_data_dma; u16 smid, ioc_status; @@ -4300,14 +4302,26 @@ _base_display_fwpkg_version(struct MPT3SAS_ADAPTER *ioc) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { - FWImgHdr = (Mpi2FWImageHeader_t *)fwpkg_data; - if (FWImgHdr->PackageVersion.Word) { - ioc_info(ioc, "FW Package Version (%02d.%02d.%02d.%02d)\n", - FWImgHdr->PackageVersion.Struct.Major, - FWImgHdr->PackageVersion.Struct.Minor, - FWImgHdr->PackageVersion.Struct.Unit, - FWImgHdr->PackageVersion.Struct.Dev); - } + fw_img_hdr = (Mpi2FWImageHeader_t *)fwpkg_data; + if (le32_to_cpu(fw_img_hdr->Signature) == + MPI26_IMAGE_HEADER_SIGNATURE0_MPI26) { + cmp_img_hdr = + (Mpi26ComponentImageHeader_t *) + (fwpkg_data); + package_version = + le32_to_cpu( + cmp_img_hdr->ApplicationSpecific); + } else + package_version = + le32_to_cpu( + fw_img_hdr->PackageVersion.Word); + if (package_version) + ioc_info(ioc, + "FW Package Ver(%02d.%02d.%02d.%02d)\n", + ((package_version) & 0xFF000000) >> 24, + ((package_version) & 0x00FF0000) >> 16, + ((package_version) & 0x0000FF00) >> 8, + (package_version) & 0x000000FF); } else { _debug_dump_mf(&mpi_reply, sizeof(Mpi2FWUploadReply_t)/4); From patchwork Fri Sep 13 13:04:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144787 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7B7F16C1 for ; Fri, 13 Sep 2019 13:05:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C623B206BB for ; Fri, 13 Sep 2019 13:05:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="G7QQ7PKb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388230AbfIMNF0 (ORCPT ); Fri, 13 Sep 2019 09:05:26 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38513 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNF0 (ORCPT ); Fri, 13 Sep 2019 09:05:26 -0400 Received: by mail-pl1-f193.google.com with SMTP id w10so2119680plq.5 for ; Fri, 13 Sep 2019 06:05:25 -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=6bJJhskxZy1dIvhDoO5hXBSBZjyiy4EkGZwUvULphPk=; b=G7QQ7PKbH945uzjLINmpcNNrdPRzPpgIZMsO9LJmRgQT/HcguUynEbh/OZAuSTVceT XlaE6ZHbpIkLomtMbD1Sk7K4zFRhRsEZQeSz/cPcb+lw4vx75SLSz7KjN3QwmszvjZRI OLb7iAju3Vlez2wS92Ti/1lsVatbG58YlwI6Y= 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=6bJJhskxZy1dIvhDoO5hXBSBZjyiy4EkGZwUvULphPk=; b=dOOgvag51zgucwTF0ZMVwYcfTJZe1ZYnhuE9oIhm0PLcU/I0stHoYBGYsvDoFIudT4 BjtYRCICpVUKidHK7OVJclg6hgLA69TOdR4E23S55RTuJ77jqFwNGMJaq/Ex8xDUgUDt 4ZKk8cZ1GidSBUoLPR2oyHwfh+8OOZqmHJVoypiceWq8AgiYI5zt4UOkkH9cZMBc73uH 95C95hOAz81SgsaI8hwhkKktm0HG8N7eKYDS+RdYYJV4lKKvM5jogckxC/IhiJMDolCS z3dZlB736qH8tN2lecYWtm3RM8nO+MaUBQPOuH7emENgt1dskdGfpyv91yvibGSkJJwK T8uw== X-Gm-Message-State: APjAAAWNwCUDtKWxt4F7VpR7e2U+7pUP5v4y4WuLBYIjpwzVmALXTEFV GQ4xpsnkLEAN47zWB+QHOsxVGw== X-Google-Smtp-Source: APXvYqxnNRvXqkuyxzHgYWEtiMMZUxBjc8TsBkCEFBLlRxxV6Q82ClsNTuUyVCQI+jBui1G+3YiLHg== X-Received: by 2002:a17:902:bd97:: with SMTP id q23mr2826003pls.259.1568379925329; Fri, 13 Sep 2019 06:05:25 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:24 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 11/13] mpt3sas: Reject NVMe Encap cmnds to unsupported HBA Date: Fri, 13 Sep 2019 09:04:48 -0400 Message-Id: <1568379890-18347-12-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If any faulty application issues an NVMe Encapsulated commands to HBA which doesn't support NVMe protocol then driver should return the command as invalid with below message. "HBA doesn't supports NVMe. Hence rejecting NVMe Encapsulated request." Otherwise below page fault kernel panic will be observed while building the PRPs as their is no PRP pools allocated for the HBA which doesn't support NVMe drives. RIP: 0010:_base_build_nvme_prp+0x3b/0xf0 [mpt3sas] Call Trace: _ctl_do_mpt_command+0x931/0x1120 [mpt3sas] _ctl_ioctl_main.isra.11+0xa28/0x11e0 [mpt3sas] ? prepare_to_wait+0xb0/0xb0 ? tty_ldisc_deref+0x16/0x20 _ctl_ioctl+0x1a/0x20 [mpt3sas] do_vfs_ioctl+0xaa/0x620 ? vfs_read+0x117/0x140 ksys_ioctl+0x67/0x90 __x64_sys_ioctl+0x1a/0x20 do_syscall_64+0x60/0x190 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 9267ffe..3b72a24 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -785,6 +785,18 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, case MPI2_FUNCTION_NVME_ENCAPSULATED: { nvme_encap_request = (Mpi26NVMeEncapsulatedRequest_t *)request; + if (!ioc->pcie_sg_lookup) { + dtmprintk(ioc, ioc_info(ioc, + "HBA doesn't supports NVMe. Hence rejecting NVMe Encapsulated request.\n" + )); + + if (ioc->logging_level & MPT_DEBUG_TM) + _debug_dump_mf(nvme_encap_request, + ioc->request_sz/4); + mpt3sas_base_free_smid(ioc, smid); + ret = -EINVAL; + goto out; + } /* * Get the Physical Address of the sense buffer. * Use Error Response buffer address field to hold the sense From patchwork Fri Sep 13 13:04:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C602A14E5 for ; Fri, 13 Sep 2019 13:05:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4EF62084F for ; Fri, 13 Sep 2019 13:05:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="IH2R2Za3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388232AbfIMNF2 (ORCPT ); Fri, 13 Sep 2019 09:05:28 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35507 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNF2 (ORCPT ); Fri, 13 Sep 2019 09:05:28 -0400 Received: by mail-pf1-f196.google.com with SMTP id 205so18053509pfw.2 for ; Fri, 13 Sep 2019 06:05: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=SRj0c5G429iSG116CLiEpdfd+23LgYkL7nkuDUVI6yE=; b=IH2R2Za3oh6upvL4TDY7cbvQbD4AQ3J6RwXCcOTn9t+d7o2++SYyxzMRDZcn+AsfaI 5RtLJFmb2ffDCMU5s/JuUTp8QNx7Jj+k3Xh4mJSd7PHYy65v1eHWmf6z/vgmYh49Dj5H gh5E4WOLO2O1k2YL1FaCofUjYZAAjDSi7ler4= 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=SRj0c5G429iSG116CLiEpdfd+23LgYkL7nkuDUVI6yE=; b=L/HVXbslk/D8pD972xgV+TAKmlZ9HgaDWuk4qqNtaeznhyeKCWTDPewbY0KzmryrL3 arzYU09OG+LLjALUGx3qXIXXsOQh20Aw7rW+KhJvUbQmOhymohp4vnzIKw1rlGHCcl9z gqi6JNXEc2vSQntgBJhHTLIiKS4xm3yfrAPjAggkYYUVS7A3JZ98I+T6iODnsgfZJnKk Qf66X4dt5TuMZWHIKzvLwQl0LQvTOw7Ida/t2yscyoAOiKoEANSR2cwAVJsyHl6cMUjR fnyQTVGDJBmhTGOk7cNLJHs8ny+nD8QEozX4/ajRtJD6jH1DmRoFsf9xWmqfooLqieDS CUdg== X-Gm-Message-State: APjAAAVXX8k7wyOsM1OZ+/k+KZreSkCHiGIAGUOwWaD8/puOPiEUGdfH MbaXfbDcHO4HQc1YXXqwmBkg/Q== X-Google-Smtp-Source: APXvYqwQvLbdYLRjcB8iEO4peZcTyv6ORiDqXIMhawy+4KoripmL+EzDdDCj9mi0t94m/7vpt+AiCA== X-Received: by 2002:a63:5c06:: with SMTP id q6mr43552696pgb.45.1568379927418; Fri, 13 Sep 2019 06:05:27 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:26 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 12/13] mpt3sas: Fix module parameter max_msix_vectors Date: Fri, 13 Sep 2019 09:04:49 -0400 Message-Id: <1568379890-18347-13-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Issue: Load driver with module parameter "max_msix_vectors". Value provided in module parameter is not used by mpt3sas driver. Driver loads with max controller supported MSIX value. Fix: In _base_alloc_irq_vectors use reply_queue_count which is determined using user provided msix value insted of ioc->msix_vector_count which tells max supported msix value of the controller. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 6eb0cef..ddecdb1 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -3042,11 +3042,11 @@ _base_alloc_irq_vectors(struct MPT3SAS_ADAPTER *ioc) descp = NULL; ioc_info(ioc, " %d %d\n", ioc->high_iops_queues, - ioc->msix_vector_count); + ioc->reply_queue_count); i = pci_alloc_irq_vectors_affinity(ioc->pdev, ioc->high_iops_queues, - ioc->msix_vector_count, irq_flags, descp); + ioc->reply_queue_count, irq_flags, descp); return i; } From patchwork Fri Sep 13 13:04:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11144791 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 037C914E5 for ; Fri, 13 Sep 2019 13:05:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D62702084F for ; Fri, 13 Sep 2019 13:05:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="dLR7VSJs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388236AbfIMNFa (ORCPT ); Fri, 13 Sep 2019 09:05:30 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46997 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387533AbfIMNFa (ORCPT ); Fri, 13 Sep 2019 09:05:30 -0400 Received: by mail-pf1-f194.google.com with SMTP id q5so18029615pfg.13 for ; Fri, 13 Sep 2019 06:05:30 -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=ktbcZeLlBRjAw6x6Msq4A4si1KxqnAXIHUrMZiQtUvg=; b=dLR7VSJsL/rTQfa7rE5qXzXkE0IcmR8pH8dCMIwh4Y2zmmMsXIPDnApZnHvFZUH+nQ WOCEcDjG6hGYyRWF6fJJCum8BkeOb9lKSaMDWId/UcpgOIECaXiZWVgk/hdeL9C8jYH1 eyGHFsK9Osj8vszpM6KbhpbJQM/PYicw0gsg8= 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=ktbcZeLlBRjAw6x6Msq4A4si1KxqnAXIHUrMZiQtUvg=; b=ObYAnHM1U/myc9ttHkEUDMfh+lu+4trMUvPsZvtxADsBQIg3gLmXpQLp0ndzN0AjLj 11alqSu0yFtgtwgjMkgAa5u3naBbQLEs/8C0ZwLgMRn9/DmM9+HO6a8fyNbzGhaT5Gnv gLEpFwMeDiT4POpo6mktmoW42exGIwCMABj7C71+EqxRB38JXqXyyjvPiwK+GtPDfXN0 Mep3y3mle0eihxMohPByMS6QpvSJ033j8GFSIobumN/n5Iv4bDMPNXHkzRSG33wU9rTF 0K3KuyOCkdaYqN39quEeqarGoLD889D7TsdcOajh7jIvwqTaOwIJPJ452pVcE9qNRjep KW5w== X-Gm-Message-State: APjAAAWr4GNRqPzxMKOcZeaygw4n5q+fsJ2yRplxryc201vm4WLxY/dx y9EEI1MtFd+Hg3Bf0nwvGhGGEw== X-Google-Smtp-Source: APXvYqxvi5Diy+YFgOGpf0L8xlS/myCe1845ahpYofOGRfBNB17mBB1Xby3qIeJmufEsRGmSEVLbjg== X-Received: by 2002:a17:90a:360b:: with SMTP id s11mr5136710pjb.30.1568379929581; Fri, 13 Sep 2019 06:05:29 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 69sm37208841pfb.145.2019.09.13.06.05.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 06:05:29 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy Subject: [PATCH 13/13] mpt3sas: Bump mpt3sas driver version to 32.100.00.00 Date: Fri, 13 Sep 2019 09:04:50 -0400 Message-Id: <1568379890-18347-14-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> References: <1568379890-18347-1-git-send-email-sreekanth.reddy@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Bump mpt3sas driver version to 32.100.00.00 Signed-off-by: Sreekanth Reddy --- 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 91f6636..4ebf81e 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 "31.100.00.00" -#define MPT3SAS_MAJOR_VERSION 31 +#define MPT3SAS_DRIVER_VERSION "32.100.00.00" +#define MPT3SAS_MAJOR_VERSION 32 #define MPT3SAS_MINOR_VERSION 100 #define MPT3SAS_BUILD_VERSION 0 #define MPT3SAS_RELEASE_VERSION 00