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=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 0DFEEC11F68 for ; Wed, 30 Jun 2021 18:49:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E945061431 for ; Wed, 30 Jun 2021 18:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233587AbhF3Sw1 (ORCPT ); Wed, 30 Jun 2021 14:52:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:43324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233046AbhF3SwZ (ORCPT ); Wed, 30 Jun 2021 14:52:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 09F9361426; Wed, 30 Jun 2021 18:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625078996; bh=KG5Bqyi3jxIYrNsBw3UY3iU1TyTs0dI1AHQH1CTlP64=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=CFRO26B8UzegkPMTQBrMAKRXhkzPFZxRCW3DZesVDQR2m9NbxLWdLHuWRsSDIwyaG aE4cOx0n52hYXGBrXbsrIRS0aUEz1ANdHGxl1dtP20+JDKhJI6qgv6uYjABRLIPVCe NFttkrr9UheWlTihMLH5ZJexzX1MC1GBE1wNQ3r0djrOxl63MQ7zkGAyBdz2L01FW0 6BJBL/zBjF4FEQ4/0zuQPu0wpWHHv1JFiXmTbytq5g/6YF5kouXy1fCvkczksZnrp4 BgyFjavilOZ4wAq9gbQBlcE5yZymxNo/omBtYH74fKk3znEawB7q4db4tqT/qHEF20 TCM79k+8xTEnA== Date: Wed, 30 Jun 2021 13:49:54 -0500 From: Bjorn Helgaas To: Robin Murphy Cc: Javier Martinez Canillas , linux-kernel@vger.kernel.org, Peter Robinson , Shawn Lin , Bjorn Helgaas , Heiko Stuebner , Lorenzo Pieralisi , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, Michal Simek , Ley Foon Tan , rfi@lists.rocketboards.org, Jingoo Han , Thierry Reding , Jonathan Hunter , linux-tegra@vger.kernel.org Subject: Re: [PATCH v2] PCI: rockchip: Avoid accessing PCIe registers with clocks gated Message-ID: <20210630184954.GA4169648@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3d5a983f-bfdd-d79b-4ec9-357ea26dd2c8@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On Tue, Jun 29, 2021 at 11:52:44AM +0100, Robin Murphy wrote: > Well, it does use devm_request_irq() so the handler should be unregistered > by devres *after* ->remove has finished, however that does still leave a > potential race window in which a pending IRQ could be taken during the later > part of rockchip_pcie_remove() after it has started turning off critical > things. Unless the clocks and regulators can also be delegated to devres, it > might be more robust to explicitly manage the IRQs as well. Mixing the two > schemes can be problematic when the exact order of both setup and teardown > matters. Thanks for this. I missed this problem. We have lots of PCI controller drivers that use some devm interfaces but use the non-devm clk_prepare_enable(), and they generally turn things off in their .remove() methods, which is obviously before any devm unregistration. Many .suspend() methods turn off clocks and power while leaving the IRQ handler installed. Should we get an interrupt from our device after .suspend()? *Probably* not, but it makes me a little queasy to rely on that, or to rely on the assumption that the IRQ is not shared. Bjorn 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=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 547DFC11F65 for ; Wed, 30 Jun 2021 18:50:14 +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 228356142C for ; Wed, 30 Jun 2021 18:50:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 228356142C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+linux-rockchip=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.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=aBpgLnVQIrW5BZZ/2Lmqc1cZDAJRqhtwQKRDn2azVcI=; b=eNC/1A29HmZZex Tvrfz9gYXqN3v/VciJveNwkRLYnAEGz16Y99N2t7kY0R6EDyNngpBzSZcLmAJ6ImmR+ZcMwGzdjgg PzC6wJctu9G9BjFx1AGgsPfK+WRJtSelmZJPbm8ygRB6EuWv/+6qg3YVMVCb4TinKuncYtxci69Hj scYriI24+xzjxlZir9UyY02OP+Kv+NjF5qipbKG6ldU1N5j/WwMPrYF0Q2UM6E4Trc3vZlBqatRDN PXRRaxQohDWOq1bCPpMhztoKMSSfREaFFsm9+x3Rm99QjPv+4ut4XI5y0xtBHe3Vlm5mna7ecY5Cp TBG2eL/dKStg0W1agCUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyfHn-00F2kW-8e; Wed, 30 Jun 2021 18:50:11 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyfHZ-00F2hV-IF; Wed, 30 Jun 2021 18:49:58 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 09F9361426; Wed, 30 Jun 2021 18:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625078996; bh=KG5Bqyi3jxIYrNsBw3UY3iU1TyTs0dI1AHQH1CTlP64=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=CFRO26B8UzegkPMTQBrMAKRXhkzPFZxRCW3DZesVDQR2m9NbxLWdLHuWRsSDIwyaG aE4cOx0n52hYXGBrXbsrIRS0aUEz1ANdHGxl1dtP20+JDKhJI6qgv6uYjABRLIPVCe NFttkrr9UheWlTihMLH5ZJexzX1MC1GBE1wNQ3r0djrOxl63MQ7zkGAyBdz2L01FW0 6BJBL/zBjF4FEQ4/0zuQPu0wpWHHv1JFiXmTbytq5g/6YF5kouXy1fCvkczksZnrp4 BgyFjavilOZ4wAq9gbQBlcE5yZymxNo/omBtYH74fKk3znEawB7q4db4tqT/qHEF20 TCM79k+8xTEnA== Date: Wed, 30 Jun 2021 13:49:54 -0500 From: Bjorn Helgaas To: Robin Murphy Cc: Javier Martinez Canillas , linux-kernel@vger.kernel.org, Peter Robinson , Shawn Lin , Bjorn Helgaas , Heiko Stuebner , Lorenzo Pieralisi , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, Michal Simek , Ley Foon Tan , rfi@lists.rocketboards.org, Jingoo Han , Thierry Reding , Jonathan Hunter , linux-tegra@vger.kernel.org Subject: Re: [PATCH v2] PCI: rockchip: Avoid accessing PCIe registers with clocks gated Message-ID: <20210630184954.GA4169648@bjorn-Precision-5520> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3d5a983f-bfdd-d79b-4ec9-357ea26dd2c8@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210630_114957_660907_B28D636A X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org On Tue, Jun 29, 2021 at 11:52:44AM +0100, Robin Murphy wrote: > Well, it does use devm_request_irq() so the handler should be unregistered > by devres *after* ->remove has finished, however that does still leave a > potential race window in which a pending IRQ could be taken during the later > part of rockchip_pcie_remove() after it has started turning off critical > things. Unless the clocks and regulators can also be delegated to devres, it > might be more robust to explicitly manage the IRQs as well. Mixing the two > schemes can be problematic when the exact order of both setup and teardown > matters. Thanks for this. I missed this problem. We have lots of PCI controller drivers that use some devm interfaces but use the non-devm clk_prepare_enable(), and they generally turn things off in their .remove() methods, which is obviously before any devm unregistration. Many .suspend() methods turn off clocks and power while leaving the IRQ handler installed. Should we get an interrupt from our device after .suspend()? *Probably* not, but it makes me a little queasy to rely on that, or to rely on the assumption that the IRQ is not shared. Bjorn _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip 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=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 F2B55C11F65 for ; Wed, 30 Jun 2021 18:51:57 +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 BDDE46142D for ; Wed, 30 Jun 2021 18:51:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDDE46142D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=Q8taQKkXz9T/fodv2tTxxfDYdm3QhfvnWpNR8zq/Zq0=; b=M4UGDw5VGBlGwa pnpU3wJMWrTZHpXJBlrC0TLruHVoEOKmNMrMXjv9zz1thBpWpplAJMCGRsXH675I7xBG9gjUk7BvF 8sR7/2c7hVYO8igPkvC/Roq0Xq9I870LvlKcaocPudP/2ypsib21cyZfmblZ1cYU9JXvWlL/nJ98I IY/V4vhHMuBDejXvUkyksmk9ibo9vx9WKU5gDqTkSlPxRlszIp2t2gi3b+TONzYmzu829eU0SBvEH sskYrEYHBbJDLeWQo907d3bbZlCICJTw55DbDPalFcW/ewcS5iqMLBaLFrPmKXhbBOyrirQ8yRTGq cQOgTDFgvNSrjUrVnd2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyfHd-00F2iP-Kx; Wed, 30 Jun 2021 18:50:01 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyfHZ-00F2hV-IF; Wed, 30 Jun 2021 18:49:58 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 09F9361426; Wed, 30 Jun 2021 18:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625078996; bh=KG5Bqyi3jxIYrNsBw3UY3iU1TyTs0dI1AHQH1CTlP64=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=CFRO26B8UzegkPMTQBrMAKRXhkzPFZxRCW3DZesVDQR2m9NbxLWdLHuWRsSDIwyaG aE4cOx0n52hYXGBrXbsrIRS0aUEz1ANdHGxl1dtP20+JDKhJI6qgv6uYjABRLIPVCe NFttkrr9UheWlTihMLH5ZJexzX1MC1GBE1wNQ3r0djrOxl63MQ7zkGAyBdz2L01FW0 6BJBL/zBjF4FEQ4/0zuQPu0wpWHHv1JFiXmTbytq5g/6YF5kouXy1fCvkczksZnrp4 BgyFjavilOZ4wAq9gbQBlcE5yZymxNo/omBtYH74fKk3znEawB7q4db4tqT/qHEF20 TCM79k+8xTEnA== Date: Wed, 30 Jun 2021 13:49:54 -0500 From: Bjorn Helgaas To: Robin Murphy Cc: Javier Martinez Canillas , linux-kernel@vger.kernel.org, Peter Robinson , Shawn Lin , Bjorn Helgaas , Heiko Stuebner , Lorenzo Pieralisi , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, Michal Simek , Ley Foon Tan , rfi@lists.rocketboards.org, Jingoo Han , Thierry Reding , Jonathan Hunter , linux-tegra@vger.kernel.org Subject: Re: [PATCH v2] PCI: rockchip: Avoid accessing PCIe registers with clocks gated Message-ID: <20210630184954.GA4169648@bjorn-Precision-5520> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3d5a983f-bfdd-d79b-4ec9-357ea26dd2c8@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210630_114957_660907_B28D636A X-CRM114-Status: GOOD ( 12.69 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 29, 2021 at 11:52:44AM +0100, Robin Murphy wrote: > Well, it does use devm_request_irq() so the handler should be unregistered > by devres *after* ->remove has finished, however that does still leave a > potential race window in which a pending IRQ could be taken during the later > part of rockchip_pcie_remove() after it has started turning off critical > things. Unless the clocks and regulators can also be delegated to devres, it > might be more robust to explicitly manage the IRQs as well. Mixing the two > schemes can be problematic when the exact order of both setup and teardown > matters. Thanks for this. I missed this problem. We have lots of PCI controller drivers that use some devm interfaces but use the non-devm clk_prepare_enable(), and they generally turn things off in their .remove() methods, which is obviously before any devm unregistration. Many .suspend() methods turn off clocks and power while leaving the IRQ handler installed. Should we get an interrupt from our device after .suspend()? *Probably* not, but it makes me a little queasy to rely on that, or to rely on the assumption that the IRQ is not shared. Bjorn _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel