From patchwork Wed May 19 14:31:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 442439 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1383770jac; Wed, 19 May 2021 07:35:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcmrFZZoUH+Bwu3ugoufu3lTcJ5IH/DFrsy6GnhRJiQ9QmU9xF16o4Egj0PHbep48y+fDz X-Received: by 2002:a05:6e02:ee1:: with SMTP id j1mr10713265ilk.105.1621434937384; Wed, 19 May 2021 07:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621434937; cv=none; d=google.com; s=arc-20160816; b=x01kN8JT1eXFfyfOlCKDA3H268OhIw3XoW+mvbvkEpmTPGuEsigZvFx9u/KFGTbE5f Po0qFn6QZ04coiIasalvk5huSOJ4TN58HFkt8tGEJAaw46xWo5p3Wn6lxBrFKdB/QyR0 H2M4dsc+DY3pRy1AIBg3IkkECgbv5cbQ44vhNBJe+NhrLpL0bG+IMLBzQOv7WUXw3C/f /gYfbKZz+l0jWKHVJlsEnzUTrns0anww6MSVjMmB1cZ5c19g0p+juwd2nBFtkdnspSpX yL6nc8vdyk9d+Bzf/mefEGWYKKqgpQ+oiacpNNrhkZWEkygemI1BprqPJ6NrqPRFLySw xucg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=1bL3JmS00v2WpTBbUh+sqmVi9fscTn0exbbwLh/TWM0=; b=r34zILYZ7XJKCUl+WzjYL3u2nu33NRwIDqMUw5SPtEYBmZUG7GrsBxC5jQ2PX0Ehol gnydJSIQcniQ5Z+K5yxM/2bmFrLUm/Celdxy7NzmDL7BrMyi9gv4zHLGIbFGmYbd/aaI AovntOkItcVh6PANvaNOuiGBThlm2xMy2syryatephhj7L4Pf7nvOMfASi2jLn/q8K9t E7X5nhn2KiLQTRux0qdhQfn+3G5xrBddx/OacT4At6f1kp7wflxH0yP97hEC2hxD2Muu noyEfWBvw/P3CXn5/xu95HnknxRx6vJ98K9hdBq5ZIUkTT64eib8JauM+m55G/t58yju f7CA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si4093731jal.96.2021.05.19.07.35.37 for ; Wed, 19 May 2021 07:35:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347956AbhESOgz (ORCPT ); Wed, 19 May 2021 10:36:55 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4537 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346231AbhESOgy (ORCPT ); Wed, 19 May 2021 10:36:54 -0400 Received: from dggems705-chm.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Flb1n4ds4zsScl; Wed, 19 May 2021 22:32:45 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 19 May 2021 22:35:31 +0800 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 19 May 2021 15:35:27 +0100 From: John Garry To: , CC: , , , John Garry Subject: [PATCH] scsi: core: Cap shost cmd_per_lun at can_queue Date: Wed, 19 May 2021 22:31:02 +0800 Message-ID: <1621434662-173079-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Function sdev_store_queue_depth() enforces that the sdev queue depth cannot exceed Shost.can_queue. The sdev initial value comes from shost cmd_per_lun. However, the LLDD may still set cmd_per_lun > 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/ Signed-off-by: John Garry --- Earlier patch was in https://lore.kernel.org/linux-scsi/1618848384-204144-1-git-send-email-john.garry@huawei.com/ -- 2.26.2 Reviewed-by: Ming Lei Reviewed-by: Bart Van Assche diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index ba72bd4202a2..624e2582c3df 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;