From patchwork Mon Sep 2 03:17:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Clark X-Patchwork-Id: 13786693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2CA99C54FC6 for ; Mon, 2 Sep 2024 03:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=T3N7De+0939d6NZS86Emr2LVxI0z0Wq/JpD0yjK8hS8=; b=Y5C115W3UR140PaJ8LNriKISC8 /B+y2DXAmgD1RTV5vQ2de4Cn11n9zUmhPJM8M6M72pDPtfFG/dq9Lk05UTMXndunmZchxQaITWkiM oPIWr22jgnt20sHShJ8b/A/rbiaZYkAhOiEG5IQhkzETYIaV6dL3xX8eoBhKm8nUBKHACYWkJERTd ilOqTfJTRPG0uGuRCq/bK/n8fd4PfH6zyN2MfvbaAFrsEXdRLZ8vyCQODLF1MTwKaYsvVKTxO1o97 b5w/1kHfvLH/bn5EydsQAzTGGh4G04AeYAwtZ8kxaDe6fI+ITbDjx+bgVGZydWCk1zBGhUeAVURhZ Hd5m2PMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skxai-0000000Cprp-2daR; Mon, 02 Sep 2024 03:18:56 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skxZp-0000000CplL-14ER for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 03:18:02 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2d877e9054eso1691609a91.3 for ; Sun, 01 Sep 2024 20:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725247080; x=1725851880; darn=lists.infradead.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=T3N7De+0939d6NZS86Emr2LVxI0z0Wq/JpD0yjK8hS8=; b=SHAX5B59ZE+lT5pYyZ35HI3nDpxFHBvDZ1yV6kmDJr0eqfDTb1QeYqGAfj0/ppvg8e wVS54gSSwU6vR6Bob+EKypsxxLqgfFjg1LBkQ7fQoWfnBbkCpV1JcWxEdgNh2CVcS3JV A4aOf+9qVmOfCGWritx5pRG4sVQatf4vYxWIqs185dtKvjUzzIBrN3+1et8ixBZAVv/A 5R1tVcbyEPstAqxNP6520Smp0Rr7kp91aPTSxc3ekyn4ErUX5ACN9B+ILzrAGgP/FIFe YqzPxYDlUDU5aD/kYUVb+0ZCXkyJ7THhGsElhgx0C+6uHd7LcTDbclJgPztQo/JrUu96 bDVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725247080; x=1725851880; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T3N7De+0939d6NZS86Emr2LVxI0z0Wq/JpD0yjK8hS8=; b=Hs6NfKAEeoC51uXgcHULkcAe4TSsRcOhmCh94b7TMlFBEEkvEMPjDPBu+1wzpc+FXf vauP454l/TH4Hj7BAmNJvRfPnNKpymKmtWHT4BpfcHnc0btW4YO4dxucYEtV9+ud4A2j 5YfBhWRkIaVOnrtpGgihZZ3vHzKol6w96O6ceo7IeQEuRPz/lxUJgJuA88Uf1+FMcPKT 7OxNmOLMH5ZkMXgnJrPF5CEwFizguaizk7LIVBgyv9qwCF5JD9Ht9fzE0o+cVN3AcXcw xuExGf3npDqS4KjHNnBrCtYQJPq/y+yVsKnkrax7VvZJA6BevsqaIAOAVinX915x/Yu4 uvMQ== X-Forwarded-Encrypted: i=1; AJvYcCXfTv4TTqqbJMq2cj4GOIibw/OhY0iRwEzyD8P9atST8TfShJLzHsAwGecGslYlIrLh1JAsapdi649c2KhhWSbk@lists.infradead.org X-Gm-Message-State: AOJu0YzyT1uHnY7l/msph4w2MZzCSRaZXcXm78ky2YAmh8N/qTaW5AIg Okudv7hAEkMbhHImOtYYYrmx41DnvfLm1Cu/wpFVofbjk7vo2z9a X-Google-Smtp-Source: AGHT+IEWSSoRYKEqR2rJ4k3fUTsPBa9GiQubzHTLYBrHBdJXXXfTtOgchXIWz+c85/pXoZtEse0cwg== X-Received: by 2002:a17:90b:4b45:b0:2d8:b923:b56a with SMTP id 98e67ed59e1d1-2d8b923b62emr3196107a91.41.1725247079364; Sun, 01 Sep 2024 20:17:59 -0700 (PDT) Received: from den-build ([116.228.68.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d8446f35eesm10365544a91.47.2024.09.01.20.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2024 20:17:58 -0700 (PDT) Date: Mon, 2 Sep 2024 11:17:53 +0800 From: Richard Clark To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, torvalds@linux-foundation.org, richard.xnu.clark@gmail.com Subject: [PATCH] irq: fix the interrupt trigger type override issue Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240901_201801_316545_733FA256 X-CRM114-Status: GOOD ( 17.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In current implementation, the trigger type in 'flags' when calling request_irq will override the type value get from the firmware(dt/acpi node) if they are not consistent, and the overrided trigger type value will be retained by irq_data, consequently the type value get from the firmware will not match the retained one next time in case the virq is available. Thus below error message will be observed by the __2nd__ 'insmod' within the 'insmod - rmmod - insmod' operation sequence for the same device driver kernel module, in which request_irq(..., IRQ_TYPE_LEVEL_HIGH, ...) is used: irq: type mismatch, failed to map hwirq-182 for interrupt-controller! The corresponding 'interrupts' property of that device node is: interrupts = <0 150 1>; This commit fixes the above issue by adding a new checker - irqd_trigger_type_was_set: the irq_create_fwspec_mapping(...) will return the interrupt number directly if the trigger type has been set previously. Signed-off-by: Richard Clark --- kernel/irq/irqdomain.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index cea8f6874b1f..fb0be8e73c5b 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -895,25 +895,25 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) */ virq = irq_find_mapping(domain, hwirq); if (virq) { + irq_data = irq_get_irq_data(virq); + if (!irq_data) { + virq = 0; + goto out; + } + /* * If the trigger type is not specified or matches the - * current trigger type then we are done so return the - * interrupt number. + * current trigger type or has been set previously then we are done so + * return the interrupt number. */ - if (type == IRQ_TYPE_NONE || type == irq_get_trigger_type(virq)) + if (type == IRQ_TYPE_NONE || type == irq_get_trigger_type(virq) || + irqd_trigger_type_was_set(irq_data)) goto out; - /* * If the trigger type has not been set yet, then set * it now and return the interrupt number. */ if (irq_get_trigger_type(virq) == IRQ_TYPE_NONE) { - irq_data = irq_get_irq_data(virq); - if (!irq_data) { - virq = 0; - goto out; - } - irqd_set_trigger_type(irq_data, type); goto out; }