From nobody Wed Dec 17 10:21:26 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71C421C5D79 for ; Fri, 28 Mar 2025 14:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743173633; cv=none; b=Bbk7TKeBbNOSY69/cHyGcjYnEN71pvynSfoD4qSF9HBSMObcTbdvudmW6ff5uPOFkpeZeR50nQRVHTu/iWtkIJBQ8ozNZvqeLjOI5vx+LDRbngyy9Rc8F4SSptJjHkQCAyM4X3T50ZnRppRv/pZSZdd4dApaRuhti16qJ+0JEd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743173633; c=relaxed/simple; bh=gUEdTnXFrxQFCubyzkt8h7MkbAD/T1O1BvGuN2YMSZk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z9LTDmQBbmOPP9hUtKHno0Qjp7jqgLDiK0m2SXDyD0F2M/fdpwaHWG/njO1ARKEczcOS61CRf90VVFt/uIOsbpugzliny6uWNXJQAqSx4yoPnN6DjeFEcfjdBwc3dy1nCf3UyuZJr0R4KytdAB97vO+DmYxJy6vDfraiOgNkZgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=otgY/Ol5; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="otgY/Ol5" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-43cfa7e7f54so14499995e9.1 for ; Fri, 28 Mar 2025 07:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1743173629; x=1743778429; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hmbC5RFYydPYh642kyN0rQaa467lBDxTsawumsVo1Aw=; b=otgY/Ol5ZtwGWKVKjZZ5B9DQI77BDRPGqjsojkUYq3bYG685AdupaJ+fig5vsOnBqn orP/wwX9n5UznpEfzz2PyExPpPt3/XUpOr0wPOvLfR7zejEP/RSpP4FI/hO4aURLpy1F O4hccnf4gej/pU+XphRKVFxGKMKfMRUqfEHj3kie3gvcLMxjg7YMaXr9s0pz+txuR/pj CZmuzTsa4cRKYN9kZmZpi/+YVYW/LCqBxrCJ9kSX6IvNrV4toEqDFUhojLNS+jXO2W5v z+OOjc6CN33/nLpca05nWk7UMwV8mxOO6vmFvAog9Ya6MXqz8wCDWhmuVjFP7AM780KF BUKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743173629; x=1743778429; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hmbC5RFYydPYh642kyN0rQaa467lBDxTsawumsVo1Aw=; b=snEullHYwUSVDSWf3V2PZ1WcM4QicF1IMV1ODa34e5BiR1sxupzCkslQegZ8wThdbM 4lvOjqbW3I7yKc7Sndj9V3E2nRhc12Z22mkV4dfSzPg7FtQx/ho/hjxefPyxFuGoVEGg TK1bSzT5vHaQXtMgFvYF01tATS8QBoOZDhAOw6POrFdiW5NnSrHIvfYeoyEtxPXGUckr tFZ5TYbM76AuvNOT28YCOhE9I5tXZw18WGuORfcxhE8WinLxNHkSSDUPaseeyL8L9Fzx jTpgSS/CBNPDAB2k+V3uE86GirTeu9d4hVlwvy2jY0b8osUhr7BSfFJbGA2rUdzk/WqJ JPzg== X-Forwarded-Encrypted: i=1; AJvYcCWTYozx5TKWqQF7eqwvLm0artFeu/cwhlBFBwgPuHNfjQR4PSKUjXLeuY4we/9sxZtxI7F+nBr9PmxMUk8=@vger.kernel.org X-Gm-Message-State: AOJu0Yyr0TbRjUVvOhREJ64EpRl/kILyYx2d/YXjCs8FV1ZLToykjQmf bCdM2YxWgXP0dXnWdj0XZsoUDCP313zRvMiWXBnypffWUEXrs+HxFhGsME+XpZQ= X-Gm-Gg: ASbGncvVwSFmgE+2sivmdCZ3yY805zZkZ1lm2CvnhbXcOn2EDisev0y/0rsV2wAXwqa wp4KIobmvUpBnbpqTC+Ider1We8EhyPuU1Hj6wWXH8OC/qCa+UkPPO+fCZcVHJX+BR/yccQ8Ycm IIC4aN706fSE1knS9XGu7jJu+xsw+kgXrPihHpxvV0V5ROsC6/cqOOB+XROtu5ubfeLceRmqD2P qQ3bvCdpxqGHpL9K6ivcXz6eCdSeP2PucGXk3QsDb/9bVJ4SYfsUVPH9fpFIEZUOlKTc6nEaAQX fFuSjJmMCn9eLOgj2q+Lt6Df1dn33Lmwx2l5F/1NIe27FskEk4mTVc3jwdM= X-Google-Smtp-Source: AGHT+IHEwb8loYtorvEBGaqWpt3wJlMaO1x80S4rv3p5SrimoSh4/TC2550uL3aEEWUnSViQo2QLzg== X-Received: by 2002:a05:600c:1f14:b0:439:9737:675b with SMTP id 5b1f17b1804b1-43d9145bb08mr29097225e9.7.1743173628723; Fri, 28 Mar 2025 07:53:48 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:70c0:edf6:6897:a3f8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d8314e110sm75219615e9.39.2025.03.28.07.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Mar 2025 07:53:48 -0700 (PDT) From: Jerome Brunet Date: Fri, 28 Mar 2025 15:53:42 +0100 Subject: [PATCH 1/2] PCI: endpoint: strictly apply bar fixed size to allocate space Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250328-pci-ep-size-alignment-v1-1-ee5b78b15a9a@baylibre.com> References: <20250328-pci-ep-size-alignment-v1-0-ee5b78b15a9a@baylibre.com> In-Reply-To: <20250328-pci-ep-size-alignment-v1-0-ee5b78b15a9a@baylibre.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Lorenzo Pieralisi , Jon Mason , Dave Jiang , Allen Hubbe Cc: Marek Vasut , Yoshihiro Shimoda , Yuya Hamamachi , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, ntb@lists.linux.dev, Jerome Brunet X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1358; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=gUEdTnXFrxQFCubyzkt8h7MkbAD/T1O1BvGuN2YMSZk=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBn5rf42oi1rZDSM6XrbYRStOeGfWZi4bFla10nb K7qwiyD9t2JAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZ+a3+AAKCRDm/A8cN/La hQFGD/9VO5rQNfzw3OhspgPwCblFhKTlz8Qu/BP7+Qx/Qecie+/xT66l3wDwIyad6t73UH6EZh+ NukWAUMUFVnsHzpetu6cHHxG7P4cJSiZraHpTxk71rJlqqtKNln1JZEetSZr3tzurykZtQn8IB1 QIDGc2ZwKf+F4LCkZYdc+U8FpWGWnK19thptpoX90MTBDHL3p3IjNrIpl9dcMXta41/n7hKU0iM X3mKwqfDLJoAkCVksfneEjJG7SrhHsOSZqGgJ65uWAaRiWvKlffc7HPcI/efUA4mJcDOPmg5s7v XSmaI5ZBFx+gYypJ9WM7/NdvAc9lCboqY8NgqUOnMuQN2NmXXCDoGkKYtkcdKz2KMv/zpd5azU5 3SLmLc91smK/m1+aMgcSSeklGogyj/hJwXSZD4lrExrqboOvYygPI2fzXuQTFojuggTLB6KuwSR U4T97kNYN3Xmmwq9uraABImbwJh923AmxWLWRGwy7Sl1zNZDNirHVLPEHoxR7pfgi9k9nwmc3+E p2oFQ1DElCClLIRexJtriHYKtLAnTXj74AXyHwfAL+tIrfRLUzflyGtgXYOPBgC3Zt2yXrhLMdZ 4rJ0Py7yCIhPY6LJtTKWSTw5DNgzsnByz/UewoSMZbuG+3rfjWlIk4+XSlG2jCcyozAXCXODfHn W+2qbCqgSrz1bhg== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 When trying to allocate space for an endpoint function on a BAR with a fixed size, that size should be used regardless of the alignment. Some controller may have specified an alignment, but do have a BAR with a fixed size smaller that alignment. In such case, pci_epf_alloc_space() tries to allocate a space that matches the alignment and it won't work. When the BAR size is fixed, pci_epf_alloc_space() should not deviate from this fixed size. Fixes: 2a9a801620ef ("PCI: endpoint: Add support to specify alignment for b= uffers allocated to BARs") Signed-off-by: Jerome Brunet --- drivers/pci/endpoint/pci-epf-core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci= -epf-core.c index 394395c7f8decfa2010469655a4bd58a002993fd..cb985b172ed041c6f319c083f41= 2e51e25b0a157 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -285,12 +285,11 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t= size, enum pci_barno bar, return NULL; } size =3D bar_fixed_size; - } - - if (align) + } else if (align) { size =3D ALIGN(size, align); - else + } else { size =3D roundup_pow_of_two(size); + } =20 if (type =3D=3D PRIMARY_INTERFACE) { epc =3D epf->epc; --=20 2.47.2 From nobody Wed Dec 17 10:21:26 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83D0C1C84B4 for ; Fri, 28 Mar 2025 14:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743173634; cv=none; b=ENCZPc84YFbUcJ5C+bLNTnKkZ9rgwKkQy0JEMemnacaud1tsaGOTBVLDp0qmI68rdrZ7N+n99hmj3FcZGjFeRVprFR6rSkJfvj5JDzEvgykbRWRr7fq8BhHlGU+H9k/XFTiWnmH63LNOs4caHFuh6nB4OJxHYfxr2B7z+zZ7FqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743173634; c=relaxed/simple; bh=5oAHlbTAcauldOWi9cMUgYioWN6gScafeHZfYPLkyRw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l6egzhqSfiwbKX6wbrzotSlmOI6D5PbB3yWXO+8RZAXVyZQA9p4y5HJvf9Mx3b6lCNArSA0r246mrec+G7ttaw5Pbdy8uWiU47c9Zb3AXlnESibX/pP6kgGFyKjl8oaWgwcdse2VykrghesUsYiPh3dJIkMPs9RoFV+9ibDJRas= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=okOKEWfn; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="okOKEWfn" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43cef035a3bso16665115e9.1 for ; Fri, 28 Mar 2025 07:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1743173629; x=1743778429; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=om5WJnI/3Srzz6KnBz+MWEytyGjHkNFH1uylSroKmIg=; b=okOKEWfnhIchaZtaYWp60UK0xpayqqgpB5D4b0i+I8ukqG/Sk8+XjXnMU5ZSXHHiWz d+g2HYuLBHn4gdO1t99+6/VlFsAG8+rpBzFqtPiXz5SGk2/0i6RQ1rOOCbJs6bsuyxoH 7gtOPvckR+YJzU57+nMxEPPLKbxmeXtFd8F9IRCpGI9uhEZKSdJYU4vSQ1ALG/1LTIUc WhR9jfS0yWdziivczKntuGWlNSgvLfHnMrkbxpcZBZmjrR7HCUOqGoQesHaKT6AysUTz MTF2me2ZBw9HO20Hs6nTz1Rjm51UQmvK5r0MSnTi7suVo1vwTrdOlNyekhXtbPISj2Pp 7N9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743173629; x=1743778429; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=om5WJnI/3Srzz6KnBz+MWEytyGjHkNFH1uylSroKmIg=; b=g6P+BbDmcyWKOka9mRG296ftEIOeDG5nmVkL6pL/8t0ch+gZCafEj/5pJDs1M68zAa 4sVNBpb8M80YPFGiZ+chtot1bFDqbpYorREIpOelj6p23s2JSSeer86Xcyu9qYTkzXQj D4UNf8EnymJ63PJ8vVTTyt4bRCmd2EmyHiXdQbJ552XpgxnxI4ha27+0p2N+AY5/Rb3e R1KkLXnXkmk7R2nb1KKuNh/PaNkXyZYksRAMaExQTuP8eF+Y4RjkWZ1dictho9j8A9JG YuwwkDlIg6Bj7PrKpnXRqugv1M+B3LHbMTxmDM+blLAE+3vDBXYpL9kHRXl/fx+dUMdG Nzvw== X-Forwarded-Encrypted: i=1; AJvYcCW/Asge2GypxQv5uuBklEWPKDwucCFjKlNhcaoxt0GV+Ygzddi6qeYfGma5LcGYxfHS8lDW0dWbcwEML84=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2YylAfiYQij5cKGQKn5d2UQeJ7jGq6tcnKd+tbKuH27nUx2+G aW24VKpVbDAmt2c9Pt0NVpDVlGiDuGB6sSJaabnLBSAMptGSkr/7MPPd5pfRCNU= X-Gm-Gg: ASbGnctVYzrNSgj23njPgTM+/w6VVUZvH3JDyby5JHwh4fbtMYVdVSXD5OLR1RV8IOF QH3pyvN51L1YCSjQrctMYZzGu8IyUPrCTsCGkpKNCpQJkFPNKy7sfaaMTHXyDdx7Xz2uOXlrmLT MYPAS/ZN7hLnHZdZm/yi7lDgOVQNaVWqmLJHi32GTjHvy9vt+PXUCq+TIkQITA4HW7e4z+Yy772 N3o/cioSeC2OUp4sV0z/qO9SVN0LQkYG2EEpwE9zReoEIloGXgNnhoeDkraHB6jMIkRgC8lC+Cb 3sZiciSbdot0n0wP3o3HCLi3us5f8/4tTRUnj7IBcHQl9my4PDjDw8YdmS4= X-Google-Smtp-Source: AGHT+IHxpmdIjzZ3NBy6ZKDeIo2oJ9uzZLQK6IFavRFuRv86Y+8cRv+dnKeq1VLQiY8bi9c3dCFsFQ== X-Received: by 2002:a05:6000:22c7:b0:391:4889:503e with SMTP id ffacd0b85a97d-39ad17503e8mr8632876f8f.33.1743173629528; Fri, 28 Mar 2025 07:53:49 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:70c0:edf6:6897:a3f8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43d8314e110sm75219615e9.39.2025.03.28.07.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Mar 2025 07:53:49 -0700 (PDT) From: Jerome Brunet Date: Fri, 28 Mar 2025 15:53:43 +0100 Subject: [PATCH 2/2] PCI: endpoint: pci-epf-vntb: simplify ctrl/spad space allocation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250328-pci-ep-size-alignment-v1-2-ee5b78b15a9a@baylibre.com> References: <20250328-pci-ep-size-alignment-v1-0-ee5b78b15a9a@baylibre.com> In-Reply-To: <20250328-pci-ep-size-alignment-v1-0-ee5b78b15a9a@baylibre.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Lorenzo Pieralisi , Jon Mason , Dave Jiang , Allen Hubbe Cc: Marek Vasut , Yoshihiro Shimoda , Yuya Hamamachi , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, ntb@lists.linux.dev, Jerome Brunet X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2533; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=5oAHlbTAcauldOWi9cMUgYioWN6gScafeHZfYPLkyRw=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBn5rf5tteiMGeKSx358xJ2+154PVr7k7RAJ8OqE x2hmwLHlNeJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZ+a3+QAKCRDm/A8cN/La hX1yD/sHaWYMETTJwDgxrGxRlNsQF+Rc9Q5oMX73ZbvDomTMBb5/EiuCjNA+WGqvLAaxZPnInYb gbgbOiq3WmzHn+nEp/DGRjxo8UlUCwJEE0w+E+D89smicnQpIelt4t7+C/M+ImfP/AUC7bxZfiJ aJqVUT1ya+PnF0xTs2X1txWYxCtLvr1ez3Zpq7tWgPbvlZzrQgQX1Gs5NkYGemnRj4CdKAwWwc/ WdPQ6RD2QjKbsur4fqR5Mm5Ykd+yveBedPVUDb2otNDQSi+P+8ACxZ9wn2ZpFbQeSdWa/wrxgFS uaKxglM4i8uT7qLrWJWP5we/cAKLPVTI3n11V36Zs8g2ppjfZgAwIhZckxcPGaBFNStjI3em2DX y1oAkpi56w/B7itaLGgQ2OnANTCeZ74U/9RJe80a4dq7rHsZcbs8yeIxhhnIWjN/fRvO4nqpH09 B/XqYI18bYdgYLJ4zPvixPbtVhvoAxCpY7xJPyOhrJR27m0njeWb/dugQjI+03LABwI5PstLYYl qtDWRm0pg2/TA/v5JTTzpqK2BbEG2ST+9Htlt/UeGLN54VADr9qtKB/C4PCkqs0HoHNRJpX6ufm 2UoJI+sD12dRMYYnCviwxrBt7KSVPuWTN5lnUmnHqTOFDl6WfqoPgNvu3mAsPJfqPMpvduOzCNN hJsCtJfdABnSOEg== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 When allocating the shared ctrl/spad space, epf_ntb_config_spad_bar_alloc() should not try to handle the size quirks for the underlying BAR, whether it is fixed size or alignment. This is already handled by pci_epf_alloc_space(). Also, when handling the alignment, this allocate more space than necessary. For example, with a spad size of 1024B and a ctrl size of 308B, the space necessary is 1332B. If the alignment is 1MB, epf_ntb_config_spad_bar_alloc() tries to allocate 2MB where 1MB would have been more than enough. Just drop all the handling of the BAR size quirks and let pci_epf_alloc_space() handle that. Signed-off-by: Jerome Brunet --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/en= dpoint/functions/pci-epf-vntb.c index 874cb097b093ae645bbc4bf3c9d28ca812d7689d..c20a60fcb99e6e16716dd78ab59= ebf7cf074b2a6 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -408,11 +408,9 @@ static void epf_ntb_config_spad_bar_free(struct epf_nt= b *ntb) */ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb) { - size_t align; enum pci_barno barno; struct epf_ntb_ctrl *ctrl; u32 spad_size, ctrl_size; - u64 size; struct pci_epf *epf =3D ntb->epf; struct device *dev =3D &epf->dev; u32 spad_count; @@ -422,31 +420,13 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_n= tb *ntb) epf->func_no, epf->vfunc_no); barno =3D ntb->epf_ntb_bar[BAR_CONFIG]; - size =3D epc_features->bar[barno].fixed_size; - align =3D epc_features->align; - - if ((!IS_ALIGNED(size, align))) - return -EINVAL; - spad_count =3D ntb->spad_count; =20 ctrl_size =3D sizeof(struct epf_ntb_ctrl); spad_size =3D 2 * spad_count * sizeof(u32); =20 - if (!align) { - ctrl_size =3D roundup_pow_of_two(ctrl_size); - spad_size =3D roundup_pow_of_two(spad_size); - } else { - ctrl_size =3D ALIGN(ctrl_size, align); - spad_size =3D ALIGN(spad_size, align); - } - - if (!size) - size =3D ctrl_size + spad_size; - else if (size < ctrl_size + spad_size) - return -EINVAL; - - base =3D pci_epf_alloc_space(epf, size, barno, epc_features, 0); + base =3D pci_epf_alloc_space(epf, ctrl_size + spad_size, + barno, epc_features, 0); if (!base) { dev_err(dev, "Config/Status/SPAD alloc region fail\n"); return -ENOMEM; --=20 2.47.2