From patchwork Wed Jun 9 15:06:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 55103 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id F35691007F6 for ; Thu, 10 Jun 2010 01:07:13 +1000 (EST) Received: by ozlabs.org (Postfix) id 53F27B7D5B; Thu, 10 Jun 2010 01:07:07 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from hera.kernel.org (hera.kernel.org [140.211.167.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E5794B7D20 for ; Thu, 10 Jun 2010 01:07:06 +1000 (EST) Received: from hera.kernel.org (localhost [127.0.0.1]) by hera.kernel.org (8.14.3/8.14.3) with ESMTP id o59F6ceN002970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Jun 2010 15:06:38 GMT X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.95.2 at hera.kernel.org Received: (from hpa@localhost) by hera.kernel.org (8.14.3/8.14.2/Submit) id o59F6bto002965; Wed, 9 Jun 2010 15:06:37 GMT Date: Wed, 9 Jun 2010 15:06:37 GMT X-Authentication-Warning: hera.kernel.org: hpa set sender to bounces.tip@hpa.at.zytor.com using -f From: tip-bot for Thomas Gleixner To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/urgent] genirq: Deal with desc->set_type() changing desc->chip Message-ID: Git-Commit-ID: 4673247562e39a17e09440fa1400819522ccd446 X-Mailer: tip-git-log-daemon MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk X-Spam-Status: No, score=0.4 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on hera.kernel.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.3 (hera.kernel.org [127.0.0.1]); Wed, 09 Jun 2010 15:06:39 +0000 (UTC) Cc: eha@doredevelopment.dk, linuxppc-dev@ozlabs.org, mingo@redhat.com, hpa@zytor.com, tglx@linutronix.de X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Reply-To: linux-kernel@vger.kernel.org, mingo@redhat.com, hpa@zytor.com, benh@kernel.crashing.org, linuxppc-dev@ozlabs.org, eha@doredevelopment.dk, tglx@linutronix.de List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Commit-ID: 4673247562e39a17e09440fa1400819522ccd446 Gitweb: http://git.kernel.org/tip/4673247562e39a17e09440fa1400819522ccd446 Author: Thomas Gleixner AuthorDate: Mon, 7 Jun 2010 17:53:51 +0200 Committer: Thomas Gleixner CommitDate: Wed, 9 Jun 2010 17:05:08 +0200 genirq: Deal with desc->set_type() changing desc->chip The set_type() function can change the chip implementation when the trigger mode changes. That might result in using an non-initialized irq chip when called from __setup_irq() or when called via set_irq_type() on an already enabled irq. The set_irq_type() function should not be called on an enabled irq, but because we forgot to put a check into it, we have a bunch of users which grew the habit of doing that and it never blew up as the function is serialized via desc->lock against all users of desc->chip and they never hit the non-initialized irq chip issue. The easy fix for the __setup_irq() issue would be to move the irq_chip_set_defaults(desc->chip) call after the trigger setting to make sure that a chip change is covered. But as we have already users, which do the type setting after request_irq(), the safe fix for now is to call irq_chip_set_defaults() from __irq_set_trigger() when desc->set_type() changed the irq chip. It needs a deeper analysis whether we should refuse to change the chip on an already enabled irq, but that'd be a large scale change to fix all the existing users. So that's neither stable nor 2.6.35 material. Reported-by: Esben Haabendal Signed-off-by: Thomas Gleixner Cc: Benjamin Herrenschmidt Cc: linuxppc-dev Cc: stable@kernel.org --- kernel/irq/manage.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 3164ba7..e149748 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -456,6 +456,9 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, /* note that IRQF_TRIGGER_MASK == IRQ_TYPE_SENSE_MASK */ desc->status &= ~(IRQ_LEVEL | IRQ_TYPE_SENSE_MASK); desc->status |= flags; + + if (chip != desc->chip) + irq_chip_set_defaults(desc->chip); } return ret;