Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1146761pxv; Fri, 9 Jul 2021 19:30:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylDkcv73afJlys10mnvbM8zGwUkYNDlG8Eb6n1B17wCY9JqqOQ9HBgZlN1o3iGR/Iq0Yo3 X-Received: by 2002:a17:906:8683:: with SMTP id g3mr21817038ejx.126.1625884207640; Fri, 09 Jul 2021 19:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884207; cv=none; d=google.com; s=arc-20160816; b=rlo5WHm4Pf7jxXbHcoWfxsx7yZMc6VXlAVcqeObDuuCw3pbgW98FFQKvqUuhsatWQZ AM4OhXzhmf2gYstzX4Na3vC85RgDjc1am2fqm9+mur3/qVp0V+f28D4UN0SAguyhHeGj ZEI4lwOkKxPFFSuq3l+CB+2qk8S8UfMY78PqlbhHhW1rKjJ07B78+MTcsnroeKeWZkvo woX8sj6ue7bPrIrExkY5NXswGwVPE6FxIiRqq9dkgHk71H27HcnydeaD8scD2QDpRinI ciokxN6Ld8ty54xEe166lYQG8szv+NdhICzYokeoHmRvUPIxbcOc4frlCeZaIrQQVqwM kwcg== 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=RkpCAHdbXig2SzQtANhkKCObOmChE/J2VnoPahkq6cfF6g5UIasGCh+v60ZGzmDF4y 1Ehw28cf2cyPLP6LUvKr6MjG+6KnoNaH3Ut9x0QCOf9t77dO/1bfDh0+u7sM8sGQk1qb iP0eOaOryGFmMPd3wVbfy7NOB62ysbWH265FPe1jGl4yaZFOPYJvnqqfHzK7s3lwRBkm ic2Ui2L0zs2iVbgXR1MMnyvH8j8an+8G70KkKre2kt9aLYmDrj05zEahbDhdpBtLOTBg ai5s8jWOCpjmKmimFX42yLwHedvqLwzv9BXlYhJgPQplcwY4dTREmghhQVcyxkPL2BAx YnCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WlSlfqV7; 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 h93si10931678edd.134.2021.07.09.19.29.44; Fri, 09 Jul 2021 19:30:07 -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=WlSlfqV7; 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 S234347AbhGJCbJ (ORCPT + 99 others); Fri, 9 Jul 2021 22:31:09 -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 S234004AbhGJC2K (ORCPT ); Fri, 9 Jul 2021 22:28:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DAE9E613FC; Sat, 10 Jul 2021 02:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883904; bh=Hy9kKlJWwUkCQ/3hWKbyzb+3jJ97A1OvJQWsXTDd0n8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WlSlfqV7/NpWUWDLyT6Hkww0JTNMnbRrZ0xWDRmC+T4Umc26HqStEUpE7WlODfX1G xtiroG/ZVAT/MuOX2iwlB3CWLS9aJCC4AulnSr0MYRnWxTOPdU22ZzoQnxmRU7fqa+ OBa8nM8yIpuyavxRaNIdPiv8oaBxzxBqDRxdsjMyEP349QL0H81fgOYJlDE6Xx1zUC G5Pn/9yhc6iept/Iodr2MJUjbYd/WYhFFbUEegcyXFMi9jxP5yYBVgjbqrudYXTwY4 YGWuIfXco7mPqeTUZ4FNyiV8kiabTeMgYcLLEo46uOrY1jmFNx19q6w1HQIuPq/Qqx 2AUBwPf7QWLWA== 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.10 27/93] scsi: core: Cap scsi_host cmd_per_lun at can_queue Date: Fri, 9 Jul 2021 22:23:21 -0400 Message-Id: <20210710022428.3169839-27-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022428.3169839-1-sashal@kernel.org> References: <20210710022428.3169839-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