From patchwork Mon Jul 19 14:50:15 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: 480000 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4270258jao; Mon, 19 Jul 2021 09:10:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9Rd9DrEz4UVgugxuy5IcXRLZBFLMI1NGabpavgwqUX0FDAvuou88bs32IHwzvw+VhHZe/ X-Received: by 2002:aa7:d48f:: with SMTP id b15mr36077913edr.271.1626711049485; Mon, 19 Jul 2021 09:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626711049; cv=none; d=google.com; s=arc-20160816; b=E29N0NlQhoa39a5Un0BvnyD2V/FxE73DC0ovqVmngoP7BXsbB5Hu81dbAA6y541s18 cOA8yKcSjISxYFQpopV4lupRpaGa2WwstT/sxLwiZO8ruD1/eu1RYEBYVQD3q11Manlh R3oSNxPxPPSSH+3kwdXApgnGTNiL2c0lHvWcLe42vchf2EV3x2PhvEYS0+QNZVnOy9Gq x2jgchg/0NC2By5cL20CsP0MdrWV/i71VhP14hX+vK1RkX69gobIhDd7n2o+vjs216IM dc800+/M4AMsC+G1lLMc1N4GvlLuVWhAzOZqywqNs4i6NMv8SxWUELSmHrGQoR/Vfx8j 9Y+g== 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=ZH3NMaaepG7C6h+5Ta8dXZzshkKVWJWHtCZy5HHwYaU=; b=UYiQDLv1F+w5liLWyvR49gSV7417frdUusESdS1T0ngFUA4Pre3Eb5rLUypgM6GtuX pMHPHHzI6ta2EJ7pb+PJB6iIzrpPQWqhIovXONr4Htqipyh4DhbVvLd1XQ4aUUWqB2RH 5jznCF8a1ZM9lKG4gMf/rJ6my/00B/WiFYtDkxXgFhRPhWycQeRbd8efgebBP6BTCNwL EjolUiGCkCKztOKVALIVvFtxqSE3zcaxNQjASVTJhH/cxM234chmgIAqR0obl7kI+rMj BLCz9AybxR7igD/e2c/+VwMG02mYt/68zUkxBfYGDTxRHpsxEzISowROjoQVzfiDIUb+ ZqXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fYc9Tvml; 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.09.10.49; Mon, 19 Jul 2021 09:10:49 -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=fYc9Tvml; 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 S1346388AbhGSP14 (ORCPT + 12 others); Mon, 19 Jul 2021 11:27:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:40008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348350AbhGSPYo (ORCPT ); Mon, 19 Jul 2021 11:24:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C7DD26008E; Mon, 19 Jul 2021 16:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710680; bh=o5sB9KxerTUtAssH5gxvO5ecDrhWnGIbI0lXebUmgbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fYc9TvmlPCbKyIWpI6MiYGuhfbZNNfKe59LGDGHVM1cNBnjab6Fgd2XwA1HE+SvOL D8rXzIaaQ8m8xWMp3gQsbjPRNzC2HUYVzFw3MYZuoxir3viN+a+hQxctMe8CVDN8gs Z+EQuIMSeCLHBct82Cm5lpBa96d4ZkFf5G5EaBTs= 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.13 069/351] scsi: core: Cap scsi_host cmd_per_lun at can_queue Date: Mon, 19 Jul 2021 16:50:15 +0200 Message-Id: <20210719144946.794199752@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144944.537151528@linuxfoundation.org> References: <20210719144944.537151528@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 00ec0b9e9dbb..b40bb6bd5f5d 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;