From nobody Mon Feb 9 18:05:55 2026 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 918C119006B for ; Tue, 3 Jun 2025 17:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748970247; cv=none; b=WVesJQ2BTHnZmQ9aZK63BwyIuDYIWxOY+MRgqPCldc3FliZgFlL++cIYPelgHkx2LDozv4P8df/If3kvf1MM6exmgQZ77x7NDDZgzInD82FpiPkrgU7bmpTcQzHvbwCs5aeu8jY1UeeRevbh39vtQBohyhTqetQ1g6eYrOmAItI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748970247; c=relaxed/simple; bh=4r+5Eof096MZjRh8tpVi37f6nJMhY0833cfm9C9HdL0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pZlWgj+bJKNEdx+WMX+kFJGqLka8O+etEdVt8aBQGvWqQdgGUHdmr3xQBu7NyyJOuvR/hGZDVTks0FcQaNA3fiVjU/+UGsyg0htyU+hvgfaQW1fx2Lkh32Z2j0DdVc28VMHRg0grbtqLa6k3wj9QyodBqRTeqW+1H/khhoq6zT0= 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=2b7cSReR; arc=none smtp.client-ip=209.85.221.54 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="2b7cSReR" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3a4e742dc97so54251f8f.0 for ; Tue, 03 Jun 2025 10:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1748970244; x=1749575044; 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=z9KctMIkbgxYBp8QVwwNbz+2eDOalPhBXgUZIQWSTmo=; b=2b7cSReRtXT0uSW84ykQaUZH0gPMRasYIx6cwaadLeBmyvLv96BHM9K8FYF/OD+S9U DMzzJcQ8yeBC+7xuWyvaoRQSCdBNOt0CI9wdPiisC+k1MiNnSD1BL44DM3nvsSkLBogA 8CZk2QB7IgorONpNGZSCwarJlaSpV2e/b0WzTvSktUYTzyuU0OZXFlydTgHKtqqMrOTi WlpgAcACamRdhk2P2iKgaXVL+asi14KQMrPXiWj+D9uNC4moIj1G/Mjzx2HPhRgpxcMl kP+5N3ObyOLvvfR+2mo5QSJn3SV0wGV5WtFbvTnvj5ve+Dn1xvYD6kZVhUp/g/dG885v 7TtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748970244; x=1749575044; 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=z9KctMIkbgxYBp8QVwwNbz+2eDOalPhBXgUZIQWSTmo=; b=V7KhHCs6SC2lFndIm5daFRk9T1FwRLF3lYtPeLSAbl0F9gLsyfLDyM50I2Ugdxa0T7 idj7z6kXJHingCL4yv+Q8tlyNtVzyXvXGNU8N869GSWe3e1LGlQY/7PO6Nz1SlIpeYkB QV1JEPMCY0FKSCbYZCNOZpIVcp4Rjuw7uhA+gKTKFCFUrG3UQleRBkBYoFRDGiKX3NcE F1fT7Lp1RzuHxCj7aB6mgLx8idl6BuQLjCMO+Oo0MQ4mJPVmlxxyT02imUlV2xo3IZ40 eO6dQpgozQntu1wIIr28LrxrCQFaYCZG+Zqhl38r+RKzI0gc930sYDf322O1HBuBf6ia YdOQ== X-Forwarded-Encrypted: i=1; AJvYcCUkEbpdHnqBVDQQY4MDoTibjm427dcJiTFI4E/YawOoruRLBtWWCyBaPrQgPGkwqAa25bImb8GBEcx32sk=@vger.kernel.org X-Gm-Message-State: AOJu0YzCIzEIoUKWY8WYagvCn4S5RfWpx/aVLCUPd/G3aI9EaFn/3skx o84kVc7xypQV8mwTj4czXApUTPKLp2xCu3cO078aaLkJgjwDW6q87uV9UCMd11ivLP0= X-Gm-Gg: ASbGnctg1FufWAAuKzSBu7jfLioZFVppkd35Non0fag/gZK5WnlbI7g63+uVQhj/JpD H63fkk8uvGwsMe9H840yWJqyQL8IjP6RG+Yq4PI2sjcRV3uM5vt6zwIsFTphhEiboUuK8drSV7T c6BQLU+S4lltgQbY9yphMfLf6ZooobajfiY8P8USgugFSNTFsBvGdhw5GMHR25IFlynp/oDr6qk ozGFVzYTsz9ZT5/YFMYKo/GPA5RbJXK2c+V/ljSNYaPyCVCZ2QkutRBf/q6BUg5AF7CLZzSLbA7 DCAYd/3aSoJS2IMEkHeRTchUzx09ULU1dnEgq+dj/HszvEP1SvxANLGD2GeD++XfYA== X-Google-Smtp-Source: AGHT+IFQ4mga6ZpQOnpfxIJQb2eWoiJqInQW3qkdZiZ9oqXdEFGYy8VI+GYDFKLpm2n+vIAxaELDzA== X-Received: by 2002:a05:6000:144d:b0:3a3:7ba5:9a68 with SMTP id ffacd0b85a97d-3a5144f8154mr3094893f8f.18.1748970243645; Tue, 03 Jun 2025 10:04:03 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:ce70:8503:aea6:a8ed]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3a4f00972f3sm19165796f8f.69.2025.06.03.10.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jun 2025 10:04:03 -0700 (PDT) From: Jerome Brunet Date: Tue, 03 Jun 2025 19:03:38 +0200 Subject: [PATCH v2 1/3] PCI: endpoint: pci-epf-vntb: Return an error code on bar init 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: <20250603-pci-vntb-bar-mapping-v2-1-fc685a22ad28@baylibre.com> References: <20250603-pci-vntb-bar-mapping-v2-0-fc685a22ad28@baylibre.com> In-Reply-To: <20250603-pci-vntb-bar-mapping-v2-0-fc685a22ad28@baylibre.com> To: Jon Mason , Dave Jiang , Allen Hubbe , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas , Frank Li , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: ntb@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Brunet X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1100; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=4r+5Eof096MZjRh8tpVi37f6nJMhY0833cfm9C9HdL0=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBoPyr/rF0NiI9WeluJ+asQYI6+4kWmycSeT3GUm 2/aDNg8qiOJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCaD8q/wAKCRDm/A8cN/La hSLjD/0Q4FwOh6ppUJJ2M+N/1SOee8kK5qxOadTEqWDaaMGNH51khNK0PPAiZMyEIsQQf855Js6 EuEJcd77GsM3Ntm+F6UMQk9NQ+ZtPhwaGt7tRQ9jma5HTNRv/WHRy6m8qMCbH3nm5eKMRb3a0vL hP16eJ+EK2drKPfoOMWTQVyXTFHSasvW3MKH13GyM8yihB9CNcksyNl6+5yIbLPItRA/E+Gf9hP 0zP/Wkrga6nAorbLUksBosPRVzCM/BSY/CV2dF1gosh2sBxgjwJFrPWisfTmssTMzi803WllYPs QnYTl2uullBc1Wucl+zMWEbEDDDYDTobNuHfv37GE94RlHVwumK2kMOSTC6AWJzDZYjUzIwedNY ZLnu/atJWd0ffYXGJ2brfXoA2vrvv8b/83LwneArAiKAmrL85Fl+GLsOjxXYXa4IhQN/Hfhp/kv VrFLsB7gG2U3eR2DT3JKdNXYiItVLS2OuaYoMGuLw+zKR/t0FeyVTHd0tz67ff0Yt+YQHmuAn1l gZoAq4N8RGeueybFK86+IV/eQAWyKEf6syYLlxYrC7lBHofKVa2cLQoktWlVt/gfFpsK88Nn4aY NfHplfXZuoXkq48afjQsQzdkE+460W8PcYU/B/afMGCI4qnd4GSGyKMu0wyXC1o+v39S26yeuTh wjDsFm/5vzqCmPA== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 According the function documentation of epf_ntb_init_epc_bar(), the function should return an error code on error. However, it returns -1 when no BAR is available. Return -EINVAL instead. Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP= ") Reviewed-by: Frank Li Signed-off-by: Jerome Brunet --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/en= dpoint/functions/pci-epf-vntb.c index e4da3fdb000723e3adad01f0ddf230ecc0e572a7..35fa0a21fc91100a5539bff775e= 7ebc25e1fb9c1 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -680,7 +680,7 @@ static int epf_ntb_init_epc_bar(struct epf_ntb *ntb) barno =3D pci_epc_get_next_free_bar(epc_features, barno); if (barno < 0) { dev_err(dev, "Fail to get NTB function BAR\n"); - return barno; + return -EINVAL; } ntb->epf_ntb_bar[bar] =3D barno; } --=20 2.47.2 From nobody Mon Feb 9 18:05:55 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 925E51AA1D8 for ; Tue, 3 Jun 2025 17:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748970250; cv=none; b=Wj4see76l/txt+B+S9k81OsZgPFZ01FxqnhpcEYKGNo428Txk7eeiDV4BTadlSCone9SB1G646QPvU/8UVz83m0t/mGFUk/2+NXnneLDLjpV8OCvx2fS8y7KrbO5gQJpApmrYCHnXVag+j9PSJmHftfPly/t1dVa5VR6mqwtEaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748970250; c=relaxed/simple; bh=o5elYaZvS8wbMI7TEu2FQ0/cKa3utfUsILwG/lu1jg0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ai5p+NuPUtZcWJI9MOqH985o47QveGrN0257M9UsL1XiZk4vXqZKwQhQpqNgdkl/+sJ3PEZ5074rYbcausXnXGKCGjMVZLonjhibVqnJZFUylRyqWZwOplqVguQb6Bi9LOXFy+6yGejdXgzYAwk+wxrVEgfqNEEFEpL7Q08NYf0= 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=bgh4YTUT; arc=none smtp.client-ip=209.85.128.42 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="bgh4YTUT" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-451d3f72391so40095925e9.3 for ; Tue, 03 Jun 2025 10:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1748970245; x=1749575045; 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=/M2rtMrLUp1znoFQ7fmm+p8Omluvozwl8sFwFwa3e+U=; b=bgh4YTUTb4Hf6kDx4/Pm/7SNzwr2GD782UfKQ7z/JSVb2v3v5yIYjA2OF94oz1Vd3Z bCFxKCUcmIe2sUSVVJAsNswqseWQf8DHMmpNR2SsJI6FnhgHIBloD6memn8RlvuvZknS 9A8SYKBx2Sgz2W3iWcbZB0UPlKVYcWv5oX8IZS5vPBTqa5JcMJY5MIWk5ZNjq8Ou2lTb o7Ff1PKkEzJ29/AQiYn+jUaqdboB6sZvJJEYYijsvEVLXQGOSb2EcT5TZq4447GtzHsV XPprBHGhiRa2uRYoH8U20vuwbhIiHrbrz7cIwmPZrOWzMlu8OeVyd20G79m+AAVAwdri CZCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748970245; x=1749575045; 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=/M2rtMrLUp1znoFQ7fmm+p8Omluvozwl8sFwFwa3e+U=; b=VoJZHpHPKYqA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: by 2002:a05:600c:a51:b0:442:f485:6fa4 with SMTP id 5b1f17b1804b1-450d8871448mr182944585e9.31.1748970244569; Tue, 03 Jun 2025 10:04:04 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:ce70:8503:aea6:a8ed]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3a4f00972f3sm19165796f8f.69.2025.06.03.10.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jun 2025 10:04:04 -0700 (PDT) From: Jerome Brunet Date: Tue, 03 Jun 2025 19:03:39 +0200 Subject: [PATCH v2 2/3] PCI: endpoint: pci-epf-vntb: Align mw naming with config names 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: <20250603-pci-vntb-bar-mapping-v2-2-fc685a22ad28@baylibre.com> References: <20250603-pci-vntb-bar-mapping-v2-0-fc685a22ad28@baylibre.com> In-Reply-To: <20250603-pci-vntb-bar-mapping-v2-0-fc685a22ad28@baylibre.com> To: Jon Mason , Dave Jiang , Allen Hubbe , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas , Frank Li , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: ntb@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Brunet X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2559; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=o5elYaZvS8wbMI7TEu2FQ0/cKa3utfUsILwG/lu1jg0=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBoPysAmNdY3L3Sx78z2vvbh/WQc4IMEoBC/bPXW vk8+PspXkWJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCaD8rAAAKCRDm/A8cN/La hV3NEACTtimKhQfTMZzspVbi0CI9sKwDERzuHOBEmAytqOAZDm1Uqm0X1ykPRJvmL0ig6Dd8ZPB k4rNVU/qpXnb9vcNmFPad/DVPVxGZvEpM5s3gw6TkngFr88EfBGXbokRrgb8f+0i2QcgvAc9ZiS iiQJprUFLNaS4xIKb0ch/bvs+mL4xK9duMp0d69RJaXFTwKYnsXIqYnETZPE5a1niYAa8qBaKe4 0+K/k8pfUjrvk5Ui0YFt2+dI1qPwUB0KGo2N5GVqWCCR+eyhs/B8rRJO5qUUZ1iRfB0g5LkRHiC Xl5AKisqFutIcv7GSp/r8XCC4sLCc5CUw5jOurQjg+lCavWWA/Lv3ueGCfMGvvxzeeCd5IK1/NM WhhVtg0fOE1Gz+uTayQ/cjvmYnYtnbUoWwdzDH0iXdRzEZb+Y3NBkaze12zuL8SL8UC6w2sUDFr oRTXZCVBFOvadQ4gngpM9qkHMVAdXLYCQRVKbhDLop7HhAxzj2DxaLg/QbHkvr4IsKC17ywYJrk nkDPZ20bLnF4/dCnVhTHzg61vTS7MVx5uiuKehGAQzbsCMHVz4VbWBK6Mw2iV8tWeu0NLwC03aL UsLC2aLVVzuZ5ovOo3StWw4n0qP4IMl5ha2fDWPvIVVyUdc2ZAiELx8l3VUBSDSdxZpu28xJeVu qTIIajQwq7fR6Tw== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 The config file related to the memory windows start the numbering of the MW from 1. The other NTB function does the same, yet the enumeration defining the BARs of the vNTB function starts numbering the MW from 0. Both numbering are fine I suppose but mixing the two is a bit confusing. The configfs file being the interface with userspace, lets keep that stable and consistently start the numbering of the MW from 1. Signed-off-by: Jerome Brunet Reviewed-by: Frank Li --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/en= dpoint/functions/pci-epf-vntb.c index 35fa0a21fc91100a5539bff775e7ebc25e1fb9c1..2198282a80a40774047502a37f0= 288ca396bdb0e 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -70,9 +70,9 @@ static struct workqueue_struct *kpcintb_workqueue; enum epf_ntb_bar { BAR_CONFIG, BAR_DB, - BAR_MW0, BAR_MW1, BAR_MW2, + BAR_MW3, }; =20 /* @@ -576,7 +576,7 @@ static int epf_ntb_mw_bar_init(struct epf_ntb *ntb) =20 for (i =3D 0; i < ntb->num_mws; i++) { size =3D ntb->mws_size[i]; - barno =3D ntb->epf_ntb_bar[BAR_MW0 + i]; + barno =3D ntb->epf_ntb_bar[BAR_MW1 + i]; =20 ntb->epf->bar[barno].barno =3D barno; ntb->epf->bar[barno].size =3D size; @@ -629,7 +629,7 @@ static void epf_ntb_mw_bar_clear(struct epf_ntb *ntb, i= nt num_mws) int i; =20 for (i =3D 0; i < num_mws; i++) { - barno =3D ntb->epf_ntb_bar[BAR_MW0 + i]; + barno =3D ntb->epf_ntb_bar[BAR_MW1 + i]; pci_epc_clear_bar(ntb->epf->epc, ntb->epf->func_no, ntb->epf->vfunc_no, @@ -676,7 +676,7 @@ static int epf_ntb_init_epc_bar(struct epf_ntb *ntb) epc_features =3D pci_epc_get_features(ntb->epf->epc, ntb->epf->func_no, n= tb->epf->vfunc_no); =20 /* These are required BARs which are mandatory for NTB functionality */ - for (bar =3D BAR_CONFIG; bar <=3D BAR_MW0; bar++, barno++) { + for (bar =3D BAR_CONFIG; bar <=3D BAR_MW1; bar++, barno++) { barno =3D pci_epc_get_next_free_bar(epc_features, barno); if (barno < 0) { dev_err(dev, "Fail to get NTB function BAR\n"); @@ -1048,7 +1048,7 @@ static int vntb_epf_mw_set_trans(struct ntb_dev *ndev= , int pidx, int idx, struct device *dev; =20 dev =3D &ntb->ntb.dev; - barno =3D ntb->epf_ntb_bar[BAR_MW0 + idx]; + barno =3D ntb->epf_ntb_bar[BAR_MW1 + idx]; epf_bar =3D &ntb->epf->bar[barno]; epf_bar->phys_addr =3D addr; epf_bar->barno =3D barno; --=20 2.47.2 From nobody Mon Feb 9 18:05:55 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 4F7A81C5D62 for ; Tue, 3 Jun 2025 17:04:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748970249; cv=none; b=SNqJg8yme1T0Ec4B/0K/rSqZcdCVnnA+LdJcG/p4QLT92/NCsN2AOGeUcJueHPb+0kHdjOBpeujAybe8l97CUSffW2174/6BOucjrBUB2YKeh+56V4gara8qOlLDbbJxSooE59Sn01aa4spRaKBTIJwqpw0hb4I4VKx1J0mPd+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748970249; c=relaxed/simple; bh=+ePQnJDcFqkQJpItAOPJsBodMxVCJcjaopq3bndTN+U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L0W/zeiX6mhWs3oSHcOsFbjI+KLXXQa6mHstSRFsjx8/Acv5L4+vvriOAK0vSP5T3jmiYd6bdQAaovnEiMpZ7TJYIQ4opnYnWhtjjRreUQD3HhVlJV2uiArnNH0qQlIgc+GNNrmm8Z15Qlexd/ac9AqyCirsHtWs6RZAAyZI/L0= 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=QFmeDZ7E; arc=none smtp.client-ip=209.85.128.43 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="QFmeDZ7E" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-442f4a3a4d6so472575e9.0 for ; Tue, 03 Jun 2025 10:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1748970245; x=1749575045; 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=MKzxSvkuFHVX/dTGPAv3o3KaERfEbJG/IRGT5UdUnSc=; b=QFmeDZ7E2XezeGXD77ABrUPWz9r/ySw6Uo2R3xXSGNQNgkZpoVEuPW9DKy3qwJq7QJ Lld70kbjBnvNkAZW94a5MbeW0/epIcCi5YZnPtpegv2OW4aVrYvArpbppoqPHEThZ0LN SAqFy4tzKAtQhNi3ZHCClT8aQqgHdIjizGWQQjlToNx2kzQEW+fwUDC8AU4WzLr7bZ5R T34arNEFCnkQCCwvdyTlgCa+ksbEVaweRb6wLpKZ3HdOKOeMW0x78/G+IkKzwqVdMqjO 40PQPZxQrKAClBsYT2k2wkgoyTvwur9XMguLC23pl5W3pz3LCcdRZs4LQCsU6zQolqAS eMBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748970245; x=1749575045; 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=MKzxSvkuFHVX/dTGPAv3o3KaERfEbJG/IRGT5UdUnSc=; b=Ty4+/fcdb8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2002:a05:600c:1e0d:b0:451:e260:353d with SMTP id 5b1f17b1804b1-451e65ab8d5mr34535215e9.8.1748970245445; Tue, 03 Jun 2025 10:04:05 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:ce70:8503:aea6:a8ed]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3a4f00972f3sm19165796f8f.69.2025.06.03.10.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jun 2025 10:04:05 -0700 (PDT) From: Jerome Brunet Date: Tue, 03 Jun 2025 19:03:40 +0200 Subject: [PATCH v2 3/3] PCI: endpoint: pci-epf-vntb: Allow BAR assignment via configfs 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: <20250603-pci-vntb-bar-mapping-v2-3-fc685a22ad28@baylibre.com> References: <20250603-pci-vntb-bar-mapping-v2-0-fc685a22ad28@baylibre.com> In-Reply-To: <20250603-pci-vntb-bar-mapping-v2-0-fc685a22ad28@baylibre.com> To: Jon Mason , Dave Jiang , Allen Hubbe , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas , Frank Li , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: ntb@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Brunet X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7504; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=+ePQnJDcFqkQJpItAOPJsBodMxVCJcjaopq3bndTN+U=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBoPysBV7firfAE+AzkkStnAoQeF5a2evaqJzTz+ vEgGBG7I1WJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCaD8rAQAKCRDm/A8cN/La hZLjD/oCLt8l8hWeZLpqseq38yP/0NebqBRpu9cWfo7uV8rt9Mxi8V0hnxz/QTjSmjdI6U/mTb8 3T1RGLtERE7FFQ2ZRfTjjkxwf4NR7FbBO7GddhG/UakMBTBlBlJ+C0GVFK1horqdC7VJPyMs1tC 6yUQgFHLAdcp0atQLDMtzwMFn1W8XSt0eFx+2Rc89Cgvci9C5qCvCwF+d/YYLV9+7EKU6KtF1Y9 /T6UI4kymQzewV1HyRHtU5nFgErgrILrXf+w0a9dtHPsm2VLJwQQRYxcqH2ECvxPvCmqIbLeECN MuGmykicgJ3dZeUr1P41tAOTike0QlH6A26b0g5bSqvnIq8Nj9NU749Fk+LKKgh7cL5z7waoAy0 yXHcU4N1pA5Fd46cLvxzPfCqTHiucUI6MDLotrMIVzGDZ/UZpTAL6kl4WxQ8nHPKg/OqfZZOgkm kWk7V15TVIpbCnh4uui8gkBqKYMn+gsfGq3cICHR62Aff5Qj70FIAGhTJKCOUinBj3ypmzsyuXU 0GwQ0eKUVi2Sv+T04ORRkG05yio4hEYlguvGX+PppiqLpKV5hUIxg1H6Uz6v2mO4YGpSm2ua5SE 0Li7rBPxU+gPGC/RoQwp/F/KwwjQYVoSLj4rk+Ub3vIdWcotW+j7znsUyhTI0qbCgAQ09wUgcLN H5J/xwyGDcdOTWg== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 The current BAR configuration for the PCI vNTB endpoint function allocates BARs in order, which lacks flexibility and does not account for platform-specific quirks. This is problematic on Renesas platforms, where BAR_4 is a fixed 256B region that ends up being used for MW1, despite being better suited for doorbells. Add new configfs attributes to allow users to specify arbitrary BAR assignments. If no configuration is provided, the driver retains its original behavior of sequential BAR allocation, preserving compatibility with existing userspace setups. This enables use cases such as assigning BAR_2 for MW1 and using the limited BAR_4 for doorbells on Renesas platforms. Signed-off-by: Jerome Brunet Reviewed-by: Frank Li --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 131 ++++++++++++++++++++++= ++-- 1 file changed, 124 insertions(+), 7 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/en= dpoint/functions/pci-epf-vntb.c index 2198282a80a40774047502a37f0288ca396bdb0e..7475d87659b1c70aa41b0999eab= fa661f4ceed39 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -73,6 +73,8 @@ enum epf_ntb_bar { BAR_MW1, BAR_MW2, BAR_MW3, + BAR_MW4, + VNTB_BAR_NUM, }; =20 /* @@ -132,7 +134,7 @@ struct epf_ntb { bool linkup; u32 spad_size; =20 - enum pci_barno epf_ntb_bar[6]; + enum pci_barno epf_ntb_bar[VNTB_BAR_NUM]; =20 struct epf_ntb_ctrl *reg; =20 @@ -654,6 +656,62 @@ static void epf_ntb_epc_destroy(struct epf_ntb *ntb) pci_epc_put(ntb->epf->epc); } =20 + +/** + * epf_ntb_is_bar_used() - Check if a bar is used in the ntb configuration + * @ntb: NTB device that facilitates communication between HOST and VHOST + * @barno: Checked bar number + * + * Returns: true if used, false if free. + */ +static bool epf_ntb_is_bar_used(struct epf_ntb *ntb, + enum pci_barno barno) +{ + int i; + + for (i =3D 0; i < VNTB_BAR_NUM; i++) { + if (ntb->epf_ntb_bar[i] =3D=3D barno) + return true; + } + + return false; +} + +/** + * epf_ntb_find_bar() - Assign BAR number when no configuration is provided + * @epc_features: The features provided by the EPC specific to this EPF + * @ntb: NTB device that facilitates communication between HOST and VHOST + * @barno: Bar start index + * + * When the BAR configuration was not provided through the userspace + * configuration, automatically assign BAR as it has been historically + * done by this endpoint function. + * + * Returns: the BAR number found, if any. -1 otherwise + */ +static int epf_ntb_find_bar(struct epf_ntb *ntb, + const struct pci_epc_features *epc_features, + enum epf_ntb_bar bar, + enum pci_barno barno) +{ + while (ntb->epf_ntb_bar[bar] < 0) { + barno =3D pci_epc_get_next_free_bar(epc_features, barno); + if (barno < 0) + break; /* No more BAR available */ + + /* + * Verify if the BAR found is not already assigned + * through the provided configuration + */ + if (!epf_ntb_is_bar_used(ntb, barno)) + ntb->epf_ntb_bar[bar] =3D barno; + + barno +=3D 1; + } + + return barno; +} + /** * epf_ntb_init_epc_bar() - Identify BARs to be used for each of the NTB * constructs (scratchpad region, doorbell, memorywindow) @@ -676,23 +734,21 @@ static int epf_ntb_init_epc_bar(struct epf_ntb *ntb) epc_features =3D pci_epc_get_features(ntb->epf->epc, ntb->epf->func_no, n= tb->epf->vfunc_no); =20 /* These are required BARs which are mandatory for NTB functionality */ - for (bar =3D BAR_CONFIG; bar <=3D BAR_MW1; bar++, barno++) { - barno =3D pci_epc_get_next_free_bar(epc_features, barno); + for (bar =3D BAR_CONFIG; bar <=3D BAR_MW1; bar++) { + barno =3D epf_ntb_find_bar(ntb, epc_features, bar, barno); if (barno < 0) { dev_err(dev, "Fail to get NTB function BAR\n"); return -EINVAL; } - ntb->epf_ntb_bar[bar] =3D barno; } =20 /* These are optional BARs which don't impact NTB functionality */ - for (bar =3D BAR_MW1, i =3D 1; i < num_mws; bar++, barno++, i++) { - barno =3D pci_epc_get_next_free_bar(epc_features, barno); + for (bar =3D BAR_MW1, i =3D 1; i < num_mws; bar++, i++) { + barno =3D epf_ntb_find_bar(ntb, epc_features, bar, barno); if (barno < 0) { ntb->num_mws =3D i; dev_dbg(dev, "BAR not available for > MW%d\n", i + 1); } - ntb->epf_ntb_bar[bar] =3D barno; } =20 return 0; @@ -860,6 +916,37 @@ static ssize_t epf_ntb_##_name##_store(struct config_i= tem *item, \ return len; \ } =20 +#define EPF_NTB_BAR_R(_name, _id) \ + static ssize_t epf_ntb_##_name##_show(struct config_item *item, \ + char *page) \ + { \ + struct config_group *group =3D to_config_group(item); \ + struct epf_ntb *ntb =3D to_epf_ntb(group); \ + \ + return sprintf(page, "%d\n", ntb->epf_ntb_bar[_id]); \ + } + +#define EPF_NTB_BAR_W(_name, _id) \ + static ssize_t epf_ntb_##_name##_store(struct config_item *item, \ + const char *page, size_t len) \ + { \ + struct config_group *group =3D to_config_group(item); \ + struct epf_ntb *ntb =3D to_epf_ntb(group); \ + int val; \ + int ret; \ + \ + ret =3D kstrtoint(page, 0, &val); \ + if (ret) \ + return ret; \ + \ + if (val < NO_BAR || val > BAR_5) \ + return -EINVAL; \ + \ + ntb->epf_ntb_bar[_id] =3D val; \ + \ + return len; \ + } + static ssize_t epf_ntb_num_mws_store(struct config_item *item, const char *page, size_t len) { @@ -899,6 +986,18 @@ EPF_NTB_MW_R(mw3) EPF_NTB_MW_W(mw3) EPF_NTB_MW_R(mw4) EPF_NTB_MW_W(mw4) +EPF_NTB_BAR_R(ctrl_bar, BAR_CONFIG) +EPF_NTB_BAR_W(ctrl_bar, BAR_CONFIG) +EPF_NTB_BAR_R(db_bar, BAR_DB) +EPF_NTB_BAR_W(db_bar, BAR_DB) +EPF_NTB_BAR_R(mw1_bar, BAR_MW1) +EPF_NTB_BAR_W(mw1_bar, BAR_MW1) +EPF_NTB_BAR_R(mw2_bar, BAR_MW1) +EPF_NTB_BAR_W(mw2_bar, BAR_MW1) +EPF_NTB_BAR_R(mw3_bar, BAR_MW3) +EPF_NTB_BAR_W(mw3_bar, BAR_MW3) +EPF_NTB_BAR_R(mw4_bar, BAR_MW4) +EPF_NTB_BAR_W(mw4_bar, BAR_MW4) =20 CONFIGFS_ATTR(epf_ntb_, spad_count); CONFIGFS_ATTR(epf_ntb_, db_count); @@ -910,6 +1009,12 @@ CONFIGFS_ATTR(epf_ntb_, mw4); CONFIGFS_ATTR(epf_ntb_, vbus_number); CONFIGFS_ATTR(epf_ntb_, vntb_pid); CONFIGFS_ATTR(epf_ntb_, vntb_vid); +CONFIGFS_ATTR(epf_ntb_, ctrl_bar); +CONFIGFS_ATTR(epf_ntb_, db_bar); +CONFIGFS_ATTR(epf_ntb_, mw1_bar); +CONFIGFS_ATTR(epf_ntb_, mw2_bar); +CONFIGFS_ATTR(epf_ntb_, mw3_bar); +CONFIGFS_ATTR(epf_ntb_, mw4_bar); =20 static struct configfs_attribute *epf_ntb_attrs[] =3D { &epf_ntb_attr_spad_count, @@ -922,6 +1027,12 @@ static struct configfs_attribute *epf_ntb_attrs[] =3D= { &epf_ntb_attr_vbus_number, &epf_ntb_attr_vntb_pid, &epf_ntb_attr_vntb_vid, + &epf_ntb_attr_ctrl_bar, + &epf_ntb_attr_db_bar, + &epf_ntb_attr_mw1_bar, + &epf_ntb_attr_mw2_bar, + &epf_ntb_attr_mw3_bar, + &epf_ntb_attr_mw4_bar, NULL, }; =20 @@ -1379,6 +1490,7 @@ static int epf_ntb_probe(struct pci_epf *epf, { struct epf_ntb *ntb; struct device *dev; + int i; =20 dev =3D &epf->dev; =20 @@ -1389,6 +1501,11 @@ static int epf_ntb_probe(struct pci_epf *epf, epf->header =3D &epf_ntb_header; ntb->epf =3D epf; ntb->vbus_number =3D 0xff; + + /* Initially, no bar is assigned */ + for (i =3D 0; i < VNTB_BAR_NUM; i++) + ntb->epf_ntb_bar[i] =3D NO_BAR; + epf_set_drvdata(epf, ntb); =20 dev_info(dev, "pci-ep epf driver loaded\n"); --=20 2.47.2