Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1145215pxv; Fri, 9 Jul 2021 19:26:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPhYuHjlfRpjt+gjmhhhpZgyzliXJtBub3GGfkkXU9cmDOzMw0EHjw0uHbEaRNum8Bqana X-Received: by 2002:a05:6402:7c4:: with SMTP id u4mr51030610edy.69.1625884019701; Fri, 09 Jul 2021 19:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884019; cv=none; d=google.com; s=arc-20160816; b=eW0SW/vZ1l59dEu8YOy4hUQNrVUg4025hlJKdPCiqy3TSaITUwOVpEIU5eId0K+1u6 KGNbetTYGPx5YQcja8yMm2w9vsh1fBjycxuCw+hXJylPEdQmwFEEW9ovDO/g9gbcdVeH I0MBztMO493x300VrPkdB74Ej6ki/x6K3VEss5gD2ijM9EOREYgUYrJl+4F+MN0im7pU vgxJz5rf/au0oxvgx5tvOqTnuksPIon3WmZQinqWO8e9iqBEbt7CwQRtTkbwq+ulTOcG L3lDO+++FYEhKRG7d6J8Fg8DZIbR88m5YguN9Gvoou1WBsbU1syJa2PhDthvtYERAPf4 8IQg== 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=dZWFULGXb/rWBFkdyvAo5xj3wLna7++InaU4dVOt3KA=; b=0+6lquPZlam/wCCNIMCBPmKGu1/QzuE7eIe5u2TXCEfX183rgkp9cytHLKTE4/YBE+ j73PEZY+Il8OIs9dMLzB2BKY8IIKrtXHt5p0t/92orrahNjXzqQGEwzaSBEExzG66A0h nnADj4mtH3i4GsfGTi9vYFc3f/JgLJUkflt4TXbjc1B3CV6T8KE9f1VcOogqJ5dXS6NV knMegmZCKjeq2aOCsf164GNkuL9bZ1vJIQmCfEbBE0sn/Zw0GT4F14FZD6YTHWABAKjr 5PY+onBMhmTLD9jhfo0Zn2diquZkqwNOqCa+AyPDK+kmXCagjh7SQma+xKFQgtLBW6e6 G7Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D63DM4pK; 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 d1si9457646ejl.368.2021.07.09.19.26.36; Fri, 09 Jul 2021 19:26:59 -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=D63DM4pK; 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 S232351AbhGJCZv (ORCPT + 99 others); Fri, 9 Jul 2021 22:25:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:41906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233044AbhGJCZS (ORCPT ); Fri, 9 Jul 2021 22:25:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5212560BD3; Sat, 10 Jul 2021 02:22:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883754; bh=Hy9kKlJWwUkCQ/3hWKbyzb+3jJ97A1OvJQWsXTDd0n8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D63DM4pKecYUYs2mHfPN+UDS1FVszss8Oq2AzwJcEtafpEP8WcNprVffdc4SmJL5B gI61X3Zh35Wcz9wX/0tZTcGz+pz6Ieh9iHDMP/HjYrnUqt94KYb/LTjJH2V8Hp71yf wjWv0L58mnkP8LvEkrDuv5io2rhaE3vwV3t+zLDecyQKJ4Zoa5bnZC+APbhgzmdQFv fOMCXwRFUEdFhwezODrU3rp/9JQDM58HZ2t1p6S/6eDfotcDMsdXfUzjBuDb54m36A igHv4ToBH4teCp9druiNXsBLrpHjyalpAenxKQxW3VQX7oM7RpRbkzyV/16JT5aFhb IRKd8/McYnigA== 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 5.12 029/104] scsi: core: Cap scsi_host cmd_per_lun at can_queue Date: Fri, 9 Jul 2021 22:20:41 -0400 Message-Id: <20210710022156.3168825-29-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-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 b93dd8ef4ac8..ce34da53af1b 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -220,6 +220,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