From patchwork Sun Apr 9 19:59:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9671783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 98585601EB for ; Sun, 9 Apr 2017 19:59:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76A0E27F07 for ; Sun, 9 Apr 2017 19:59:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69AEB27F80; Sun, 9 Apr 2017 19:59:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E439B27F07 for ; Sun, 9 Apr 2017 19:59:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752435AbdDIT7W (ORCPT ); Sun, 9 Apr 2017 15:59:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53528 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752322AbdDIT7W (ORCPT ); Sun, 9 Apr 2017 15:59:22 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A44A7F342; Sun, 9 Apr 2017 19:59:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7A44A7F342 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=hdegoede@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7A44A7F342 Received: from shalem.localdomain.com (ovpn-116-110.ams2.redhat.com [10.36.116.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E899183AD; Sun, 9 Apr 2017 19:59:20 +0000 (UTC) From: Hans de Goede To: Thomas Gleixner Cc: Hans de Goede , linux-acpi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [RFC] Fix shared irq trigger-flags conflict when old irqaction uses IRQF_TRIGGER_NONE Date: Sun, 9 Apr 2017 21:59:18 +0200 Message-Id: <20170409195918.20864-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 09 Apr 2017 19:59:21 +0000 (UTC) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While writing a driver for the INT0002 ACPI device found on Intel Bay and Cherry Trail devices I hit the following error: "genirq: Flags mismatch irq 9. 00000084 (INT0002) vs. 00000080 (acpi)" This is caused by drivers/acpi/osl.c first doing: request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq) While the irqdata for the irq contains no trigger flags, resulting in an irqaction with IRQF_TRIGGER_NONE. And then the INT0002 driver I'm working on calling platform_get_irq which does: irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS); And then request_irq(irq, ..., IRQF_SHARED, ...) on the irq returned by platform_get_irq causes the error quoted above. Arguably the genirq code should not hit the shared irq trigger-flags mismatch code if the old irqaction has IRQF_TRIGGER_NONE as flags. This patch is an attempt at fixing this, but I'm not sure it is the right fix, hence it RFC status. Signed-off-by: Hans de Goede --- kernel/irq/manage.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index a4afe5c..24e5eef 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1212,8 +1212,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) * set the trigger type must match. Also all must * agree on ONESHOT. */ + unsigned int old_msk = old->flags & IRQF_TRIGGER_MASK; + + if (!old_msk) + old_msk = irqd_get_trigger_type(&desc->irq_data); + if (!((old->flags & new->flags) & IRQF_SHARED) || - ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) || + ((old_msk ^ new->flags) & IRQF_TRIGGER_MASK) || ((old->flags ^ new->flags) & IRQF_ONESHOT)) goto mismatch;