From patchwork Mon Jul 19 14:52:10 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: 479975 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4252554jao; Mon, 19 Jul 2021 08:51:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr9xPKQ+zH1gTkIuFCmCU8Q6rKWaMQxw7cWMzD7INgham57sSg3eypjQ8WeLrm21wne3NX X-Received: by 2002:a17:906:3c14:: with SMTP id h20mr28184801ejg.176.1626709860951; Mon, 19 Jul 2021 08:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626709860; cv=none; d=google.com; s=arc-20160816; b=MTGwww1l5cKSgO0ZABWmLJOs/qFcSt7nvemPquRSMQbyB034N5uz2SxdafrN28gZYd WXM350KAzm3gPpr583HGYFNSb8lz1AJFsp6gnWgTJJiBL1uCedIwao+vPhyORg63RPld eb+ofDhtg0RIJDpERvJuyqPlrLopNt1RkBJ+sUaKhmK4VawU6T6ATUfGwkJmLLwtxerp FKLc2bteWaLri/7lM8VENaoqEhzavlpedulRBhk9BUMsdIP//QxSL159u/zu6YTQSgdz urSHDKA5KaKlAT/QE1Rr7mh5LMpUylszBw67rRjS5izMZpLISe6+PpDFpoPhAuz6rKgj 9L+Q== 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=RtV/7uyPQXskGFKSW5YcNMrzKgdxwUYAe4RX0j4q3N8=; b=IX4f3lwmIvZZ+QZ00pUfZU8CGZrFPilQepEtQh/xVcES/PRwDc/rSAlNrNGea2ODHv y8wzPGvj9vn9D+dAPC6vyKwPbHv9omodRVMwVj06XMhZkppxnR12/HxeOWR2E0XhW0wb U4DaKug1mZMSB+56B2cBFNsi0rbGLw2YtOdlTeIW5fKU1V8NtbEK0fKiuEzg+t2d0GCc THWQVG5Qi9dd78VKNACgorioRRU/NgD3dMr6aHSndLQ0VzKty4fbxDjVApQa2YlnhtAN cZR79/SQLUbn/BkGTXea9bM3/26ep/GqkoILbA/9KzsyhCm9b/vuoQ+i3LOMQ44jdj/F 6upw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Sag/CqF3"; 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 x22si21782145edd.466.2021.07.19.08.51.00; Mon, 19 Jul 2021 08:51:00 -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="Sag/CqF3"; 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 S1344050AbhGSPKJ (ORCPT + 12 others); Mon, 19 Jul 2021 11:10:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:40562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344689AbhGSPH3 (ORCPT ); Mon, 19 Jul 2021 11:07:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1FC4760FD7; Mon, 19 Jul 2021 15:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626709665; bh=iifnX91AN+L2jLWiw4nnHxUcq6QolYgUh6Mjh5RIBdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sag/CqF36LXrylHrL/ay/u5V/od+g5MTZwGeW+Uxurnt3G/pbHyJGlyRPgnoHHf9/ UJbIQNTAW2hB5HHpwwUD7gHlVG5W+O1anFOyTupY8K3Cz/D4sVxEBADHlIVQfvU1h4 oNGB+S7qSfzfdX0043U4/nP9Ihx+AnXOLyXPxnH8= 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.4 022/149] scsi: core: Cap scsi_host cmd_per_lun at can_queue Date: Mon, 19 Jul 2021 16:52:10 +0200 Message-Id: <20210719144906.767188521@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144901.370365147@linuxfoundation.org> References: <20210719144901.370365147@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 119c292cdb8f..7c736e4ddafe 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -219,6 +219,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;