From patchwork Wed Feb 7 21:39:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 13549091 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98C0612FF7D; Wed, 7 Feb 2024 21:40:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707342025; cv=none; b=GDwaeGyajn4pcpeiBhpcceHt2D5UG2IcwVJ/YFVXixjjVfpTiUfP3jigCh//VNxkMxPTfRimmRY1NiPgc1eEzfop6froW1AeDVGTM1qK4D6r1uUhJeldTR2BgalK9bIvi3DydGWP1FMTWELPuQA4tFP4K99ON8e1PD1UH8RRHhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707342025; c=relaxed/simple; bh=7fxBm/u2hpuDrFKxyT9bbbVkeIk2RFIy8x4CrTkZ0IA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YJ5Iq9g0ykyLHrqKzMuLABM5Ew2aPizIWiuvfl/JKNMCD1R6XgVB+Nx2fGpT6L1OPU3oASiFwQoQrjRdR99laKCEz29Y8I7NOwacbxDzwha8T5T7U/34+bPBsD66pUNvgB86IC8h/6JvschAFvaxDqFTaMfDRzknVeFZJQFuZio= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sLEAdqQ3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sLEAdqQ3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10235C433F1; Wed, 7 Feb 2024 21:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707342025; bh=7fxBm/u2hpuDrFKxyT9bbbVkeIk2RFIy8x4CrTkZ0IA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sLEAdqQ3K80SAgWPWulLyIDYM6OpLTPdkqpTvk8iymqcsF9cLDVOZv67/iDvyn8xq eNzExg3CQm2BX4xKjh8hqh5l+2epbZQdphfbAqfBtbgQBnGDHU6mc0D5Ivs6uKjXNO +ZetRlloDLFyngqH+8Nm0i8VTFp+IkdK1/uXrJEB3cNx096Wz1Y17BRO/GpyfgTckK MCkwkZag45y8pLhz1mEgqbD8AZKGHkoxWHy86m4T9+TywiCZc3fTd43t2ag6c42kpr s7i8n+ujtDnqYCchea+hkHbmPLPLdnrBrl1MaNvmQ+XnfAakzcvl9uqrI+0T6bQ58W uT0Qw0JieF8NQ== From: Niklas Cassel To: Jon Mason , Dave Jiang , Allen Hubbe , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas Cc: Damien Le Moal , Frank Li , Niklas Cassel , ntb@lists.linux.dev, linux-pci@vger.kernel.org Subject: [PATCH v2 1/4] PCI: endpoint: refactor pci_epf_alloc_space() Date: Wed, 7 Feb 2024 22:39:14 +0100 Message-ID: <20240207213922.1796533-2-cassel@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207213922.1796533-1-cassel@kernel.org> References: <20240207213922.1796533-1-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor pci_epf_alloc_space() to take epc_features as a parameter. This is a preparation patch needed for further cleanups. Reviewed-by: Frank Li Reviewed-by: Manivannan Sadhasivam Signed-off-by: Niklas Cassel --- drivers/pci/endpoint/functions/pci-epf-ntb.c | 2 +- drivers/pci/endpoint/functions/pci-epf-test.c | 5 ++--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 4 ++-- drivers/pci/endpoint/pci-epf-core.c | 6 ++++-- include/linux/pci-epf.h | 4 +++- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c index 0553946005c4..43cd309ce22f 100644 --- a/drivers/pci/endpoint/functions/pci-epf-ntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c @@ -1067,7 +1067,7 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb, else if (size < ctrl_size + spad_size) return -EINVAL; - base = pci_epf_alloc_space(epf, size, barno, align, type); + base = pci_epf_alloc_space(epf, size, barno, epc_features, type); if (!base) { dev_err(dev, "%s intf: Config/Status/SPAD alloc region fail\n", pci_epc_interface_string(type)); diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 18c80002d3bd..15bfa7d83489 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -848,7 +848,7 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) } base = pci_epf_alloc_space(epf, test_reg_size, test_reg_bar, - epc_features->align, PRIMARY_INTERFACE); + epc_features, PRIMARY_INTERFACE); if (!base) { dev_err(dev, "Failed to allocated register space\n"); return -ENOMEM; @@ -866,8 +866,7 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) continue; base = pci_epf_alloc_space(epf, bar_size[bar], bar, - epc_features->align, - PRIMARY_INTERFACE); + epc_features, PRIMARY_INTERFACE); if (!base) dev_err(dev, "Failed to allocate space for BAR%d\n", bar); diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index e75a2af77328..ba509d67188b 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -446,7 +446,7 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb) else if (size < ctrl_size + spad_size) return -EINVAL; - base = pci_epf_alloc_space(epf, size, barno, align, 0); + base = pci_epf_alloc_space(epf, size, barno, epc_features, 0); if (!base) { dev_err(dev, "Config/Status/SPAD alloc region fail\n"); return -ENOMEM; @@ -550,7 +550,7 @@ static int epf_ntb_db_bar_init(struct epf_ntb *ntb) barno = ntb->epf_ntb_bar[BAR_DB]; - mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, align, 0); + mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, epc_features, 0); if (!mw_addr) { dev_err(dev, "Failed to allocate OB address\n"); return -ENOMEM; diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 2c32de667937..1d405fd61a2a 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -251,14 +251,16 @@ EXPORT_SYMBOL_GPL(pci_epf_free_space); * @epf: the EPF device to whom allocate the memory * @size: the size of the memory that has to be allocated * @bar: the BAR number corresponding to the allocated register space - * @align: alignment size for the allocation region + * @epc_features: the features provided by the EPC specific to this EPF * @type: Identifies if the allocation is for primary EPC or secondary EPC * * Invoke to allocate memory for the PCI EPF register space. */ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, - size_t align, enum pci_epc_interface_type type) + const struct pci_epc_features *epc_features, + enum pci_epc_interface_type type) { + size_t align = epc_features->align; struct pci_epf_bar *epf_bar; dma_addr_t phys_addr; struct pci_epc *epc; diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 77b146e0f672..adee6a1b35db 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -15,6 +15,7 @@ #include struct pci_epf; +struct pci_epc_features; enum pci_epc_interface_type; enum pci_barno { @@ -216,7 +217,8 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver, struct module *owner); void pci_epf_unregister_driver(struct pci_epf_driver *driver); void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, - size_t align, enum pci_epc_interface_type type); + const struct pci_epc_features *epc_features, + enum pci_epc_interface_type type); void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar, enum pci_epc_interface_type type); int pci_epf_bind(struct pci_epf *epf); From patchwork Wed Feb 7 21:39:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 13549092 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A65BC1384BC for ; Wed, 7 Feb 2024 21:40:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707342029; cv=none; b=FpmiYuWsPIRUTTRsc3o/Swrx7gS8nqqbe+7IbSNoA4PmdB7giJW+cIPFfg8IuOhnRxsA5wB6tazDvsjhV35hb+65nbJss6l6LE7j2xpqdJshfXTTnxM3wLjxEUEMLKa0dcVtmeGgDQqXSKNMUjRkUdP/HVFWi0WFXY1Tme8vb14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707342029; c=relaxed/simple; bh=w6QU8DprQSPzQIrjxMXngpDc2DP7OjoMXjmp2NuW8e4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qt46ap7QuRHcdbJgxWKRMn6MevDyj535dlcXvFUBeSBCPsDx4r14NEdzqwI0NOqo8Dzbj6eqHLe2jVU5vlN8MgupurU5EfCaIiyEyqLQHcpCsx5lvn3/VQXldhXKm7vQvwe3eI0puivaWD9DpMU7kjAdbbSdywv02vrAollZTlY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rgCpOrMc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rgCpOrMc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AA75C433F1; Wed, 7 Feb 2024 21:40:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707342029; bh=w6QU8DprQSPzQIrjxMXngpDc2DP7OjoMXjmp2NuW8e4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rgCpOrMciJ+VHYwkoEn+aHlmrlI0PknnAldFXON7XBCqyNtllPVN4Z8l2LciUQ8Q0 zXLY5K81CWXie2UETtmTLwtL1yghZ2pateO47mTE3WstHKH/npy57phwa+b+kYCJg7 qhlZ2ZCS3IDHGaD4xMvt43O/MUuCkrssVYUg7gycnK+RJjv5i17FbiJ9fFxDp+IjKU QuBWKMd7RsDmBd9D4wcAD4F+1yhysr5+Nl9llBfP59fTNxLjyipPn/NQZl3nHsJUMa bEaJgXsLIaJNz6Tj5vW+80fxOgUoOYnMfxm0h1pZ764jeAP/1AFzU08MN1W2TiJl5i w9RYmfMHMMkKg== From: Niklas Cassel To: Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas Cc: Damien Le Moal , Frank Li , Niklas Cassel , linux-pci@vger.kernel.org Subject: [PATCH v2 2/4] PCI: endpoint: improve pci_epf_alloc_space() Date: Wed, 7 Feb 2024 22:39:15 +0100 Message-ID: <20240207213922.1796533-3-cassel@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207213922.1796533-1-cassel@kernel.org> References: <20240207213922.1796533-1-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 pci_epf_alloc_space() already performs checks on the requested BAR size, and will allocate and set epf_bar->size to a size higher than the requested BAR size if some constraint deems it necessary. However, other than pci_epf_alloc_space() already doing these roundups, there are additional checks and roundups done in e.g. pci-epf-test.c. And similar checks are proposed to other endpoint function drivers, see: https://lore.kernel.org/linux-pci/20240108151015.2030469-1-Frank.Li@nxp.com/ Having these checks scattered over different locations in multiple EPF drivers is not maintainable and makes the code hard to follow. Since pci_epf_alloc_space() already performs roundups, add the checks currently performed by pci-epf-test.c to pci_epf_alloc_space(), such that a follow up patch can drop these checks from pci-epf-test.c. Signed-off-by: Niklas Cassel Reviewed-by: Manivannan Sadhasivam --- drivers/pci/endpoint/pci-epf-core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 1d405fd61a2a..367e029f6716 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -260,6 +260,7 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, const struct pci_epc_features *epc_features, enum pci_epc_interface_type type) { + u64 bar_fixed_size = epc_features->bar_fixed_size[bar]; size_t align = epc_features->align; struct pci_epf_bar *epf_bar; dma_addr_t phys_addr; @@ -270,6 +271,14 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, if (size < 128) size = 128; + if (bar_fixed_size && size > bar_fixed_size) { + dev_err(dev, "requested BAR size is larger than fixed size\n"); + return NULL; + } + + if (bar_fixed_size) + size = bar_fixed_size; + if (align) size = ALIGN(size, align); else From patchwork Wed Feb 7 21:39:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 13549093 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E376128374 for ; Wed, 7 Feb 2024 21:40:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707342033; cv=none; b=nvNwldbtZOGKoe2eS42+hREbJnRvz0++V5eWvNJdifapd10XdWMGxe6Pu+FjZkMPmb6cDZZSpFu8dL/Av2WEYQaWxXRO4UnkPK4fpvzDFQUOch4PAdynHCiUSPMx9JPXq5EPoZsvvR4szm56FlqcMPx25GI2Rh44kDHTfEXwNWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707342033; c=relaxed/simple; bh=N7ZKqHPGXfWt+MkG5VO8F2GODx04e0Kf0WyC2JoHZzY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QAoEeiGa7C/Nd6S7MivVlX48o1fyy8kjRC3fWLG7c2ATLanrfmd7hAnNMVkt7JFpKm9rcXJMK9SFph/AcF1Pnilp37RG/Nvd6tBN2qhcrhDFM6owUDAhLLDnrAJ5BTu0RXGxfXfdcnps6Luqk5e/d5PcPLkbWj/1+YU4pJbajO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aVG2fZPS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aVG2fZPS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19338C433A6; Wed, 7 Feb 2024 21:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707342032; bh=N7ZKqHPGXfWt+MkG5VO8F2GODx04e0Kf0WyC2JoHZzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aVG2fZPS6yGNkMtEzj9ohXqxM4zDnz74e9NgVV8mCcpsnX2X7pnWu8tGYMKdYlwMk bUSdxeStVcWFIoNUNMTEDpYpjRouGiIIBLlzklcJUEMyLWerOyIgCltp/Z/MsBNOTO iFPOVG3hd8l/CfHHkFN019MsmrQGg/gATyUoFE+mdpkFL4av/nZCSLDfn4wEArR2w4 PIC5D4jPyWCzeYUjkW40WIyaonD3YTdt9q4H5KMk66PViFSiuW/FKWN9obHxapToBM 6WhvawAmlCsywJbvTbvB2bX8eLAoObqN/7Eru8uvpl+ILzh7u7Gd9S2sP+fAYzISBH LXjH0v7ppt80w== From: Niklas Cassel To: Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas Cc: Damien Le Moal , Frank Li , Niklas Cassel , linux-pci@vger.kernel.org Subject: [PATCH v2 3/4] PCI: endpoint: pci-epf-test: remove superfluous checks Date: Wed, 7 Feb 2024 22:39:16 +0100 Message-ID: <20240207213922.1796533-4-cassel@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207213922.1796533-1-cassel@kernel.org> References: <20240207213922.1796533-1-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove superfluous alignment checks, these checks are already done by pci_epf_alloc_space(). Signed-off-by: Niklas Cassel Reviewed-by: Manivannan Sadhasivam --- drivers/pci/endpoint/functions/pci-epf-test.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 15bfa7d83489..981894e40681 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -841,12 +841,6 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) } test_reg_size = test_reg_bar_size + msix_table_size + pba_size; - if (epc_features->bar_fixed_size[test_reg_bar]) { - if (test_reg_size > bar_size[test_reg_bar]) - return -ENOMEM; - test_reg_size = bar_size[test_reg_bar]; - } - base = pci_epf_alloc_space(epf, test_reg_size, test_reg_bar, epc_features, PRIMARY_INTERFACE); if (!base) { @@ -888,8 +882,6 @@ static void pci_epf_configure_bar(struct pci_epf *epf, bar_fixed_64bit = !!(epc_features->bar_fixed_64bit & (1 << i)); if (bar_fixed_64bit) epf_bar->flags |= PCI_BASE_ADDRESS_MEM_TYPE_64; - if (epc_features->bar_fixed_size[i]) - bar_size[i] = epc_features->bar_fixed_size[i]; } } From patchwork Wed Feb 7 21:39:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 13549094 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D054D128374; Wed, 7 Feb 2024 21:40:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707342037; cv=none; b=HdYOQoFnjKm0KYYkVNIBmyFAUSnyHaT7fzB6Lqxsl1bZGoFBIGUDaKAvhn16O7GubnpTI6WTegFElJgUSEmtfZ1uWTUQRbBC52peUi8+LfDnUub18t/oAR3ub9C7B9wrbg+7LAqCUxpsLngIR7frUND9JNQFKg+ggSSuGa0MFNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707342037; c=relaxed/simple; bh=t1zaT2PqWJmTPD8CEXsvLf7gjiZz+GzDPD84WF2ALbk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kpA0t0YvxEA+rf9iEReTIdIuX15pRfm1XtHd7uKGzq7id9ooT5UjqRZKCIEw6crZ+9pzrr9rLOcmQ/zWEWwXrrVKBA0KIUYX+74p72laEVNVEAfA908xUVyqWF2TUKkslJHapOX2w2jbeUObQXtdiVIAmJ95D5B2ctcNX13pBz4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XAlMkAkQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XAlMkAkQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCEADC433C7; Wed, 7 Feb 2024 21:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707342037; bh=t1zaT2PqWJmTPD8CEXsvLf7gjiZz+GzDPD84WF2ALbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XAlMkAkQFnmNijD641qDAcd7VaTGaSXSCSGvFklWFQSw4ksPQGcI5u56Vn0blhzP7 /TZkqtzbpBSW5ivJ7acNBK6M+4VrZJZg3Sg8rPuLTNGTc1kyq6lhGEl6aySjfVb/i/ 4YhjqfgEEh8lozyo51MFER8EUw+43rkbLbcTozeKWMX9pf+C5G3Qx8EL20qARfK99Q MyTF9DUzQkgMGW+a3mDwWATpuQMnH/IoDdZKDv3jzccIsYzrN6VGI6aR7RGyHeEO3e IH9CmITZ381iVg1uiFEkdElYE3S0ARyNxaLvKHuiN5/Ds9dFVssWSB0hnBZRSySnal 5xnwg5/U1lP6w== From: Niklas Cassel To: Jon Mason , Dave Jiang , Allen Hubbe , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas Cc: Damien Le Moal , Frank Li , Niklas Cassel , ntb@lists.linux.dev, linux-pci@vger.kernel.org Subject: [PATCH v2 4/4] PCI: endpoint: pci-epf-vntb: remove superfluous checks Date: Wed, 7 Feb 2024 22:39:17 +0100 Message-ID: <20240207213922.1796533-5-cassel@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207213922.1796533-1-cassel@kernel.org> References: <20240207213922.1796533-1-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove superfluous alignment checks, these checks are already done by pci_epf_alloc_space(). Signed-off-by: Niklas Cassel Reviewed-by: Manivannan Sadhasivam --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index ba509d67188b..eda4b906868b 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -527,7 +527,6 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb) static int epf_ntb_db_bar_init(struct epf_ntb *ntb) { const struct pci_epc_features *epc_features; - u32 align; struct device *dev = &ntb->epf->dev; int ret; struct pci_epf_bar *epf_bar; @@ -538,16 +537,6 @@ static int epf_ntb_db_bar_init(struct epf_ntb *ntb) epc_features = pci_epc_get_features(ntb->epf->epc, ntb->epf->func_no, ntb->epf->vfunc_no); - align = epc_features->align; - - if (size < 128) - size = 128; - - if (align) - size = ALIGN(size, align); - else - size = roundup_pow_of_two(size); - barno = ntb->epf_ntb_bar[BAR_DB]; mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, epc_features, 0);