Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp846866lqe; Sun, 7 Apr 2024 06:44:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8ROHF6jAgbqEcqii7vVzsWJAtiyffCYZO5IYQb0maRFsqGeY8y6dMM1aB63jFASPu+SvxYxBWsWRQZ/FxuJUzKz7i6prlSDd6UpebZg== X-Google-Smtp-Source: AGHT+IHTIP3L2+aEbfWEc+JgOLai2v29lA/0dfAq5z6C8jQm0UfJAew4+s1c/1T+f4dJJZ/LXfJq X-Received: by 2002:a17:902:ea0a:b0:1e3:ce12:ef77 with SMTP id s10-20020a170902ea0a00b001e3ce12ef77mr6990080plg.11.1712497452959; Sun, 07 Apr 2024 06:44:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712497452; cv=pass; d=google.com; s=arc-20160816; b=Zjmbay06GnkxkyW/hokTEhaP2LGbXG1oTFQJmW6uY7dxgmMr1rn4HRTfQQJjFH63vi 6k0QrsEXuh12ArveeUlSUMJ2Ewh/YvJBkRZT/mNrS5j6kEejoMgVSD+rVe2culNebaOk 4XKFjba95AANk58RIxV6vn7RgNfr7O+QpFxz0pl/L1JmyoeAzGjAUExw7lLfg6AH8VET pINiHUd/4+UERK/SLtUo9U3AK37kc9vKSico7QDKZp10qYKbmMN5QG0vkfZbAJrHpOS4 Q/4XAaKMR8p82vRfLqC82ErR4YPyJ4fpWQVGnGp8g9gDbgbBwyF9KD9gbbSVHpRkvcoR hd0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=gp22wgtiUJjkl3D/oIfM5fXo7DDUkDYgs7xcg4rHoXs=; fh=oPkVWPhE12BMK+pwlJxHuiMmWHHXnalyKV7QdFfBV30=; b=bAJGeJ36H7cMqbT9Eyn6a3t50g+BtnvJjg0ck7NfO0hPluVDGtjn3Lwesmm2ffP8Z2 TN68MoXP8NOt2H75YtA4rSiBBLZF7LUEFs1UXkBGxUgR9/6XitxlyORtDgZgViC2yeTX dRUfKpsc3ByLX4uQpT/ZIfIVW/SOI6JR8vLi/gESDO5unZFNY40gSPFhxndtMBFnjExM esMfVsqUjFmq+owhcxFyVccu0IpSrhVAwSkNiVX6A5Wq3mIeMu9hJlu2meLuw/QdCJxq jHWVew4uNxtOeA1gSviyucmNNfUXNaisCvAUhxmG1WcAqkoHyli4eOIZnRD6vJK0wSD+ 5Fpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S4WLakIA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134489-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id jd7-20020a170903260700b001e2a40a6eb4si4451320plb.137.2024.04.07.06.44.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 06:44:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S4WLakIA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134489-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134489-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2EE02B21D09 for ; Sun, 7 Apr 2024 13:39:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7F1B42079; Sun, 7 Apr 2024 13:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S4WLakIA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5B7242070; Sun, 7 Apr 2024 13:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712495655; cv=none; b=Ff3xhONmdhfikBZlmHRjfW/FlJZuGhsNlkedUhFNwR9p7AP8H4nWLzENXIG5lnJs7mRZHIcynv0xjY6OnwOIO+iPXiI1g0PJ92q+C1fONCGRCoovJiuhmDR2CknmtEXDwnRNnTqHQbVLmVClWerqiXDjR80zADoRdZix9ARDrSs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712495655; c=relaxed/simple; bh=IrkDEfdQJowtBx2Nz7uVHLjvPQ1A1Oh6PuoYCvmpDRg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZT9cWX25d+PE9Ze9C+oLrlyAxQZ+uT6FzG8QyH0fKyDdZwMWlzIRZn0C6ohVGvvFutmGYiTchJHLIeX5Cz0lNJ0qAAAXdGvKM2c6J7Ulyr2L7T2uUDumIuPFlN3870c2DN2gxcYtFBxWnJvKNT78jUVR8SXeuqvyX/MvM4vhcro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S4WLakIA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A332EC433F1; Sun, 7 Apr 2024 13:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712495655; bh=IrkDEfdQJowtBx2Nz7uVHLjvPQ1A1Oh6PuoYCvmpDRg=; h=From:To:Cc:Subject:Date:From; b=S4WLakIA2AzsMyfSIclEos1F4eKsH9WJ4mSB5/BqSFqnWAoDKTzDnY1tD4fe4o38a fgLsMIQI2/ZC0uODUEdpKgMO8C/FWpQbA3x7GnpRkrml1ujkAoZQGOMpT6/egOR8wy O61QGtv0w/Iyuj3dfA/QqvlQMGPrfZ9GnpTpI6APyf3mypGV3DPrvTAeqQ+fTGCUxz 3ykvgsZSjBy8QBDQyMfrcb59RiteCed9BWTjuXNQF/G0e+kuiyAAxrN+y0B7b3gaBK oClOVNDr3A284R/qET85I5DtFUZgpJoi0RfF04iDDnNql41AiY7a6BXTYrvVJGp5g5 U5aoGruWpeusw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Justin Tee , "Martin K . Petersen" , Sasha Levin , james.smart@broadcom.com, dick.kennedy@broadcom.com, jejb@linux.ibm.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 1/6] scsi: lpfc: Update lpfc_ramp_down_queue_handler() logic Date: Sun, 7 Apr 2024 09:14:07 -0400 Message-ID: <20240407131414.1053600-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.4.273 Content-Transfer-Encoding: 8bit From: Justin Tee [ Upstream commit bb011631435c705cdeddca68d5c85fd40a4320f9 ] Typically when an out of resource CQE status is detected, the lpfc_ramp_down_queue_handler() logic is called to help reduce I/O load by reducing an sdev's queue_depth. However, the current lpfc_rampdown_queue_depth() logic does not help reduce queue_depth. num_cmd_success is never updated and is always zero, which means new_queue_depth will always be set to sdev->queue_depth. So, new_queue_depth = sdev->queue_depth - new_queue_depth always sets new_queue_depth to zero. And, scsi_change_queue_depth(sdev, 0) is essentially a no-op. Change the lpfc_ramp_down_queue_handler() logic to set new_queue_depth equal to sdev->queue_depth subtracted from number of times num_rsrc_err was incremented. If num_rsrc_err is >= sdev->queue_depth, then set new_queue_depth equal to 1. Eventually, the frequency of Good_Status frames will signal SCSI upper layer to auto increase the queue_depth back to the driver default of 64 via scsi_handle_queue_ramp_up(). Signed-off-by: Justin Tee Link: https://lore.kernel.org/r/20240305200503.57317-5-justintee8345@gmail.com Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc.h | 1 - drivers/scsi/lpfc/lpfc_scsi.c | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 7ce0d94cdc018..98ab07c3774ed 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -1039,7 +1039,6 @@ struct lpfc_hba { unsigned long bit_flags; #define FABRIC_COMANDS_BLOCKED 0 atomic_t num_rsrc_err; - atomic_t num_cmd_success; unsigned long last_rsrc_error_time; unsigned long last_ramp_down_time; #ifdef CONFIG_SCSI_LPFC_DEBUG_FS diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 816235ccd2992..f238e0f41f07c 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -246,11 +246,10 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) struct Scsi_Host *shost; struct scsi_device *sdev; unsigned long new_queue_depth; - unsigned long num_rsrc_err, num_cmd_success; + unsigned long num_rsrc_err; int i; num_rsrc_err = atomic_read(&phba->num_rsrc_err); - num_cmd_success = atomic_read(&phba->num_cmd_success); /* * The error and success command counters are global per @@ -265,20 +264,16 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { shost = lpfc_shost_from_vport(vports[i]); shost_for_each_device(sdev, shost) { - new_queue_depth = - sdev->queue_depth * num_rsrc_err / - (num_rsrc_err + num_cmd_success); - if (!new_queue_depth) - new_queue_depth = sdev->queue_depth - 1; + if (num_rsrc_err >= sdev->queue_depth) + new_queue_depth = 1; else new_queue_depth = sdev->queue_depth - - new_queue_depth; + num_rsrc_err; scsi_change_queue_depth(sdev, new_queue_depth); } } lpfc_destroy_vport_work_array(phba, vports); atomic_set(&phba->num_rsrc_err, 0); - atomic_set(&phba->num_cmd_success, 0); } /** -- 2.43.0