From patchwork Mon Jul 19 14:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 479986 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4258224jao; Mon, 19 Jul 2021 08:58:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnmzYQHOIAwZVx99MaMEReQaTdmQzsFLgA7wWBSpvFmnYk55VZ2BTDVuXTSOQakPdmIG6B X-Received: by 2002:aa7:d554:: with SMTP id u20mr35125539edr.50.1626710303042; Mon, 19 Jul 2021 08:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626710303; cv=none; d=google.com; s=arc-20160816; b=DEMRd3VaYxddmdmycCkK/xChTllG3V6p1x96u6MIsgTA6h1duWhZNZxo3XtvnImKFJ Bquk7QhBO+JS3beDmUtwExIgKeDLgO9zwQL9Zjee5UeKDO8OmEigInYOO67kOTOVkHPo idzQoDsixr9dCkmJovR/PadZ1IhQZ5sxmcCAYx0U60y7VS3/7KAt5m7BbyFjejRlGvGQ JtRtftvD8r2u6hEekYbv4MuPTzEzI+Pny6dIq8V2BKQgOrM8toFIHcd7jBqTNC5egc5N 1pVfu9Tx+pAbrIQ98EPwcxhy2urQ+3n+sUuTAz2FeExIx3PRGLG/qHuqvTazgQ2yGyOS uN3A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=emHBCNEmY1eqakEBrtXqbspPP8jEpWvszQtTwOQzs8I=; b=igral7ew5IiknD0XmDrXdpUEMi1KqWXNEvsrIFLk5xFvXvXoEPnzKGLzj6/FBVPI+a lY5Wp+uLVVL4RwxFlEFSc34tS8uSVdlvgcSmdAytPoPXjbujTPayyulfWyTeDetcCt2+ 9qMW4Z5BDZph+z+mJAa4nYZiqRWAZRyQj/kesFCjKS2uSNXG53hve7Wazx5N/Ht5QaZB OD9hUE2EXJsfaZWDRsExlIhmlioqYoA4esNHszhS0UnBx1fWiJUEr+V29Q1NN0bnZei6 /Y2Opu1Ky4LzNTNP4jWn+vXRzU+WhJzQyLUZlMKx3+krA+oO6Bcp5p1wd6917LBYb2yT Re1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yF4OOvGL; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la14si22045543ejc.142.2021.07.19.08.58.22; Mon, 19 Jul 2021 08:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b=yF4OOvGL; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346816AbhGSPR2 (ORCPT + 12 others); Mon, 19 Jul 2021 11:17:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:47814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346156AbhGSPOE (ORCPT ); Mon, 19 Jul 2021 11:14:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C4B78613F6; Mon, 19 Jul 2021 15:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710031; bh=F0zeVKDyFDPy6hrxyowfbDBSqgsKZ6SvVWTV12S9pX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yF4OOvGLjhehMawNUCj849knYw5HoWWmgd1QlR2VbrL5kvBV0ufZzYWWRpXU2Vbgp QOCbuOTWF/Ty/fFnQx8FbkBK4JgoC3jTGI5jJpeA8yOUcqy4Kx7FkYRSBR7x9sM/9F AP9hkArRW4qPJTb4MKEZfVku0XkYGOlqcQzjDirA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Lei , Bart Van Assche , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 047/243] scsi: core: Cap scsi_host cmd_per_lun at can_queue Date: Mon, 19 Jul 2021 16:51:16 +0200 Message-Id: <20210719144942.438101997@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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(+) -- 2.30.2 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index bd0dcb540f82..da3920a19d53 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;