Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1150283pxv; Fri, 9 Jul 2021 19:37:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf2jzY/FSr5YpWDO4lAUBO3T+Ry7ka408kPGxrfQHQvI/utChVPdgUbWU5EfY4CeODq2Rv X-Received: by 2002:a17:906:33c7:: with SMTP id w7mr18894333eja.430.1625884652777; Fri, 09 Jul 2021 19:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884652; cv=none; d=google.com; s=arc-20160816; b=ZMpeuIO8r859M1qYC+SuC1N6PhxdzntzGAVkVnamCD/uZNtfe3IAfD9Aw58x9OQ/Xu dmqwbNCzja6pmBAXYNoofqYouATUe84o4lpGN5gdaMQCdZwAz/p4+aagFp4CR5Oig+Mx KyW2k+o8bPLLBTME9N1MVJYo7/Kn0koORv8wRtFK5PLwpR1NBNHW3bkBmxPhT7sQnSrX mMKJvQKOYJVzJRLVXKRy3WsFSVbAUzx4f2176C23U7Gl3/0f6HUNtNvRhVMEPXwpHGS/ sW4eV+XfRs/INkuPAKk7gYiE8RUZueKB0OrxUrz/rUmc/qKgGCl/B2JsfvHwm+Px+vro nqeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gn46xEtcFpEC9YpU9c/tl5G8cA4Xs2cO5XLGXd/+XM8=; b=b/AyEKYT03OsYoxODNFOe6NRVECnOrW+ErdoTRx73uY79XqLPpL+TzVFy53de52USf sQx3mbevr9l3Ttk9C4HpVe6Kdr1sXNNmTelWQtSYrAOqbE4et+WWzJF9aZMuC+O7QwZs W3uMMqxh2bfdNT7/eVYEPqwLm13Q3vvMpOECF0d060GhU6fuMMBBcb6JhJUhSrydkIc2 rMt+2o0dPI5wuiN7WKuOkMctxN3elstw5Vk66+VleJ33FQFNvik/kMLhYlS5WwSS0xYL BZvnv1wLEjfBUgr5soHtCB+GgkDB5zSt2X5un4aVzm4GsNSBZLTjA1pke5n/spllSIVN 74Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="S/wen5Xz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q15si9512850edd.286.2021.07.09.19.37.09; Fri, 09 Jul 2021 19:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="S/wen5Xz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231757AbhGJCiq (ORCPT + 99 others); Fri, 9 Jul 2021 22:38:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:53552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235699AbhGJCe7 (ORCPT ); Fri, 9 Jul 2021 22:34:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E06E6613DF; Sat, 10 Jul 2021 02:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625884334; bh=PvYicS1MzkHzIS9KQy8XMlGrWB35iLyEPJpc6q/fTNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S/wen5Xz8UU9bJYNHtHzRRPrL96Ov9X+IppftqWnuTcjVZ9bSE9bs3rxlS+im3+Fi 6p9u7gOdD+UsZbP37mgZiM8AbJ9gQ5TvQGe63aQi2+6BXkoEBNs+IszgZnR+3w9FAh BGqZNz581dBK/C0hc/Ikmu7b5kwL0En7+VQes20Yhu+kLGpwkhUOxLZplptHzO1Hrp za9XctHprQG2jMctN3XEnCAU+ZTbfPmsvZUmMpxiqvEL00lYgZeghg4Pd7DoGg1FVe x2rdxRDMi1fzHf5DRzYkvMIVW1E87o1X3g0FFQW48036iI+oCvDGoIW6ezdblUuubD 4eDX8YfbysTWg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: John Garry , Ming Lei , Bart Van Assche , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 08/39] scsi: core: Cap scsi_host cmd_per_lun at can_queue Date: Fri, 9 Jul 2021 22:31:33 -0400 Message-Id: <20210710023204.3171428-8-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710023204.3171428-1-sashal@kernel.org> References: <20210710023204.3171428-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry [ Upstream commit ea2f0f77538c50739b9fb4de4700cee5535e1f77 ] The sysfs handling function sdev_store_queue_depth() enforces that the sdev queue depth cannot exceed shost can_queue. The initial sdev queue depth comes from shost cmd_per_lun. However, the LLDD may manually set cmd_per_lun to be larger than can_queue, which leads to an initial sdev queue depth greater than can_queue. Such an issue was reported in [0], which caused a hang. That has since been fixed in commit fc09acb7de31 ("scsi: scsi_debug: Fix cmd_per_lun, set to max_queue"). Stop this possibly happening for other drivers by capping shost cmd_per_lun at shost can_queue. [0] https://lore.kernel.org/linux-scsi/YHaez6iN2HHYxYOh@T590/ Link: https://lore.kernel.org/r/1621434662-173079-1-git-send-email-john.garry@huawei.com Reviewed-by: Ming Lei Reviewed-by: Bart Van Assche Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hosts.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index fa03be813f2c..9462564b2147 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -218,6 +218,9 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, goto fail; } + shost->cmd_per_lun = min_t(short, shost->cmd_per_lun, + shost->can_queue); + error = scsi_init_sense_cache(shost); if (error) goto fail; -- 2.30.2