Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9203512ybi; Tue, 23 Jul 2019 23:53:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2Ne/eoBWx+dZzSwGw47SXdeReFDZsMhbYYddIzUXukm7DfhJRSm+HDqYYdRF5SRvpanR9 X-Received: by 2002:a17:902:2926:: with SMTP id g35mr84057375plb.269.1563951223119; Tue, 23 Jul 2019 23:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563951223; cv=none; d=google.com; s=arc-20160816; b=0gQ/TkUvX3dzHHilqCGCJae8hakHPMbFDaZXOBKAzuOV+YZebq0gXLuMGdsBQzsTFf irlXwFz3WCp/5XmC8MkPHZ4kUkvrdh16mwlek0Fj0kPDP+pxi1agt+2L/nHjWfThPYSC hvoi38h9Vw5GTQM0FlIPiYjpKugHotWTwD14YcpJhKIXylawwGbaNpODAlR42C3N77Kf I5IOJkaoJXMKJENVJYhRijMr949Om/yDYiuo23Lsd23cf8cioPCuhW+E2Qxe6PhcyATx QWS4x6vuA5dpLCrTP8JJcatMzCKQ9Y9R8FSIVj/+tOjqKsVli+PWre/35lp3bN3sVcHM CqgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=MFrd7UXHo5qqpaehbv5wqzqFosN1Fwn1uRNnU+1Tt8I=; b=dFPMFuqGD2IZgBwXMwNZyez0ePO+NOa2QENgDE6SP2fKh9iD9oWviSh1mKxRIQHVa/ bIl/+FaV9WdNrRRtuEkC+Qky5D0ZxgRxIG383rq3F/jJpgak728/0Oi8H2S87qBriaDQ G1kWhf1N2yW9iqAMA2yHI8A16nqo3qq/GM8pOD8Ho89WLR1XTG+FtO7CupJyECyCG3/3 0qhM222ojiszZU0vYSmjL4uzVTMkYkWSi6i67FcjAacRJEzMeE4Ly95oX8kKnSTlJWFB 3GTI26a6DFUuO1DLsPc+WZjkOUoKL2FRISq0Jlkjm7H8++TEsYt7qbP6Pe5ICtlSsG0s Q/TQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1si14940381pgv.58.2019.07.23.23.53.27; Tue, 23 Jul 2019 23:53:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726148AbfGXGvJ (ORCPT + 99 others); Wed, 24 Jul 2019 02:51:09 -0400 Received: from foss.arm.com ([217.140.110.172]:35860 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbfGXGvI (ORCPT ); Wed, 24 Jul 2019 02:51:08 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E72CD28; Tue, 23 Jul 2019 23:51:07 -0700 (PDT) Received: from why (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2C79E3F694; Tue, 23 Jul 2019 23:53:10 -0700 (PDT) Date: Wed, 24 Jul 2019 07:51:03 +0100 From: Marc Zyngier To: pheragu@codeaurora.org Cc: Linux Kernel , Linux-arm Msm , psodagud@codeaurora.org, Tsoni , rananta@codeaurora.org, mnalajal@codeaurora.org Subject: Re: Warning seen when removing a module using irqdomain framework Message-ID: <20190724075103.00ae5924@why> In-Reply-To: References: Organization: ARM Ltd X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 23 Jul 2019 14:52:34 -0700 pheragu@codeaurora.org wrote: Hi Prakruthi, > Hi, > > I have been working on a interrupt controller driver that uses tree > based mapping for its domain (irq_domain_add_tree(..)). > If I understand correctly, the clients get a mapping when they call > platform_get_irq(..). However, after these clients are removed > (rmmod), when I try to remove the interrupt controller driver where > it calls irq_domain_remove(..), I hit this warning from > kernel/kernel/irq/irqdomain.c:: irq_domain_remove(..) > [WARN_ON(!radix_tree_empty(&domain->revmap_tree));]- > WARNING: CPU: 0 PID: 238 at /kernel/kernel/irq/irqdomain.c:246 irq_domain_remove+0x84/0x98 > > Also, I see that the requested IRQs by the clients are still present > (in /proc/interrupts) even after they had been removed. Hence, I just > wanted to know how to handle this warning. Should the client clean up > by calling irq_dispose_mapping(..) or is it the responsibility of the > interrupt controller driver to dispose the mappings one by one? In general, building interrupt controller drivers as a module is a pretty difficult thing to do in a safe manner. As you found out, this relies on the irq_domain being "emptied" before it can be freed. There are some other gotchas in the rest of the IRQ stack as well. Doing that is hard. One of the reasons is that the OF subsystem will happily allocate all the interrupts it can even if there is no driver having requested them (see of_platform_populate). This means that you cannot track whether a client driver is using one of the interrupt your irqchip is in charge of. You can apply some heuristics, but they are in general all wrong. Fixing the OF subsystem is possible, but will break a lot of platforms that will have to be identified and fixed one by one. Another possibility would be to refcount irqdescs, and make sure the irqdomain directly holds pointers to them. Doable, but may create overhead. To sum it up, don't build your irqchip driver as a module if you can avoid it. If you can't, you'll have to be very careful about how the mapping is established (make sure it is not created by of_platform_populate), and use irq_dispose_mapping in the client drivers. Hope this helps, M. -- Without deviation from the norm, progress is not possible.