Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3888752pxv; Mon, 19 Jul 2021 11:11:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvR5enKWa8vGP8sN1bS15A83iv2bICGBH/ckegRDO0Hoorr2wLwEmUXKiaoYMmlkqB/pw8 X-Received: by 2002:a50:d982:: with SMTP id w2mr12319880edj.338.1626718278567; Mon, 19 Jul 2021 11:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626718278; cv=none; d=google.com; s=arc-20160816; b=anWb4Uvi0MoN4+tJDL9j4KIl+5cGBaohfWGhMvyWj8hhVaqBLmbtOK+zobTdPy7rUL eR7s2lYblCwNMo8eGpdQBlZaIQ0n6BfRQDlBiqVFQkEZmG7uRzmvPRbNNUbxQGSlJrZD f6iIguJVR5NeKizyE4bZ3P93uNgyVVZ2YX22r2jI4pJpsdhQZASx1Lods6ROLSj9tHvX oAtbNIgUl5fwIKT9BaaZD10+bfl/pPUNyl4DybZ1bPmW6omDAOT1jLtpJtg0HxoUwQmH OXX2T60hHvj0PpR1BWe+Lm2YMJ537Jx+ns/LoUvlcP8Rfs7FsuL70tDy8ff+iwkXIoMI zmig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Sr0Sg2e75wSa19j2MHrn8iy1lMwDGzjqEooSvRzTvkM=; b=OKu6bzt5CQE6JtmP7MRxE8POdMRrNctpfrZSEzHRY4pgXzl7za0L5ShQj3Dk4o5Mnh LlutccWafbI/zLErAF8UgY/1OB8SpIFMF26Kfkyquj2crmC/FT0PkQ/t+ppe6RBHE5r8 gBrI/A1S1cbIvMtHxVJYAFYf5WruDQ/Q7pNVbUZG6RJvixddrl6cefi26DDk32MRVXk3 CXcYz7q9DCgyy+TLh6KEffmuQNqwmNBX7Bfk5+Q8H2rrALCu/tv5hrS8XQ75yAGQsY3r QibqR/ZZQWs/n/5D1WJLpPVKwj18KYHvzDF7UXHrP8dSlXdqd1VaQCGi0Lx0d5+AuZ6u FM6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ymmK+LZ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si21827482ejc.291.2021.07.19.11.10.54; Mon, 19 Jul 2021 11:11:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ymmK+LZ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356766AbhGSRZC (ORCPT + 99 others); Mon, 19 Jul 2021 13:25:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:43678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349385AbhGSPpC (ORCPT ); Mon, 19 Jul 2021 11:45:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 53D7661376; Mon, 19 Jul 2021 16:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626711879; bh=usjltRtEuFp8h2ICKIOczpm839/NnubVdwqvLBLU3LI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ymmK+LZ1eN59icaisqbp62xx1ZGALwj4i0reXYxRGsZIsD4WVziNmanBi9Ed0eG70 HVNLYqOnlD8W1kNW8bUa4guYCfmRrNYbPrZ9J7qAHtVGQZAw72zpCwx7DzkUAbTLze McVtSLirWA2H26BP09t4YXeX1DG9gxzF28I3/4js= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Robinson , Javier Martinez Canillas , Lorenzo Pieralisi , Bjorn Helgaas , Shawn Lin , Sasha Levin Subject: [PATCH 5.12 167/292] PCI: rockchip: Register IRQ handlers after device and data are ready Date: Mon, 19 Jul 2021 16:53:49 +0200 Message-Id: <20210719144947.992885729@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.514164272@linuxfoundation.org> References: <20210719144942.514164272@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Javier Martinez Canillas [ Upstream commit 3cf5f7ab230e2b886e493c7a8449ed50e29d2b98 ] An IRQ handler may be called at any time after it is registered, so anything it relies on must be ready before registration. rockchip_pcie_subsys_irq_handler() and rockchip_pcie_client_irq_handler() read registers in the PCIe controller, but we registered them before turning on clocks to the controller. If either is called before the clocks are turned on, the register reads fail and the machine hangs. Similarly, rockchip_pcie_legacy_int_handler() uses rockchip->irq_domain, but we installed it before initializing irq_domain. Register IRQ handlers after their data structures are initialized and clocks are enabled. Found by enabling CONFIG_DEBUG_SHIRQ, which calls the IRQ handler when it is being unregistered. An error during the probe path might cause this unregistration and IRQ handler execution before the device or data structure init has finished. [bhelgaas: commit log] Link: https://lore.kernel.org/r/20210608080409.1729276-1-javierm@redhat.com Reported-by: Peter Robinson Tested-by: Peter Robinson Signed-off-by: Javier Martinez Canillas Signed-off-by: Lorenzo Pieralisi Signed-off-by: Bjorn Helgaas Acked-by: Shawn Lin Signed-off-by: Sasha Levin --- drivers/pci/controller/pcie-rockchip-host.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index f1d08a1b1591..78d04ac29cd5 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -592,10 +592,6 @@ static int rockchip_pcie_parse_host_dt(struct rockchip_pcie *rockchip) if (err) return err; - err = rockchip_pcie_setup_irq(rockchip); - if (err) - return err; - rockchip->vpcie12v = devm_regulator_get_optional(dev, "vpcie12v"); if (IS_ERR(rockchip->vpcie12v)) { if (PTR_ERR(rockchip->vpcie12v) != -ENODEV) @@ -973,8 +969,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev) if (err) goto err_vpcie; - rockchip_pcie_enable_interrupts(rockchip); - err = rockchip_pcie_init_irq_domain(rockchip); if (err < 0) goto err_deinit_port; @@ -992,6 +986,12 @@ static int rockchip_pcie_probe(struct platform_device *pdev) bridge->sysdata = rockchip; bridge->ops = &rockchip_pcie_ops; + err = rockchip_pcie_setup_irq(rockchip); + if (err) + goto err_remove_irq_domain; + + rockchip_pcie_enable_interrupts(rockchip); + err = pci_host_probe(bridge); if (err < 0) goto err_remove_irq_domain; -- 2.30.2