Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1150276pxv; Fri, 9 Jul 2021 19:37:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb9uDWTUCY/BS3KG1ymQpt6oofQGh60EXNDeRrAXs8UlEsU3tAgJYWY3v/8370i2FUwe6T X-Received: by 2002:a17:907:d89:: with SMTP id go9mr25923246ejc.165.1625884651975; Fri, 09 Jul 2021 19:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884651; cv=none; d=google.com; s=arc-20160816; b=HBBToGv4/usJZeC4aElefgfmsUhs5cwh4F2eR7yCS4PJCby0IBHsPYOIQFrtAa2cl0 lc/N83BYryT9J87ZOAvc1ndTKgRT1H0BP9gv7VigocYb3W/5Nm+Dbk2kwp5r11Z50wlY PfcTJSYsaIow3s2AxWM0bMFHsvUMyigcFoQ5juXhhBBs1Fc/TRsf6VWp6iyT2L/iQUIA XKLZ9E9+Enp/q0VX5ocKo9nR06PSwI9NywIDW+TniHioZCZ+Zm1P1tMZrYKfoskByuKN 8OrhDUS3f7XSdXYZMfvkpJkDbfBrA7P2VGAEmUmO9j5qP9+nxsphQnkHPqz2088alMvP bqxA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uY6X9ijjHlDfko2ehfvS8H0cOqIfwhSNw20iWL60QsE=; b=SZHyPKVnDDYVxBj4PQCcnYXG36Ws7Psc8YaU96PrwpVecbB4qD3JhLNxBvMI0fjC9b KwdW8bUTpu/X6bC9cLH+Ig8m+X72hLYkjVSQmwRPkW3QKui+NSQdIWz2f682l8Yr6Vwy Cvmd1hqFiYQA1qjgZxwM6To1CbS0cEqB7jFDrl6Qg1tSEmHISV/aqxXeR7e3VOCvLtl4 lbJNQOooY6oyI5cnweTwQka/bkzZQ16MMzplhVa6yf3KKPc8r+JWkq0Qh30wUYYldVqR +eStcrLuRa26LBiw9h7XEnpzJT+gdL09zf0IF5TYJqfmkXkAkgsqQMaNxXZw1FwC0BUv q4Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=selQSDO0; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l4si9305591edc.31.2021.07.09.19.37.09; Fri, 09 Jul 2021 19:37:31 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=selQSDO0; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234574AbhGJCjA (ORCPT + 99 others); Fri, 9 Jul 2021 22:39:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:53516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233820AbhGJCf1 (ORCPT ); Fri, 9 Jul 2021 22:35:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0380613EE; Sat, 10 Jul 2021 02:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625884343; bh=oep/XyLwiWnpfAbcpvPIkwg+OxWb5tuaJb/5MWBdVoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=selQSDO0ozxgQemBHuqKuH2omDZCsf1rcHDuHNvPIDttLtHyk2TSErIAAER5Q0W5P QkWUyuuBETjlrrjT916pGCXnvKwHnAoTgVSJL41YnwJ8vXxgPs9csLuEq4n3zeV2P6 +WH6YzOh03QHjxUCMSQfYzbxXPH3pbaLlAEgXQprDItHJpB9bJllEnSjoY5I2An7ks ShM2oVsrkteibWX7aM49V4RJOKg5zrhPQliYQh70poUtg7ygWCm78UFQxlfwSv4YeM RQbrfUMg8ESNsfNCIJBouoLKPZDyRDnpq0bcbyyXobCH2PR+NJbS+m4eGaV5yOFwqs b5af2T9leAaTg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mike Christie , Lee Duncan , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 15/39] scsi: iscsi: Fix shost->max_id use Date: Fri, 9 Jul 2021 22:31:40 -0400 Message-Id: <20210710023204.3171428-15-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710023204.3171428-1-sashal@kernel.org> References: <20210710023204.3171428-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Christie [ Upstream commit bdd4aad7ff92ae39c2e93c415bb6761cb8b584da ] The iscsi offload drivers are setting the shost->max_id to the max number of sessions they support. The problem is that max_id is not the max number of targets but the highest identifier the targets can have. To use it to limit the number of targets we need to set it to max sessions - 1, or we can end up with a session we might not have preallocated resources for. Link: https://lore.kernel.org/r/20210525181821.7617-15-michael.christie@oracle.com Reviewed-by: Lee Duncan Signed-off-by: Mike Christie Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/be2iscsi/be_main.c | 4 ++-- drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +- drivers/scsi/cxgbi/libcxgbi.c | 4 ++-- drivers/scsi/qedi/qedi_main.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 3660059784f7..a5b807c676fc 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -423,7 +423,7 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev) "beiscsi_hba_alloc - iscsi_host_alloc failed\n"); return NULL; } - shost->max_id = BE2_MAX_SESSIONS; + shost->max_id = BE2_MAX_SESSIONS - 1; shost->max_channel = 0; shost->max_cmd_len = BEISCSI_MAX_CMD_LEN; shost->max_lun = BEISCSI_NUM_MAX_LUN; @@ -5336,7 +5336,7 @@ static int beiscsi_enable_port(struct beiscsi_hba *phba) /* Re-enable UER. If different TPE occurs then it is recoverable. */ beiscsi_set_uer_feature(phba); - phba->shost->max_id = phba->params.cxns_per_ctrl; + phba->shost->max_id = phba->params.cxns_per_ctrl - 1; phba->shost->can_queue = phba->params.ios_per_ctrl; ret = beiscsi_init_port(phba); if (ret < 0) { diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 718a0335cfbb..9a5795d5a347 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -793,7 +793,7 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic) return NULL; shost->dma_boundary = cnic->pcidev->dma_mask; shost->transportt = bnx2i_scsi_xport_template; - shost->max_id = ISCSI_MAX_CONNS_PER_HBA; + shost->max_id = ISCSI_MAX_CONNS_PER_HBA - 1; shost->max_channel = 0; shost->max_lun = 512; shost->max_cmd_len = 16; diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index 559d8bda4cca..01f5ebee3229 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -339,7 +339,7 @@ void cxgbi_hbas_remove(struct cxgbi_device *cdev) EXPORT_SYMBOL_GPL(cxgbi_hbas_remove); int cxgbi_hbas_add(struct cxgbi_device *cdev, u64 max_lun, - unsigned int max_id, struct scsi_host_template *sht, + unsigned int max_conns, struct scsi_host_template *sht, struct scsi_transport_template *stt) { struct cxgbi_hba *chba; @@ -359,7 +359,7 @@ int cxgbi_hbas_add(struct cxgbi_device *cdev, u64 max_lun, shost->transportt = stt; shost->max_lun = max_lun; - shost->max_id = max_id; + shost->max_id = max_conns - 1; shost->max_channel = 0; shost->max_cmd_len = 16; diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index fe26144d390a..7665fd641886 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -629,7 +629,7 @@ static struct qedi_ctx *qedi_host_alloc(struct pci_dev *pdev) goto exit_setup_shost; } - shost->max_id = QEDI_MAX_ISCSI_CONNS_PER_HBA; + shost->max_id = QEDI_MAX_ISCSI_CONNS_PER_HBA - 1; shost->max_channel = 0; shost->max_lun = ~0; shost->max_cmd_len = 16; -- 2.30.2