From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F714C43381 for ; Fri, 8 Mar 2019 14:04:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 717B420851 for ; Fri, 8 Mar 2019 14:04:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jOnc26QB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 717B420851 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Vilb352aUopLshDRLLsXFJ2QyA1JsKujrgRvJrjLuKc=; b=jOnc26QB0y8/Ne ZiuOwU5IvBVUUvbSU+M+Xpl4piqMmkatRc1EfAtULPbo/ljDio6zsbDX3mLkiagVJHSicXMAtkui9 HxYb1AfOEcLQ4PM9QaEp82XuY8yVFPK7gT6GBdYb6ux6nSQe+PTgNv04P6JAqh+dfun0lCF4EnK7k yMva8C9gdkJtftGdcYq2zRNO5UV5r9PG0fXtsXpW5cfNa9E2ihX6BiVbqD82KbpKrLp83WVNXZ69D zJ43FyYIgoTXW/1GrYvCct1opL93WZ81GzLwjkGN1ZnqrRZrVW/QGSgh41tUFB0h7S2IGhm8W2fKd v5IAe8CRth9SRHla/taQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h2G6d-0003W8-Sy; Fri, 08 Mar 2019 14:04:11 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h2G6a-0003VZ-01 for linux-arm-kernel@lists.infradead.org; Fri, 08 Mar 2019 14:04:09 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x28DvLnv032274; Fri, 8 Mar 2019 15:03:58 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2qyhknp4v4-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 08 Mar 2019 15:03:58 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 567A049; Fri, 8 Mar 2019 14:03:56 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag3node3.st.com [10.75.127.9]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1F6495743; Fri, 8 Mar 2019 14:03:56 +0000 (GMT) Received: from SFHDAG5NODE3.st.com (10.75.127.15) by SFHDAG3NODE3.st.com (10.75.127.9) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 8 Mar 2019 15:03:55 +0100 Received: from SFHDAG5NODE3.st.com ([fe80::7c09:5d6b:d2c7:5f47]) by SFHDAG5NODE3.st.com ([fe80::7c09:5d6b:d2c7:5f47%20]) with mapi id 15.00.1347.000; Fri, 8 Mar 2019 15:03:55 +0100 From: Fabien DESSENNE To: Marc Zyngier , Thomas Gleixner , Jason Cooper , Maxime Coquelin , Alexandre TORGUE , "linux-kernel@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH] irqchip: stm32: add a second level init to request hwspinlock Thread-Topic: [PATCH] irqchip: stm32: add a second level init to request hwspinlock Thread-Index: AQHU1QIoQlGKLyEqVUCXZ0malJJs9aYATz+AgAFlgYA= Date: Fri, 8 Mar 2019 14:03:55 +0000 Message-ID: References: <1551975829-16350-1-git-send-email-fabien.dessenne@st.com> <97040a1e-7a24-3d41-c3b7-43b551a70825@arm.com> In-Reply-To: <97040a1e-7a24-3d41-c3b7-43b551a70825@arm.com> Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.50] Content-ID: <74F710C22D289047BF71DC5B245F4CD8@st.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-08_12:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190308_060408_322416_0D724B14 X-CRM114-Status: GOOD ( 20.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin GAIGNARD Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Marc, Thank you for your feedback. Let me try to explain this patch, and the reason of its unusual implementation choices. Regarding the driver init mode: As an important requirement, I want to keep this irq driver declared with IRQCHIP_DECLARE(), so it is initialized early from start_kernel()/init_IRQ(). Most of the other irq drivers are implemented this way and I imagine that this ensures the availability of the irq drivers, before the other platform drivers get probed. Regarding the second init: With the usage of the hwspinlock framework (used to protect against coprocessor concurrent access to registers) we have a problem as the hwspinlock driver is not available when the irq driver is being initialized. In order to solve this, I added a second initialization where we get a reference to hwspinlock. You pointed that we are not supposed to use of_node_clear_flag (which allows to get a second init call) : I spent some time to find any information about it, but could not find any reason to not use it. Please, let me know if I missed something here. Regarding the inits sequence and dependencies: - The second init is guaranteed to be called after the first one, since start_kernel()->init_IRQ() is called before platform drivers init. - During the second init, the dependency with the hwspinlock driver is implemented correctly : it makes use of defered probe when needed. I understand that this patch is 'surprising' but I hope that my explanations justify its implementation. Waiting for your feedback BR Fabien On 07/03/2019 5:44 PM, Marc Zyngier wrote: > On 07/03/2019 16:23, Fabien Dessenne wrote: >> Requesting hwspinlock, at the first time it is used, is not correct: >> indeed, at that moment we are under raw_spin_lock_irqsave() context and >> hwspin_lock_request_specific() may sleep ("BUG: sleeping function called >> from invalid context"). >> Requesting hwspinlock during the init (stm32*_exti_of_init()) is also >> not possible (the hwspinlock framework is not ready at that stage of the >> kernel init). >> As a consequence, add a second level init (probed with arch_initcall) >> where we can safely request hwspinlock. > No, this is fairly broken. You're playing with stuff you're not supposed > to (OF_POPULATE? really?), and adding initcalls is completely unreliable > (things depend on the link order and will randomly break). > > If you need dependencies, implement them correctly. Turn this driver > into a real device driver (in the platform device sense), and return > PROBE_DEFER when you can't find your dependency. > > Thanks, > > M. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel