cpuidle: Fix build for Linux v6.13

Commit ef4c675dc296 ("genirq: Unexport nr_irqs") unexported 'nr_irqs' in
Linux v6.13 and this breaks the build for the cpuidle-debugfs driver.
For Linux v6.13 the number of IRQs can be queried by using the function
irq_get_nr_irqs() instead. Fix the build by using conftest to detect if
the function irq_get_nr_irqs() and use this function if it is present.

Bug 4991705

Change-Id: I98d477896fcf9e8d2e1afa21e2f7ba4d071ab442
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3261690
(cherry picked from commit 3fd3699807afd1503c72e1d2a1610ef0e4862197)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3499748
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
Tested-by: Brad Griffis <bgriffis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2024-12-03 16:07:25 +00:00
committed by mobile promotions
parent ac523e2cad
commit 814fdf0d88
3 changed files with 36 additions and 5 deletions

View File

@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/*
* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All Rights Reserved.
*
* Module to force cpuidle states through debugfs files.
*
*/
#include <nvidia/conftest.h>
#include <linux/module.h>
#include <linux/irq.h>
#include <linux/irqdesc.h>
@@ -26,9 +26,16 @@ static void suspend_all_device_irqs(void)
{
struct irq_data *data;
struct irq_desc *desc;
unsigned int nirqs;
int irq;
for (irq = 0, data = irq_get_irq_data(irq); irq < nr_irqs;
#if defined(NV_IRQ_GET_NR_IRQS_PRESENT) /* Linux v6.13 */
nirqs = irq_get_nr_irqs();
#else
nirqs = nr_irqs;
#endif
for (irq = 0, data = irq_get_irq_data(irq); irq < nirqs;
irq++, data = irq_get_irq_data(irq)) {
if (!data)
continue;
@@ -44,9 +51,16 @@ static void resume_all_device_irqs(void)
{
struct irq_data *data;
struct irq_desc *desc;
unsigned int nirqs;
int irq;
for (irq = 0, data = irq_get_irq_data(irq); irq < nr_irqs;
#if defined(NV_IRQ_GET_NR_IRQS_PRESENT)
nirqs = irq_get_nr_irqs();
#else
nirqs = nr_irqs;
#endif
for (irq = 0, data = irq_get_irq_data(irq); irq < nirqs;
irq++, data = irq_get_irq_data(irq)) {
if (!data)
continue;

View File

@@ -139,6 +139,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_driver_struct_remove_return_type_int
NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_mux_add_adapter_has_no_class_argument
NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock
NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += irq_get_nr_irqs
NV_CONFTEST_FUNCTION_COMPILE_TESTS += kthread_complete_and_exit
NV_CONFTEST_FUNCTION_COMPILE_TESTS += media_entity_remote_pad
NV_CONFTEST_FUNCTION_COMPILE_TESTS += mm_struct_struct_has_percpu_counter_rss_stat

View File

@@ -7465,6 +7465,22 @@ compile_test() {
compile_check_conftest "$CODE" "NV_IIO_DEV_OPAQUE_HAS_LOCK" "" "types"
;;
irq_get_nr_irqs)
#
# Determine if the function irq_get_nr_irqs() is present.
#
# Commit 5280a14a6079 ("genirq: Introduce irq_get_nr_irqs() and
# irq_set_nr_irqs()") added irq_get_nr_irqs() in Linux v6.13.
#
CODE="
#include <linux/irqnr.h>
void conftest_irq_get_nr_irqs(void) {
irq_get_nr_irqs();
}"
compile_check_conftest "$CODE" "NV_IRQ_GET_NR_IRQS_PRESENT" "" "functions"
;;
kthread_complete_and_exit)
#
# Determine if function kthread_complete_and_exit() is present.