From patchwork Thu Jan 23 12:01:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 13948209 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 E4C6A1D432F; Thu, 23 Jan 2025 12:01:58 +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=1737633719; cv=none; b=G5QRv5j1FItLsH68iAMeKycm8wVRTxr3LQRUiyJW34kvctV3WvM/qjeiBNt63/9iQ7xiPew65oJ1O1wbvBizjuCU5zNj3a9qZcx3J3JgUcFOEGUHmt/TcmWPMfK3X6Ft8IU5FjDRnkxpQRe8V4KDqbXvZUY5M3sK1mUafOWgUdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737633719; c=relaxed/simple; bh=8fqakwhEliIhTWw+vJJvLaeNsJgd+hbvnPpuAgtm8Lg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=XNdi+Ui+3Wv3Vs+q4nC2KY5/o6y+6LzOuFNsjifponZ0AlPMTEJX42uQGcs8HEgHyl1STHYOZXZ1D3gz6C+8pKD24pP6498drHXW9AgO9nESecaT11ATB19RYyBOCDNjwO2C02qXXKqIP2Nq/hRHj6u+PvJgJvqTzujTtWF9deQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ExQ0KCoD; 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="ExQ0KCoD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C375C4CEDF; Thu, 23 Jan 2025 12:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737633718; bh=8fqakwhEliIhTWw+vJJvLaeNsJgd+hbvnPpuAgtm8Lg=; h=From:To:Cc:Subject:Date:From; b=ExQ0KCoDZOmubqrjMK1PBfxSEFLYtM03wAehat4iTHwqawGcLLkJyEvDC0vQoRiED FoVE4ST+0M14aGR+Ob4uq7Y4KvqXkBx5N+waC7bc53b2rD+yOo+GKAJhVfgUJ0WEhA ensqgd1Gln/vCZfmJNuB8CtAjR8ETT6kn6R0jqJSJFwrtkyJHndaWtQ+1tCwDp8i0Y 81EHdwGFtNe+hHeqV+OWLEjcv53groUT6sJXWN51xlVv8yZSSGlvzuZTZOYNoQpFvO qVRg4890JmVYUU7bWZwwKsfs4mSWdhkwxiyOwTN2mTPa01/JvlU/ywW8cd8baH+iSl MsIm89IUyxoeA== From: Niklas Cassel To: bhelgaas@google.com, kw@linux.com Cc: linux-pci@vger.kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org, manivannan.sadhasivam@linaro.org, Niklas Cassel Subject: [PATCH 1/2] misc: pci_endpoint_test: Give disabled BARs a distinct error code Date: Thu, 23 Jan 2025 13:01:48 +0100 Message-ID: <20250123120147.3603409-3-cassel@kernel.org> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1880; i=cassel@kernel.org; h=from:subject; bh=8fqakwhEliIhTWw+vJJvLaeNsJgd+hbvnPpuAgtm8Lg=; b=owGbwMvMwCV2MsVw8cxjvkWMp9WSGNIn6a9ZVhn4QeLqwTM7PVR/Pj99l7H9aIfnab3mOpvFl ye5ZFpUd5SyMIhxMciKKbL4/nDZX9ztPuW44h0bmDmsTCBDGLg4BWAiKVsZGfYo1PaH2dhWPH30 LTiFYYMixykvE9ZfMY35Xq+kS5ecj2Fk2KgWEK0vr/G3uEHMee+OvQc1/k0q0Ni5Qt2b04ujb1o eFwA= X-Developer-Key: i=cassel@kernel.org; a=openpgp; fpr=5ADE635C0E631CBBD5BE065A352FE6582ED9B5DA The current code returns -ENOMEM if test->bar[barno] is NULL. There can be two reasons why test->bar[barno] is NULL: 1) The pci_ioremap_bar() call in pci_endpoint_test_probe() failed. 2) The BAR was skipped, because it is disabled by the endpoint. Many PCI endpoint controller drivers will disable all BARs in their init function. A disabled BAR will have a size of 0. A PCI endpoint function driver will be able to enable any BAR that is not marked as BAR_RESERVED (which means that the BAR should not be touched by the EPF driver). Thus, perform check if the size is 0, before checking if test->bar[barno] is NULL, such that we can return different errors. This will allow the selftests to return SKIP instead of FAIL for disabled BARs. Signed-off-by: Niklas Cassel --- Hello PCI maintainers. This patch might give a trivial conflict with: https://lore.kernel.org/linux-pci/20250123095906.3578241-2-cassel@kernel.org/T/#u because the context lines (lines that haven't been changed) might be different. If there is a conflict, simply look at this patch by itself, and resolution should be trivial. drivers/misc/pci_endpoint_test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index d5ac71a49386..b95980b29eb9 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -292,11 +292,13 @@ static int pci_endpoint_test_bar(struct pci_endpoint_test *test, void *read_buf __free(kfree) = NULL; struct pci_dev *pdev = test->pdev; + bar_size = pci_resource_len(pdev, barno); + if (!bar_size) + return -ENODATA; + if (!test->bar[barno]) return -ENOMEM; - bar_size = pci_resource_len(pdev, barno); - if (barno == test->test_reg_bar) bar_size = 0x4; From patchwork Thu Jan 23 12:01:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 13948210 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 4E24820D51C; Thu, 23 Jan 2025 12:02:02 +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=1737633723; cv=none; b=BooLRig+Vw0laTxIZe8vjUoausGlkwZ1Z0FPMMaeJzYKu8JoTvw/XQ8ZR3LOZqPoALCpHSTRay7ALiQL7TjRA0qBQEooe2GjTPjjf6f17Bw0rHfPctkD4sp3yFgu0buxGHQ/psL4omfA4QopioURUO0hP6Zd979b+zqY1GXpwQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737633723; c=relaxed/simple; bh=SJfDFslsBozN9KlVdyTBzI9flaqI0LLi8HWs05pUThE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MT+kISV4qSRro+bxNOfbeUgDrkCUBvRD67rIuoVU/firA8k/rRhkFCWkjDHATsuYSABQaV1uEFz3MQ88/ysjySBR3BEhXGBq5EQ2ngHHORF+dQcwWRPmJDUs8cBiIFW3wBCHefTs6PllIE97ze1j+rHbB53PretmJSzyctE3vPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uJGmWo8r; 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="uJGmWo8r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0408BC4CEDF; Thu, 23 Jan 2025 12:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737633722; bh=SJfDFslsBozN9KlVdyTBzI9flaqI0LLi8HWs05pUThE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uJGmWo8rm5HV5aPCe2ZqxonDa1EiYFE2nf5xJXRlSYyjb9ASstAmR7m8jprTNw73g nRCppKb9/r0OYqiug+SP1x+56/XTZtG2QfEyQrEVKkP69HZycXtrTBwLjm/zNLauiT F5kUuKZj3w/v79yddMWyvSGlrQLOuAjq2RQlr0ombRiLzdjpJaqqkO9vtf5t586amK yeH5uJTjkQd/0yHjvHrdwlHzkqeghFA6iDiyGAWygS1JjGaup+qd6qcyGXSqHxz2Wt 1fPKSZXOM9e7nQqoWvfQLp4mMlWekUy+mBruCVIecW3k4bJ+IfreUYKlEPneDxu3An 8A32RsTS/3eqA== From: Niklas Cassel To: bhelgaas@google.com, kw@linux.com Cc: linux-pci@vger.kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org, manivannan.sadhasivam@linaro.org, Niklas Cassel Subject: [PATCH 2/2] selftests: pci_endpoint: Skip disabled BARs Date: Thu, 23 Jan 2025 13:01:49 +0100 Message-ID: <20250123120147.3603409-4-cassel@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250123120147.3603409-3-cassel@kernel.org> References: <20250123120147.3603409-3-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1522; i=cassel@kernel.org; h=from:subject; bh=SJfDFslsBozN9KlVdyTBzI9flaqI0LLi8HWs05pUThE=; b=owGbwMvMwCV2MsVw8cxjvkWMp9WSGNIn6W9oifA7ohJVL66rNJNR5uddG8YOk3dXOhRfarTb6 80+fXNHRykLgxgXg6yYIovvD5f9xd3uU44r3rGBmcPKBDKEgYtTACZS9IOR4e8xnuiDAsz/VYTL p817EbZuvtmGg9E1t7mMz02s01mbe4WRYT/f/hWqHV7Zq54vWqG0Kuc07/1SE34fI5spbZ1XCk2 6+QA= X-Developer-Key: i=cassel@kernel.org; a=openpgp; fpr=5ADE635C0E631CBBD5BE065A352FE6582ED9B5DA Currently BARs that have been disabled by the endpoint controller driver will result in a test FAIL. Returning FAIL for a BAR that is disabled seems overly pessimistic. There are EPC that disables one or more BARs intentionally. One reason for this is that there are certain EPCs that are hardwired to expose internal PCIe controller registers over a certain BAR, so the EPC driver disables such a BAR, such that the host will not overwrite random registers during testing. Such a BAR will be disabled by the EPC driver's init function, and the BAR will be marked as BAR_RESERVED, such that it will be unavailable to endpoint function drivers. Let's return FAIL only for BARs that are actually enabled and failed the test, and let's return skip for BARs that are not even enabled. Signed-off-by: Niklas Cassel --- tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c index c267b822c108..576c590b277b 100644 --- a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c +++ b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c @@ -65,6 +65,8 @@ TEST_F(pci_ep_bar, BAR_TEST) int ret; pci_ep_ioctl(PCITEST_BAR, variant->barno); + if (ret == -ENODATA) + SKIP(return, "BAR is disabled"); EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno); }