From: Joseph Jang <jjang@nvidia.com>
To: shuah@kernel.org, tglx@linutronix.de, helgaas@kernel.org,
mochs@nvidia.com, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Subject: Re: [PATCH] selftest: drivers: Add support to check duplicate hwirq
Date: Fri, 18 Oct 2024 12:29:58 +0800 [thread overview]
Message-ID: <533eb948-a061-4d62-8d89-5edbdaf785e6@nvidia.com> (raw)
In-Reply-To: <20240904014426.3404397-1-jjang@nvidia.com>
On 2024/9/4 9:44 AM, Joseph Jang wrote:
> Validate there are no duplicate hwirq from the irq debug
> file system /sys/kernel/debug/irq/irqs/* per chip name.
>
> One example log show 2 duplicated hwirq in the irq debug
> file system.
>
> $ sudo cat /sys/kernel/debug/irq/irqs/163
> handler: handle_fasteoi_irq
> device: 0019:00:00.0
> <SNIP>
> node: 1
> affinity: 72-143
> effectiv: 76
> domain: irqchip@0x0000100022040000-3
> hwirq: 0xc8000000
> chip: ITS-MSI
> flags: 0x20
>
> $ sudo cat /sys/kernel/debug/irq/irqs/174
> handler: handle_fasteoi_irq
> device: 0039:00:00.0
> <SNIP>
> node: 3
> affinity: 216-287
> effectiv: 221
> domain: irqchip@0x0000300022040000-3
> hwirq: 0xc8000000
> chip: ITS-MSI
> flags: 0x20
>
> The irq-check.sh can help to collect hwirq and chip name from
> /sys/kernel/debug/irq/irqs/* and print error log when find duplicate
> hwirq per chip name.
>
> Kernel patch ("PCI/MSI: Fix MSI hwirq truncation") [1] fix above issue.
> [1]: https://lore.kernel.org/all/20240115135649.708536-1-vidyas@nvidia.com/
>
> Signed-off-by: Joseph Jang <jjang@nvidia.com>
> Reviewed-by: Matthew R. Ochs <mochs@nvidia.com>
> ---
> tools/testing/selftests/drivers/irq/Makefile | 5 +++
> tools/testing/selftests/drivers/irq/config | 2 +
> .../selftests/drivers/irq/irq-check.sh | 39 +++++++++++++++++++
> 3 files changed, 46 insertions(+)
> create mode 100644 tools/testing/selftests/drivers/irq/Makefile
> create mode 100644 tools/testing/selftests/drivers/irq/config
> create mode 100755 tools/testing/selftests/drivers/irq/irq-check.sh
>
> diff --git a/tools/testing/selftests/drivers/irq/Makefile b/tools/testing/selftests/drivers/irq/Makefile
> new file mode 100644
> index 000000000000..d6998017c861
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/irq/Makefile
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +TEST_PROGS := irq-check.sh
> +
> +include ../../lib.mk
> diff --git a/tools/testing/selftests/drivers/irq/config b/tools/testing/selftests/drivers/irq/config
> new file mode 100644
> index 000000000000..a53d3b713728
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/irq/config
> @@ -0,0 +1,2 @@
> +CONFIG_GENERIC_IRQ_DEBUGFS=y
> +CONFIG_GENERIC_IRQ_INJECTION=y
> diff --git a/tools/testing/selftests/drivers/irq/irq-check.sh b/tools/testing/selftests/drivers/irq/irq-check.sh
> new file mode 100755
> index 000000000000..e784777043a1
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/irq/irq-check.sh
> @@ -0,0 +1,39 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +# This script need root permission
> +uid=$(id -u)
> +if [ $uid -ne 0 ]; then
> + echo "SKIP: Must be run as root"
> + exit 4
> +fi
> +
> +# Ensure debugfs is mounted
> +mount -t debugfs nodev /sys/kernel/debug 2>/dev/null
> +if [ ! -d "/sys/kernel/debug/irq/irqs" ]; then
> + echo "SKIP: irq debugfs not found"
> + exit 4
> +fi
> +
> +# Traverse the irq debug file system directory to collect chip_name and hwirq
> +hwirq_list=$(for irq_file in /sys/kernel/debug/irq/irqs/*; do
> + # Read chip name and hwirq from the irq_file
> + chip_name=$(cat "$irq_file" | grep -m 1 'chip:' | awk '{print $2}')
> + hwirq=$(cat "$irq_file" | grep -m 1 'hwirq:' | awk '{print $2}' )
> +
> + if [ -z "$chip_name" ] || [ -z "$hwirq" ]; then
> + continue
> + fi
> +
> + echo "$chip_name $hwirq"
> +done)
> +
> +dup_hwirq_list=$(echo "$hwirq_list" | sort | uniq -cd)
> +
> +if [ -n "$dup_hwirq_list" ]; then
> + echo "ERROR: Found duplicate hwirq"
> + echo "$dup_hwirq_list"
> + exit 1
> +fi
> +
> +exit 0
Hi Tglx,
I follow your suggestions
https://www.mail-archive.com/linux-kselftest@vger.kernel.org/msg16952.html
to enable IRQ DEBUG_FS and create a new script to scan duplicated hwirq.
If you have available time, would you please help to take a look at new
patch again ?
https://lore.kernel.org/all/20240904014426.3404397-1-jjang@nvidia.com/T/
Hi Shuah,
If you have time, could you help to take a look at the new patch ?
Thank you,
Joseph.
next prev parent reply other threads:[~2024-10-18 4:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 1:44 [PATCH] selftest: drivers: Add support to check duplicate hwirq Joseph Jang
2024-10-18 4:29 ` Joseph Jang [this message]
2024-10-18 15:23 ` Shuah Khan
2024-10-18 19:34 ` Bjorn Helgaas
2024-11-11 7:21 ` Joseph Jang
2024-11-22 17:54 ` Bjorn Helgaas
2024-12-01 11:38 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=533eb948-a061-4d62-8d89-5edbdaf785e6@nvidia.com \
--to=jjang@nvidia.com \
--cc=helgaas@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mochs@nvidia.com \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox