From patchwork Mon Dec 20 14:11:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 12687959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1659C433EF for ; Mon, 20 Dec 2021 14:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232683AbhLTOEZ (ORCPT ); Mon, 20 Dec 2021 09:04:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233452AbhLTOEX (ORCPT ); Mon, 20 Dec 2021 09:04:23 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9D37C06173F for ; Mon, 20 Dec 2021 06:04:22 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id k4so9489201pgb.8 for ; Mon, 20 Dec 2021 06:04:22 -0800 (PST) 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; bh=54nQQal7gZO2EC6fSgoUKGMRJXZNVg+VcDigyuC9B0s=; b=LX8GdRmXtwOaneEFf2aDNRKh2opwGaH6BRD977inDS9A1MsQEkOkUOCWZGwWeYaZSk XWp54LM8xCP0yYbeYlEMoQ5GsAhXwCycyoXCbEf4QKTvyPbcKFjCo+hOisae591rzecX vm1pDTvnUCeuf70LiEHFz6DCYhUBmHh35/2Gc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=54nQQal7gZO2EC6fSgoUKGMRJXZNVg+VcDigyuC9B0s=; b=FgQCYYEMTiWwlN5AJzoAhorsXrCEXnYPw4dK97e2Aj4R6QzurEvmqq2/9jRa9rxBxC bdy9J511dDR1mqwA7hlK+pxIt3zKvNC6gw+nYUFPCv2NUv7iqDG/r4S4ceOBHRAby05K 6oXJDP1+XCYX1aF06krUYczSQrvoIVlsEZJTMtc/o26DqpiEuoo3+koZzRABx+SLqJ/Y xZKOA2a14JJmB69K1nIy82LjwHkVRRc4SaZ1jKpXKjXr2X1gzWngz6Uzbc5emrA72PDT nOCEedjQYdzk4m0G7rx0kAkQhuVR6IB5wrWbqHLmaYDK7XSSoS/Bqm2YqZ68jzvREyJj astw== X-Gm-Message-State: AOAM533Ux99LgpJ6eJ0CoV4hW+2Ickqx1R3yOlveDtvdn58M9JomKf9O M1+DkpgACe/dzuonN/8nJgS1QgI0zoGCUOBYMylKeULpiviHAaJ2mfjWA8Gi52t9LuPe6HOB+aK AlLNrM8mfVUtG7bFjclQN6Glkav1NrFjZsTnpCOTumrfvirrRAa9uKtbvt57mHQPEPa9bVZ2Bjd MbynoRszqO X-Google-Smtp-Source: ABdhPJyq4Ci+cXOZijpmk66ihpOALfrZajIgaSoJhMplfSUMwMb23j/y/hAgHuKkZkAaZRGusEHU/A== X-Received: by 2002:a63:7981:: with SMTP id u123mr15089516pgc.360.1640009061869; Mon, 20 Dec 2021 06:04:21 -0800 (PST) Received: from dhcp-10-123-20-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id b4sm5434180pjm.17.2021.12.20.06.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 06:04:21 -0800 (PST) From: Sreekanth Reddy To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, mpi3mr-linuxdrv.pdl@broadcom.com, Sreekanth Reddy Subject: [PATCH 09/25] mpi3mr: Handling unaligned PLL in unmap cmnds Date: Mon, 20 Dec 2021 19:41:43 +0530 Message-Id: <20211220141159.16117-10-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211220141159.16117-1-sreekanth.reddy@broadcom.com> References: <20211220141159.16117-1-sreekanth.reddy@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Below special handling is needed for UNMAP commands issued to NVMe drives, - On B0 boards, if the parameter list length is greater than 24 and not 16byte multiple then truncate the parameter list length to 16byte multiple. - on A0 boards, if the parameter list length is greater than block descriptor data length + 8 then truncate the parameter list length to block descriptor data length + 8 value. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_os.c | 36 ++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index e961bb2..2a153df 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -3344,9 +3344,22 @@ static bool mpi3mr_check_return_unmap(struct mpi3mr_ioc *mrioc, struct scsi_cmnd *scmd) { unsigned char *buf; - u16 param_len, desc_len; - - param_len = get_unaligned_be16(scmd->cmnd + 7); + u16 param_len, desc_len, trunc_param_len; + + trunc_param_len = param_len = get_unaligned_be16(scmd->cmnd + 7); + + if (mrioc->pdev->revision) { + if ((param_len > 24) && ((param_len - 8) & 0xF)) { + trunc_param_len -= (param_len - 8) & 0xF; + dprint_scsi_command(mrioc, scmd, MPI3_DEBUG_SCSI_ERROR); + dprint_scsi_err(mrioc, + "truncating param_len from (%d) to (%d)\n", + param_len, trunc_param_len); + put_unaligned_be16(trunc_param_len, scmd->cmnd + 7); + dprint_scsi_command(mrioc, scmd, MPI3_DEBUG_SCSI_ERROR); + } + return false; + } if (!param_len) { ioc_warn(mrioc, @@ -3406,12 +3419,12 @@ static bool mpi3mr_check_return_unmap(struct mpi3mr_ioc *mrioc, } if (param_len > (desc_len + 8)) { + trunc_param_len = desc_len + 8; scsi_print_command(scmd); - ioc_warn(mrioc, - "%s: Truncating param_len(%d) to desc_len+8(%d)\n", - __func__, param_len, (desc_len + 8)); - param_len = desc_len + 8; - put_unaligned_be16(param_len, scmd->cmnd + 7); + dprint_scsi_err(mrioc, + "truncating param_len(%d) to desc_len+8(%d)\n", + param_len, trunc_param_len); + put_unaligned_be16(trunc_param_len, scmd->cmnd + 7); scsi_print_command(scmd); } @@ -3466,6 +3479,7 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost, u32 scsiio_flags = 0; struct request *rq = scsi_cmd_to_rq(scmd); int iprio_class; + u8 is_pcie_dev = 0; sdev_priv_data = scmd->device->hostdata; if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) { @@ -3510,8 +3524,10 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost, goto out; } - if ((scmd->cmnd[0] == UNMAP) && - (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_PCIE) && + if (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_PCIE) + is_pcie_dev = 1; + if ((scmd->cmnd[0] == UNMAP) && is_pcie_dev && + (mrioc->pdev->device == MPI3_MFGPAGE_DEVID_SAS4116) && mpi3mr_check_return_unmap(mrioc, scmd)) goto out;