From nobody Wed Jan 22 09:50:12 2025 Received: from mx.socionext.com (mx.socionext.com [202.248.49.38]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61426145324; Wed, 22 Jan 2025 02:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.248.49.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737512704; cv=none; b=agQBrobSBri3LxFI/7kZMYmwHK31tmhASQwKHwH6oJzW+ViYm3FuHTqY1JCTCeE+X3c+IkIyXO3cC4Ncu8ZnLCQ1ZcqGDqiwSfkS5sGR9RllRKYJbVnlk7lduxJhPFPFR3F0/fYoB3UyTmBzdfUUSIQJblwrR2KazZxjQBGUfjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737512704; c=relaxed/simple; bh=/6U8WaefUiYDBAPIWBEtvBPVshgWitlCi0YZkJbyDCc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jAGyZl+3RtmxJPEH1ooZR7Umvx0w+oJmWs+unVB98mDnxlLRrh+mDBpg/s+Pk8drXvDYtwNn/wWWFg/tKAwt+YsITMUnmxggWlvhkRiL+oM/EcUo1lBIf7JoV48PRN5ToaFV/maL643isTT0aVMCt/+mei3BUHvOoJ/Zzn3l6lU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=socionext.com; spf=pass smtp.mailfrom=socionext.com; arc=none smtp.client-ip=202.248.49.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=socionext.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=socionext.com Received: from unknown (HELO iyokan2-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 22 Jan 2025 11:24:54 +0900 Received: from mail.mfilter.local (mail-arc01.css.socionext.com [10.213.46.36]) by iyokan2-ex.css.socionext.com (Postfix) with ESMTP id 0E2D12009097; Wed, 22 Jan 2025 11:24:54 +0900 (JST) Received: from kinkan2.css.socionext.com ([172.31.9.51]) by m-FILTER with ESMTP; Wed, 22 Jan 2025 11:24:54 +0900 Received: from plum.e01.socionext.com (unknown [10.212.245.39]) by kinkan2.css.socionext.com (Postfix) with ESMTP id E42363732; Wed, 22 Jan 2025 11:24:52 +0900 (JST) From: Kunihiko Hayashi To: Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=8F=AB=CDski?= , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Lorenzo Pieralisi , Gustavo Pimentel Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi , stable@vger.kernel.org Subject: [PATCH v2 1/3] misc: pci_endpoint_test: Avoid issue of interrupts remaining after request_irq error Date: Wed, 22 Jan 2025 11:24:44 +0900 Message-Id: <20250122022446.2898248-2-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250122022446.2898248-1-hayashi.kunihiko@socionext.com> References: <20250122022446.2898248-1-hayashi.kunihiko@socionext.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" After devm_request_irq() fails with error, pci_endpoint_test_free_irq_vectors() is called to free allocated vectors with pci_free_irq_vectors(). However some requested IRQs are still allocated, so there are still /proc/irq/* entries remaining and we encounters WARN() with the following message: remove_proc_entry: removing non-empty directory 'irq/30', leaking at least 'pci-endpoint-test.0' WARNING: CPU: 0 PID: 80 at fs/proc/generic.c:717 remove_proc_entry +0x190/0x19c To solve this issue, set the number of remaining IRQs and release the IRQs in advance by calling pci_endpoint_test_release_irq(). Cc: stable@vger.kernel.org Fixes: e03327122e2c ("pci_endpoint_test: Add 2 ioctl commands") Signed-off-by: Kunihiko Hayashi --- drivers/misc/pci_endpoint_test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_t= est.c index 3702dcc89ab7..302955c20979 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -252,6 +252,9 @@ static bool pci_endpoint_test_request_irq(struct pci_en= dpoint_test *test) break; } =20 + test->num_irqs =3D i; + pci_endpoint_test_release_irq(test); + return false; } =20 --=20 2.25.1 From nobody Wed Jan 22 09:50:12 2025 Received: from mx.socionext.com (mx.socionext.com [202.248.49.38]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B0461494A3; Wed, 22 Jan 2025 02:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.248.49.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737512705; cv=none; b=X4FCr4GOwyziCJPIk5OZuP8Wl70wDhAALx0eg74X5/YTnGyXMR+RoMxb/EgLYiek07bEIH59GkNMfr6pR4ZCv6/u4TCcfE9whZuFxqrAfZkoxzRQ6LCoyfg9DLzUxf4YPq3N5RZC0wbtbPBd0sgZ6KeCEv6IEZm/zNQtN/bBgDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737512705; c=relaxed/simple; bh=t/vh29f67FFXM/scGWVX11/EjOoNhgxeZRGL5kwotWo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XkpCkkOL0xFbgmKLczK8Jk9fa3lelYfuRI5u+e1/gYuhUi6xq60c4wCeWWZ2CTr4NNE75olHJWH7560j3vLpEm/4Q7ozv7DXJLgiHs87xdJC/zU6G840YR4geDEW+rI/+90EgkA92cTwhJfsiT8i1U13ZwN1lJljPevlQvUrwXQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=socionext.com; spf=pass smtp.mailfrom=socionext.com; arc=none smtp.client-ip=202.248.49.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=socionext.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=socionext.com Received: from unknown (HELO kinkan2-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 22 Jan 2025 11:24:55 +0900 Received: from mail.mfilter.local (mail-arc01.css.socionext.com [10.213.46.36]) by kinkan2-ex.css.socionext.com (Postfix) with ESMTP id 9492F2010183; Wed, 22 Jan 2025 11:24:55 +0900 (JST) Received: from kinkan2.css.socionext.com ([172.31.9.51]) by m-FILTER with ESMTP; Wed, 22 Jan 2025 11:24:55 +0900 Received: from plum.e01.socionext.com (unknown [10.212.245.39]) by kinkan2.css.socionext.com (Postfix) with ESMTP id 4CEE6C3C1E; Wed, 22 Jan 2025 11:24:54 +0900 (JST) From: Kunihiko Hayashi To: Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=8F=AB=CDski?= , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Lorenzo Pieralisi , Gustavo Pimentel Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi , stable@vger.kernel.org Subject: [PATCH v2 2/3] misc: pci_endpoint_test: Fix disyplaying irq_type after request_irq error Date: Wed, 22 Jan 2025 11:24:45 +0900 Message-Id: <20250122022446.2898248-3-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250122022446.2898248-1-hayashi.kunihiko@socionext.com> References: <20250122022446.2898248-1-hayashi.kunihiko@socionext.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are two variables that indicate the interrupt type to be used in the next test execution, global "irq_type" and test->irq_type. The former is referenced from pci_endpoint_test_get_irq() to preserve the current type for ioctl(PCITEST_GET_IRQTYPE). In pci_endpoint_test_request_irq(), since this global variable is referenced when an error occurs, the unintended error message is displayed. For example, the following message shows "MSI 3" even if the current irq type becomes "MSI-X". # pcitest -i 2 pci-endpoint-test 0000:01:00.0: Failed to request IRQ 30 for MSI 3 SET IRQ TYPE TO MSI-X: NOT OKAY Fix this issue by using test->irq_type instead of global "irq_type". Cc: stable@vger.kernel.org Fixes: b2ba9225e031 ("misc: pci_endpoint_test: Avoid using module parameter= to determine irqtype") Signed-off-by: Kunihiko Hayashi --- drivers/misc/pci_endpoint_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_t= est.c index 302955c20979..a342587fc78a 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -235,7 +235,7 @@ static bool pci_endpoint_test_request_irq(struct pci_en= dpoint_test *test) return true; =20 fail: - switch (irq_type) { + switch (test->irq_type) { case IRQ_TYPE_INTX: dev_err(dev, "Failed to request IRQ %d for Legacy\n", pci_irq_vector(pdev, i)); --=20 2.25.1 From nobody Wed Jan 22 09:50:12 2025 Received: from mx.socionext.com (mx.socionext.com [202.248.49.38]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08AD414A619; Wed, 22 Jan 2025 02:25:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.248.49.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737512706; cv=none; b=G2151OeXIiTr06gAkWfQjxmyEWfTVTxnW6ZDNeJSsYW28Ozzu9K1nJdx7nD4EIbncgGpNQGIzctipnf/8+g8zUnvj+amwfD3U5i/D9Yv1gNm3YnP+mVdpKLd9Tywuun79yy6Ea+4VRt2jRGAgknfY+Clb7T164+EjBIt1KK+19w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737512706; c=relaxed/simple; bh=zNjjVTNpCe9/02Yg7k2e+F/dI6XDTX/eYAktHa0ZlHA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uKifPFxgOjb++Er0CEaxDu8kve8IlMdT6XVMtmGsdDCC+RfZZO2YzVdO/osGkdp8Z93I/m4N545vC4Grgl7ctYOvaPnfSIow5vvYi81Ayr3A3jh1abpeyJkmYXHvoUWb9CH8pF5lIQh4gebF9IY0sJ7wiWzZARGnFuezp4fb8rc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=socionext.com; spf=pass smtp.mailfrom=socionext.com; arc=none smtp.client-ip=202.248.49.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=socionext.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=socionext.com Received: from unknown (HELO kinkan2-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 22 Jan 2025 11:24:56 +0900 Received: from mail.mfilter.local (mail-arc01.css.socionext.com [10.213.46.36]) by kinkan2-ex.css.socionext.com (Postfix) with ESMTP id 8C1DE2010183; Wed, 22 Jan 2025 11:24:56 +0900 (JST) Received: from kinkan2.css.socionext.com ([172.31.9.51]) by m-FILTER with ESMTP; Wed, 22 Jan 2025 11:24:56 +0900 Received: from plum.e01.socionext.com (unknown [10.212.245.39]) by kinkan2.css.socionext.com (Postfix) with ESMTP id A537C3730; Wed, 22 Jan 2025 11:24:55 +0900 (JST) From: Kunihiko Hayashi To: Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=8F=AB=CDski?= , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Lorenzo Pieralisi , Gustavo Pimentel Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi , stable@vger.kernel.org Subject: [PATCH v2 3/3] misc: pci_endpoint_test: Fix irq_type to convey the correct type Date: Wed, 22 Jan 2025 11:24:46 +0900 Message-Id: <20250122022446.2898248-4-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250122022446.2898248-1-hayashi.kunihiko@socionext.com> References: <20250122022446.2898248-1-hayashi.kunihiko@socionext.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are two variables that indicate the interrupt type to be used in the next test execution, "irq_type" as global and test->irq_type. The global is referenced from pci_endpoint_test_get_irq() to preserve the current type for ioctl(PCITEST_GET_IRQTYPE). The type set in this function isn't reflected in the global "irq_type", so ioctl(PCITEST_GET_IRQTYPE) returns the previous type. As a result, the wrong type will be displayed in "pcitest" as follows: # pcitest -i 0 SET IRQ TYPE TO LEGACY: OKAY # pcitest -I GET IRQ TYPE: MSI Fix this issue by propagating the current type to the global "irq_type". Cc: stable@vger.kernel.org Fixes: b2ba9225e031 ("misc: pci_endpoint_test: Avoid using module parameter= to determine irqtype") Signed-off-by: Kunihiko Hayashi --- drivers/misc/pci_endpoint_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_t= est.c index a342587fc78a..33058630cd50 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -742,6 +742,7 @@ static bool pci_endpoint_test_set_irq(struct pci_endpoi= nt_test *test, if (!pci_endpoint_test_request_irq(test)) goto err; =20 + irq_type =3D test->irq_type; return true; =20 err: --=20 2.25.1