From patchwork Tue Feb 8 14:20:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Lane X-Patchwork-Id: 1589874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=TGHuDnON; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JtQCS3Nv4z9sFn for ; Wed, 9 Feb 2022 01:20:35 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nHRM1-0000SX-4V; Tue, 08 Feb 2022 14:20:25 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nHRLx-0000RV-7x for kernel-team@lists.ubuntu.com; Tue, 08 Feb 2022 14:20:21 +0000 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 1E6753F17B for ; Tue, 8 Feb 2022 14:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1644330021; bh=fA+j9lMZWHbU67HU51troBOg1a8DA5FFRF6C4d5K1eY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TGHuDnON7f3SvASJfv1RyKD8dUhw+CNEmROWXpWBpPMJDRJvcXd9ob3vZz01GeCnK R6EDQbRZ8Q2YprWf7qwpnD3xzfG+C5agyL7mTf5QFdNw87fxYYwzvG56ZO+IZlCfW/ J1lmgNDoQNsN4G3dJOExzEdu6BFS/BMGUPLsFVWehS7m4/ilaH7R3MbxJL5obsstZw 9hvmveyr0xyVGJXYYm48IvGc9oA24clTLKK+5yHEDQSdFRy4PJKlFoWvGzxPGOhZ5a ZANNeBVIiJAME/Z46SwSc9Rx5P5orVIMQVuvP8OmmqHi58/Aoswp/IlWswjflaNpUQ Q+HBAcUFytiUQ== Received: by mail-qv1-f71.google.com with SMTP id 8-20020a0562140d0800b00422bb534680so11042332qvh.7 for ; Tue, 08 Feb 2022 06:20:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fA+j9lMZWHbU67HU51troBOg1a8DA5FFRF6C4d5K1eY=; b=C36FPiqUP4aqdT0QLtPJz9Lj7gYp33m2jRPZt5FpFpkJsKi6HS1OLrDI3YBGeguHnu gJ2O1q7KqGvgIPrpCHPnYo1NNhGo0oZMHAcxFbXoWmjXHFWvJnuZncVN8z5rCBx467L0 Uw7iaNk4reAbNcP2Gfz90xxLTD/cGir1u7k7l6PRWwZqa91XyhC8WDtB3toHO7DQsJjU JcLWJDDNApXoE4mSIP8EzKPriF3Rz7eXE7YxkMsotPPPB+X6iNlTM4tqdb063aBE+ZBy q2cEDoJr9A4MVf1qkBylVDTPQ+m1SR82wlwYpxmKR7H0eZdvzd52EIcMMNpGPygfwQgB HHBQ== X-Gm-Message-State: AOAM531cSurMPbbVPxbFgAGYvZNLrcW7CGgcjmMX2RLjy9C8z1RDxPU2 uGxx278BFWDTk6yFmH0933N0BQuwpvvVYSNWmAHxar3s02atx6ZADdNEqZP9RPaOkc5svHhRSq+ zZKUCEUmzjHDitQSG32J/XMj2jZ7K1XKXabthKT8SrA== X-Received: by 2002:a05:6214:4011:: with SMTP id kd17mr3119262qvb.45.1644330019994; Tue, 08 Feb 2022 06:20:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWtlNhSQSLdx0SFLlqTvZBjqZXXxE1pKKKN3VJi5Hc70xpC3hA4R0yExSx1MoYtOZ10Xz4JA== X-Received: by 2002:a05:6214:4011:: with SMTP id kd17mr3119231qvb.45.1644330019589; Tue, 08 Feb 2022 06:20:19 -0800 (PST) Received: from localhost.localdomain ([71.217.161.186]) by smtp.gmail.com with ESMTPSA id b16sm6712977qtk.84.2022.02.08.06.20.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 06:20:19 -0800 (PST) From: Jeff Lane To: kernel-team@lists.ubuntu.com Subject: [J][PATCH 4/6] scsi: lpfc: Cap CMF read bytes to MBPI Date: Tue, 8 Feb 2022 09:20:12 -0500 Message-Id: <20220208142014.3782820-5-jeffrey.lane@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208142014.3782820-1-jeffrey.lane@canonical.com> References: <20220208142014.3782820-1-jeffrey.lane@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: James Smart BugLink: https://bugs.launchpad.net/bugs/1956982 Ensure read bytes data does not go over MBPI for CMF timer intervals that are purposely shortened. Link: https://lore.kernel.org/r/20211204002644.116455-8-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen (cherry picked from commit 05116ef9c4b444f7fdbb56f9e13c2ec941726639) Signed-off-by: Jeff Lane --- drivers/scsi/lpfc/lpfc.h | 2 +- drivers/scsi/lpfc/lpfc_init.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 4c7bc0a5fcf7..f1c87a2d0af2 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -1027,7 +1027,7 @@ struct lpfc_hba { */ #define HBA_PCI_ERR 0x80000 /* The PCI slot is offline */ #define HBA_FLOGI_ISSUED 0x100000 /* FLOGI was issued */ -#define HBA_CGN_RSVD1 0x200000 /* Reserved CGN flag */ +#define HBA_SHORT_CMF 0x200000 /* shorter CMF timer routine */ #define HBA_CGN_DAY_WRAP 0x400000 /* HBA Congestion info day wraps */ #define HBA_DEFER_FLOGI 0x800000 /* Defer FLOGI till read_sparm cmpl */ #define HBA_SETUP 0x1000000 /* Signifies HBA setup is completed */ diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index bbcf5d446cb1..171a3783ced2 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -6003,8 +6003,13 @@ lpfc_cmf_timer(struct hrtimer *timer) if (ms && ms < LPFC_CMF_INTERVAL) { cnt = div_u64(total, ms); /* bytes per ms */ cnt *= LPFC_CMF_INTERVAL; /* what total should be */ - if (cnt > mbpi) + + /* If the timeout is scheduled to be shorter, + * this value may skew the data, so cap it at mbpi. + */ + if ((phba->hba_flag & HBA_SHORT_CMF) && cnt > mbpi) cnt = mbpi; + extra = cnt - total; } lpfc_issue_cmf_sync_wqe(phba, LPFC_CMF_INTERVAL, total + extra); @@ -6087,6 +6092,8 @@ lpfc_cmf_timer(struct hrtimer *timer) /* Each minute save Fabric and Driver congestion information */ lpfc_cgn_save_evt_cnt(phba); + phba->hba_flag &= ~HBA_SHORT_CMF; + /* Since we need to call lpfc_cgn_save_evt_cnt every minute, on the * minute, adjust our next timer interval, if needed, to ensure a * 1 minute granularity when we get the next timer interrupt. @@ -6097,6 +6104,8 @@ lpfc_cmf_timer(struct hrtimer *timer) jiffies); if (timer_interval <= 0) timer_interval = LPFC_CMF_INTERVAL; + else + phba->hba_flag |= HBA_SHORT_CMF; /* If we adjust timer_interval, max_bytes_per_interval * needs to be adjusted as well.