Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3667607pxb; Mon, 24 Jan 2022 14:54:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZUzlz5lMW7BgaQ19C/5cipL3w10GVgqGPL/Oj5FzoDGGps/yo9Oc+ocd/Y2OdViMzd3/6 X-Received: by 2002:a17:902:e743:b0:14a:f395:3b2f with SMTP id p3-20020a170902e74300b0014af3953b2fmr15990303plf.110.1643064850752; Mon, 24 Jan 2022 14:54:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064850; cv=none; d=google.com; s=arc-20160816; b=0Etax7LRfxRctnw5UndHBuULKWGntQBrXOCbPgLHLJmZ/lsQGdwe3Z97KCaJ3nHbXN ZzYboHKGeo3zdznJX/OjZ3z3It906yvUJrq1hbZ0w8T3nPfA/i/NlroWBc4E1CuTFZ2d AjldAdTfbLrS8OCpqjhdPQpEJ/jn+gzHg+C2y+w8iFsFXWc1k/7WOubPE96mo8bBiaKl i8COWRHyu0RVqUpJfUW6UPGnT8teBrUmzeFxKVB/bigIpyOxrJjmpv2+Nl4yK83e/kPM FfpSHSdf5X0i04gd62mLUAErzci/BU1+rZhYet+Lp+6uOb0d3s0aeRMi0n7n2ttC266q YUvQ== 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=HS4MjswmafB0sPlj6agmL7tHXgO0QkwdKVTG/MBzOCU=; b=ermrH2gB64zd6Cyy8box4jdOBbxxS1Zacw3MmRzaWW8hAL1rHfP9WnV+drZWvmkLR7 wo+qIIjzCMNFGcrNhCUyBqioTvGiRZmghyGgNys/f1WsNWMwOgJqtcmMYceoHYMlggov DzZojaLe6KyKBN15gkXsD3TcP53j+QRUcrx9gPysa2vkPxOtWaYnvSEcyldkYXQYHsFD sx+qklzcG/Iqs925vNdy25slgMvVF43ufItiHjwka5RF9keooCOnz0T6u88RUFHnhdP8 wJlzfFvfSvWb9KZAlEqLM42M1ZP5Lo2zPzxIJhBU9benDXbDNpqNMBG0dKp3aa5m8rDn j7yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nfoAfana; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 a11si6561353plh.42.2022.01.24.14.53.58; Mon, 24 Jan 2022 14:54:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=nfoAfana; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1839340AbiAXWu0 (ORCPT + 99 others); Mon, 24 Jan 2022 17:50:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1572925AbiAXVmv (ORCPT ); Mon, 24 Jan 2022 16:42:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CEC1C07A960; Mon, 24 Jan 2022 12:31:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E8D58B81229; Mon, 24 Jan 2022 20:31:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24A9DC340E7; Mon, 24 Jan 2022 20:31:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056294; bh=VJaVJEP2pnmf2hrnN+bNMJSsTptTmnZEfFyAfQj2aoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nfoAfanaQhu2XdVx2mXwzdcdZa/whSLkkt23ce/Vlmi5zlcuAuFJaSofgiDDybhEo WbPuiIdK15aKr4BR4DbIYjyZ98xYXmPRICZpsjezyu89pozuPXRFio2GKzDBGPW0Q4 XT/3pXqKVqRJI88w5jKAExIptPY4me5i8C42wx2I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hannes Reinecke , Sumanesh Samanta , Bean Huo , Ming Lei , Bart Van Assche , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 404/846] scsi: core: Fix scsi_device_max_queue_depth() Date: Mon, 24 Jan 2022 19:38:41 +0100 Message-Id: <20220124184114.906915693@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bart Van Assche [ Upstream commit 4bc3bffc1a885eb5cb259e4a25146a4c7b1034e3 ] The comment above scsi_device_max_queue_depth() and also the description of commit ca4453213951 ("scsi: core: Make sure sdev->queue_depth is <= max(shost->can_queue, 1024)") contradict the implementation of the function scsi_device_max_queue_depth(). Additionally, the maximum queue depth of a SCSI LUN never exceeds host->can_queue. Fix scsi_device_max_queue_depth() by changing max_t() into min_t(). Link: https://lore.kernel.org/r/20211203231950.193369-2-bvanassche@acm.org Fixes: ca4453213951 ("scsi: core: Make sure sdev->queue_depth is <= max(shost->can_queue, 1024)") Cc: Hannes Reinecke Cc: Sumanesh Samanta Tested-by: Bean Huo Reviewed-by: Ming Lei Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 291ecc33b1fe6..4fc9466d820a7 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -209,11 +209,11 @@ void scsi_finish_command(struct scsi_cmnd *cmd) /* - * 1024 is big enough for saturating the fast scsi LUN now + * 1024 is big enough for saturating fast SCSI LUNs. */ int scsi_device_max_queue_depth(struct scsi_device *sdev) { - return max_t(int, sdev->host->can_queue, 1024); + return min_t(int, sdev->host->can_queue, 1024); } /** -- 2.34.1