Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3855532pxv; Mon, 19 Jul 2021 10:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyudZ4/ZVcLX+mNQzdM0cscbaBmX+uvEfLhMKW9LqkB8v+oPvkTpwEA9y7e7z/XaOQXMgv2 X-Received: by 2002:a17:906:b7c3:: with SMTP id fy3mr18711781ejb.97.1626715151510; Mon, 19 Jul 2021 10:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626715151; cv=none; d=google.com; s=arc-20160816; b=nnPtyChlBQI+AG7hxsi+nVOAso8Vanlnfs6NvhZxQ8Ok3ydLGC25tcMRfv8YfdmUsL OmWFxpY8eHRcCdAMjo9to8v6NPSdFQqXNlfB6iNIUWbk9ukJfCPZlMfXCf0ndjS9Sbsn eliAUco9Lo7cZpmL4vZx5Swd3GTJRiIOQICEDIJKS5/CigPyi1p9XheqWKU76R1XC9oH EkkKTevOVwgzpmen0cFTw46a4T+9X+R4MczA7paRs0GvAd+WHvs/O7D6YXOZaEo4FmK6 bnaoi5A599nqNK13XZdiEMbd0lJ8tu9Fus3qZByzVmUmKMJCitugadajHxs2JWMSNzAZ +EZg== 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=FrgFer6zdwyZejli3V7P3o5IW2bB8pt871FxpLNDYlw=; b=iudmht2X5Lh1bpZTN639EEWVY/VqK8POc5/fc5v9pefzGUMyrPbrSs3X0L3Er8lQqU 2+zLdhYT3BbEVlKM3/RJ2gdtjmnshFapNOZIeXKxBo94qPg7buadptS5SJwA9+85+SVu dkeBkjQMgt+U7+5s9wM9yKdtk33BnIi/cWsfNriA6RDEgq7idh+Ss3upj5Ry9/wW2Z5J 6GtiLrml+j1daunepK/NeqXoV4ayB2Rvtxs5QUABviI5gtBi9GYoNi/d8KMxwV5fJ25X oPgHrF8UpujowdYUGeCn744bdSLexP4aRzKTvr1CGeELzBVUjHPzJl3nhaMq6+DMrmos mgBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ok2CQ70h; 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 s10si19066781edd.421.2021.07.19.10.18.47; Mon, 19 Jul 2021 10:19:11 -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=ok2CQ70h; 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 S1354860AbhGSQf3 (ORCPT + 99 others); Mon, 19 Jul 2021 12:35:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347851AbhGSPWG (ORCPT ); Mon, 19 Jul 2021 11:22:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DDB266008E; Mon, 19 Jul 2021 15:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710366; bh=N5eJoTF0ViH2kJuzZiUhRZNc/Voul3eL5qnXxBEUhno=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ok2CQ70hD7H9Yk4hNfFicS+n4Co0WcExBebvIBxe2YQ2WWdEVITI86hCTHSN2C4iA 0HHHY0R0q/hUAemD1KC7ijmYE7A1E1tGps6b6Zz0/H3CgEJCJjmCSbwv7NoB2P2/Vp szXCWh4+jMpCH/APrCIj/pNXNm0QBqi0BthT+L1g= 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.10 142/243] PCI: rockchip: Register IRQ handlers after device and data are ready Date: Mon, 19 Jul 2021 16:52:51 +0200 Message-Id: <20210719144945.500147280@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@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 9705059523a6..0d6df73bb918 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -593,10 +593,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) @@ -974,8 +970,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; @@ -993,6 +987,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