From patchwork Mon Jul 17 14:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 121370 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1148913vqt; Mon, 17 Jul 2023 07:31:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlGmDj9E4RTkeVJBxseYr6ffgiKZlxEnx/T+J1M0BwTTYq91Laj2/e33W4XLamoAsqvBiHgb X-Received: by 2002:a17:903:41c8:b0:1b9:f7f4:5687 with SMTP id u8-20020a17090341c800b001b9f7f45687mr13498414ple.24.1689604307716; Mon, 17 Jul 2023 07:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689604307; cv=none; d=google.com; s=arc-20160816; b=FvxedlbacWCmifDUHE6VFGL4BoWipMAhpq6VKRu8GgmlnwlY5E9793YeBcrX6j3Hs/ Cc7CNsrCqfSd0khRC2NKbxt01Qu3U0wWV6Mp/qYvt+ra8lXOD2Iz91sp9Q8ogXrN/mim 9V5nQwNEbn5iU0xjZqxNc6j9CL1h/bvXOtzR5hn7l+U705klB3i5BJVh4Fhhy2ry1nC4 dwGr/a2Ysi7Lxmw9QMa8p4fRticjEIyLRnftf0EP1jWdth+5cuS2c1YaXnz63VDShj5L BVMwwUrIJMpPv6A0gPKbT6V8r8ev0uJfrkFqdOjT/nKoODcqIa/H7Ye4N2mAxglwUT4Q JXXw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IJ2uQ3Bi8y+SMN7gtp4Ka80179TMG9oy7jA51PzMtE0=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=fTwqtUaMS412IcmGBE/sqBD8VNAiTX+1xcaF1fBhQbDkhq8BhKrx6WFm2M0VsDQL25 KEd/3TcvTTLraMuwVYy99Zba3eZUoOc3/dB7GePS7F8kyznWwmMIPouIsRbTvz3VLH20 CVKFN/U4AzI8bwIQXk8LvtfoId4sRt2c8vSFRphLWkj0W2Of5o58cZ1EKTxARIo4Iqox q8f/S8a+JUM1kInr5qLKOgyo54IbO+eaLwpaCbwrne6Av0We9ezeRouExk6w8NTgpuZe v9LN+zlHcbK5azKlIfigFRQ4pCCx6UpW9cGIfc0uhG63OsHYyxeOqeGZ2tljKVyK3ydD U6bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EbTkkR0t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020a17090264d000b001b811261289si11438325pli.482.2023.07.17.07.31.34; Mon, 17 Jul 2023 07:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EbTkkR0t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232119AbjGQOPH (ORCPT + 99 others); Mon, 17 Jul 2023 10:15:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232157AbjGQOOy (ORCPT ); Mon, 17 Jul 2023 10:14:54 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16CB110E4 for ; Mon, 17 Jul 2023 07:14:50 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id EDBED660706B; Mon, 17 Jul 2023 15:14:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1689603288; bh=vi70p/9FDUxG9+dFVjjeS3h5x0OhHX3G4+djzfe2T7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EbTkkR0teiWcw05LFQieNjl2W+VC/k26E+DX+Uuw516A3SmmB8jrr1KMI9BSkRmJu BVEcecpOr1DrWMN0kAuwb4U1QwWZfwWAP8iyW43mjFJNe36cmWPj+hZZ8mMGb12sQt Z0aXTsg7mpwvo25MEwhACay3IXEKEY4pMti1nm9qoM/Z4pGs2CPMOmkXjvgxI3mxq+ XEBoO5LqDH3xShkuKrtXQc99Mzjj8JP6K9YFLBWDTc7pAF0QKuqYFEbvDA2GAkXDaU hBp/keqJV8TBZAfLI0ZMzETOjKUlk8jrEjKqFQpLr5Wy/SJqpWO+CvzSo6SBJzbPg7 wq1K4WxwsbkNg== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v6 06/11] drm/mediatek: dp: Enable event interrupt only when bridge attached Date: Mon, 17 Jul 2023 16:14:33 +0200 Message-Id: <20230717141438.274419-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230717141438.274419-1-angelogioacchino.delregno@collabora.com> References: <20230717141438.274419-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771678526727057344 X-GMAIL-MSGID: 1771678526727057344 It is useless and error-prone to enable the DisplayPort event interrupt before finishing to probe and install the driver, as the DP training cannot happen before the entire pipeline is correctly set up, as the interrupt handler also requires the full hardware to be initialized by mtk_dp_bridge_attach(). Anyway, depending in which state the controller is left from the bootloader, this may cause an interrupt storm and consequently hang the kernel during boot, so, avoid enabling the interrupt until we reach a clean state by adding the IRQ_NOAUTOEN flag before requesting it at probe time and manage the enablement of the ISR in the .attach() and .detach() handlers for the DP bridge. Signed-off-by: AngeloGioacchino Del Regno Tested-by: Chen-Yu Tsai Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_dp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index e8d3bf310608..83e55f8dc84a 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -100,6 +100,7 @@ struct mtk_dp_efuse_fmt { struct mtk_dp { bool enabled; bool need_debounce; + int irq; u8 max_lanes; u8 max_linkrate; u8 rx_cap[DP_RECEIVER_CAP_SIZE]; @@ -2141,6 +2142,8 @@ static int mtk_dp_bridge_attach(struct drm_bridge *bridge, mtk_dp->drm_dev = bridge->dev; + irq_clear_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); + enable_irq(mtk_dp->irq); mtk_dp_hwirq_enable(mtk_dp, true); return 0; @@ -2157,6 +2160,7 @@ static void mtk_dp_bridge_detach(struct drm_bridge *bridge) struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge); mtk_dp_hwirq_enable(mtk_dp, false); + disable_irq(mtk_dp->irq); mtk_dp->drm_dev = NULL; mtk_dp_poweroff(mtk_dp); drm_dp_aux_unregister(&mtk_dp->aux); @@ -2475,7 +2479,7 @@ static int mtk_dp_probe(struct platform_device *pdev) { struct mtk_dp *mtk_dp; struct device *dev = &pdev->dev; - int ret, irq_num; + int ret; mtk_dp = devm_kzalloc(dev, sizeof(*mtk_dp), GFP_KERNEL); if (!mtk_dp) @@ -2484,9 +2488,9 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->dev = dev; mtk_dp->data = (struct mtk_dp_data *)of_device_get_match_data(dev); - irq_num = platform_get_irq(pdev, 0); - if (irq_num < 0) - return dev_err_probe(dev, irq_num, + mtk_dp->irq = platform_get_irq(pdev, 0); + if (mtk_dp->irq < 0) + return dev_err_probe(dev, mtk_dp->irq, "failed to request dp irq resource\n"); mtk_dp->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); @@ -2507,7 +2511,8 @@ static int mtk_dp_probe(struct platform_device *pdev) spin_lock_init(&mtk_dp->irq_thread_lock); - ret = devm_request_threaded_irq(dev, irq_num, mtk_dp_hpd_event, + irq_set_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); + ret = devm_request_threaded_irq(dev, mtk_dp->irq, mtk_dp_hpd_event, mtk_dp_hpd_event_thread, IRQ_TYPE_LEVEL_HIGH, dev_name(dev), mtk_dp);