From patchwork Mon Jul 19 14:52:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 479923 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4237870jao; Mon, 19 Jul 2021 08:35:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp6X6A10S7QOJdX17saDG3in0tv0IOHemixD/lhlGLHA1DvszbtZfppSNCCRApwy7DQQOb X-Received: by 2002:a05:6e02:138b:: with SMTP id d11mr17539815ilo.229.1626708807714; Mon, 19 Jul 2021 08:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708807; cv=none; d=google.com; s=arc-20160816; b=DxFq1iw7qiTv2PihlDdxldOslcv/JiI8H8cjHsWWTf3Oxu+zcojtPXyQCrRhaV54rr 0bV207W6f2B6sDEAby4WGtacOJWpHW43FEigqQbzcTMe7IHzgabh8jXw4ZwlieajA5nk c35wyk19UhyBE6iXcDmK1ZVDJYMIryu3in8rxclgvH9qmJxTqrzlpWsFie1Cq4fH86ek eGdAy/HnEtKW/XT51mZ53sCjLQw9kInV2v9DHMHIFWpJddWNclYpTLbzZSa6QbypE2Qp 3iFlwlkP7Wny6cgr3HuBAV0NALBMiq6LfsgVy4SNiIrTeuQEJpMlZMinpiL/kY9rMZDI S1Bw== 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=awJ1i8CuC6cdvKvL2SFLGo82F2zG3zZvnvgf4slGrw4=; b=hMDd3X56CWeMzfzY/KztOUbuFsT6b2iRyp0MLwVFJItXF5KExFLr4GGZWOpmCNOh1K 4Vj8n2lA0KuiJzrwcGUMbs+utTKpOROdB8p+hYMX2q7Bw5ysPYRfl6RGYX307YYpXP/I Ckkx01/eecjDlMXpV4kMoSnsYMkCT+say4FtIFD6yqZriUgIeYKA2uPnaF/lSVKnNjkt kQllT4qrVUX4z4WCm5QpjNdt1H18l4eXxSflteqbMMu7tk9P1EamS1gw9VCBmUkVAA37 TYaLEiYt2DgR17V5d5/gt3m5aVbM9aDvWpMXnwrKnFRFPqAEQ+GWHm7sc+uUElNPwWEi PNBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ysp4bP8V; 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 g5si10245056ilk.74.2021.07.19.08.33.27; Mon, 19 Jul 2021 08:33:27 -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=Ysp4bP8V; 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 S240606AbhGSOwp (ORCPT + 12 others); Mon, 19 Jul 2021 10:52:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:40456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343642AbhGSOsb (ORCPT ); Mon, 19 Jul 2021 10:48:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C32ED61205; Mon, 19 Jul 2021 15:24:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626708259; bh=EACN06jeR+HmOakUjwaxQakXBayQUM2oTJ89JBlOwIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ysp4bP8VSjRQUmamNk4PRb2e5p0k/SzWBP8YMVE5i0bPd9tDRr33KO509+1UeHBfC Zxba1hEGkhJpDwdro6GPTWNZeNJsNmhh90S9/L00dP0MZfxfKQUfxzr9O2hHUv66VY Fs1lCAXuOaVC+xfgve7FupFKQjtaCC5fFU3pyWxs= 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 4.14 242/315] scsi: core: Cap scsi_host cmd_per_lun at can_queue Date: Mon, 19 Jul 2021 16:52:11 +0200 Message-Id: <20210719144951.377595343@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@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 20bb5a7dca3c..ec976b93341c 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -213,6 +213,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;