From patchwork Thu Mar 30 14:20: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: 77201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1168546vqo; Thu, 30 Mar 2023 07:28:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ajg5T3DJ1FdodOnz4CoLoa3a8mwqLnP9OFY78ZDNEcMDG4QXoK+UrH73Ai2m4JkDpCho6e X-Received: by 2002:aa7:95a4:0:b0:628:cff:1440 with SMTP id a4-20020aa795a4000000b006280cff1440mr23493397pfk.28.1680186509167; Thu, 30 Mar 2023 07:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680186509; cv=none; d=google.com; s=arc-20160816; b=lVx5/qn5+jyXrkuwi4/mrJBjuKKruK2sbKlDZ0PEN60BXKVOMcIIvbWuRoJThRN5IY Ey79k1Bk7xr4/zk1kI/pOIpRKazL6L73uY6yC95BeGfCDrJEYIVFYNdok4sgITD/M/k6 lIsi5c5om72R/Y9U/0UOfEldyFIcVWPQ8haboHDg0kRQbD9rnWgvw2w9SqoIntn/D7o5 Ga+vbd7grzSSyUKPYIro9LgspplzM+pG3ddgkcqWaze+jAbY+3RplrgX6vioVuLkyXyw zFTvkDBkR/71UPprXnVPR16MxUI/0+dtBeOppGnbyu8saBF7i3F5yDGlTl0isdy896x+ wfOw== 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=5aR76aUK66V+oOGD/BsUrwTZt7JhshN2uJKaf7z8324=; b=QoS0mpKu/2p8ZlUObs7+ssvThHIEhQ1J5huFkOrtNj4XJ2b8DqxmlNL1knp0HMNT1l /LOQhoFZ/lHsfExLpezrZuYvh2Wx0YxbGUeWplvbC5ADisxBZVsKVE2CNlqRJ0GKfKsd MEOleVf1mpqGi5w3TigkSSVfaRxG9fhmaZSbooi8941UI+ovyNK7Kx2a4QK/36dsbfDy sG+tGOY6xD0TeXimgyYKCR3dBiwPgTTF5xPAp5EvGyHBG3Ry6o+oLjInpM73wVt5tDoq G5uL+T7p5xqWnD2QWBhw2fU6vgSvVfjArhZ4cRr78I3iq2Q2cjEhitqKRAh2DLgfsPfm igFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dFFKk7tk; 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 c8-20020a056a00248800b005a7def83ee0si35949625pfv.210.2023.03.30.07.28.15; Thu, 30 Mar 2023 07:28:29 -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=dFFKk7tk; 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 S232405AbjC3OVC (ORCPT + 99 others); Thu, 30 Mar 2023 10:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232363AbjC3OUr (ORCPT ); Thu, 30 Mar 2023 10:20:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65F872686 for ; Thu, 30 Mar 2023 07:20:46 -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 8C811660318D; Thu, 30 Mar 2023 15:20:44 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186045; bh=piJKx8AJRTNo3xZLCBhwQ0b5ZyuIg8W2w0zGxP4Udgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dFFKk7tkMdrxgV29TKXItcjQ8VK6+yTcAue+SKpS+dJlxyYCh033az1Fbx04nLkhx aPIuM9EbxrSdmPUVssrVecUq99vE9/S+MyAe9v5/Z/dLyyA6Efpyf7WOGsuBGtij4x tw+ehm7xwuXINyeL0jdJDY2ybUhQwtct+TWywgZPsgx3w4xjv7tShHr1MgRBT3bM6v n7NUnuYhFeswARfyaJDECrwXzMjGP+JG2HJD+u8nszbq9F+VhG70DohMamZWWZrEv+ +DvXJtl45u/WRfNXeoEqLlCCcvjjLMKKqac1tTf+Z+T8rq97l/tn2jgUAtaNTBe3YV hE+H66Ni5DtMQ== 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 Subject: [PATCH v2 6/8] drm/mediatek: dp: Enable event interrupt only when bridge attached Date: Thu, 30 Mar 2023 16:20:33 +0200 Message-Id: <20230330142035.191399-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761803248706411856?= X-GMAIL-MSGID: =?utf-8?q?1761803248706411856?= In preparation for implementing support for aux-bus in this driver, add a IRQ_NOAUTOEN flag to the event interrupt that we request at probe time and manage the enablement of the ISR at bridge_attach and detach time. When aux-bus will be implemented, enabling the interrupt before attaching the bridge will create an event storm and hang the kernel during boot. In any case, the interrupt handler anyway requires resources that are initialized by mtk_dp_bridge_attach(), so it cannot do anything meaningful without... and even crash, but that's not happening in the current code because the HW remains unpowered until resources are made available. Signed-off-by: AngeloGioacchino Del Regno --- 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 19b145cf2e05..6aaf162a6bfe 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]; @@ -2148,6 +2149,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; @@ -2164,6 +2167,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); @@ -2482,7 +2486,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) @@ -2491,9 +2495,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); @@ -2514,7 +2518,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);