From patchwork Mon Jul 19 14:52:02 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: 480022 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4284017jao; Mon, 19 Jul 2021 09:26:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUma36EocAJlMn2mBoDr0Ml7HaeSWksivZx2vCNT3hKj9F0zStTVLoXy2gwK8CsBkp5YM7 X-Received: by 2002:a17:906:715b:: with SMTP id z27mr28384540ejj.523.1626712012382; Mon, 19 Jul 2021 09:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626712012; cv=none; d=google.com; s=arc-20160816; b=BAHTKvb58laLlOZDLIK+H9J7/+gW89Kvd1jlMdG2bweHVOy5e+t9/0wqUu6ZTMWFhL I6zzTxUuSXLd3aE1zgk3TPvA9MYcoRamwExSqS+3LXqUxPxzieT8IXIUpVeL5o0uXpp2 jaWgVyZSj6tyJq5rvM+K4fSN7T0QpZKNKcMVx1ZG+FgxtZa9Xxiyt7CTjpAPEBEBKViL szp1CILcqIcfLPyVUfpoSg1EGF7wm+NHwbvhr2nMWf2MUNhNSyAxjMiwijCvSfp2nBWO AjdU0E9ftjvrRD/lNrx13n7icI66ossfuJ3nEz3FW4NQVyxpheIk/G+G+tk3YceKJ7j+ IF3Q== 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=krBCDnYlqO95nmo/eHbJPZiAL9skZJc5sG9l+jgLJACacKfrdlAUfBGK4jrAawJ001 mLRBeduxZlp1t9dNBgYyYKi9K+8CO5B5derG6QFyncnb3PhuZxWeBI4UJgGZxEQLQTmJ hZx4j+R6aqznMfkTQclawWAvtMoy3JvtxQBKgSh/0XkIfjAVuFOfZ7JMcsj5UEwGgkIx CcO6lYpN/Vj1sp0r5pfFCHZmSOmNm2UIPkB4PKU766LwuDCuAInbAsWhPoc5lHbwi//4 3xLvKFCC/qn4SDm+OHVVc9id+UjDK8TZ47IjjRcTzAJNb45QDw7QrwmHKaWu4RP24EbN j49A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=08jNJGin; 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.26.52; Mon, 19 Jul 2021 09:26:52 -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=08jNJGin; 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 S1343979AbhGSPnm (ORCPT + 12 others); Mon, 19 Jul 2021 11:43:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:36640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348143AbhGSPjz (ORCPT ); Mon, 19 Jul 2021 11:39:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BDB4B61221; Mon, 19 Jul 2021 16:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626711591; bh=F0zeVKDyFDPy6hrxyowfbDBSqgsKZ6SvVWTV12S9pX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=08jNJGinJoDwdtssR9WJt/faigYciC4HSCyA/7/01LHAbVeMFXRfG/Ix+7scaQP7p ddH89uY6LKv03CbH9IXQHGUl3AFgv90bWuRCMCU/six2045JL40Y6/r1hzuWyjYp4M gFPxHRRnBeu44yUEOnHf9P+d2jw5mUpWqsO6LtTg= 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.12 060/292] scsi: core: Cap scsi_host cmd_per_lun at can_queue Date: Mon, 19 Jul 2021 16:52:02 +0200 Message-Id: <20210719144944.492215102@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.514164272@linuxfoundation.org> References: <20210719144942.514164272@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;