Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp117552lqe; Thu, 4 Apr 2024 01:06:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjZgrh5gZmAdxFk/budJQ/HGdU5izC9btPN1aoolTq9Z4igjnw9Db+TTIEBaMJpvODIJsmqV0i7kiE9NmzhJ8KVvI58ry989TPVQAz2w== X-Google-Smtp-Source: AGHT+IFBA3QSgzrrCbH7kYOZV6nUckA1VLwTOVDsz/lk1SRGLIjJ3/+qyzbviVPTPWdgH4eEcjc9 X-Received: by 2002:a05:6a20:94cc:b0:1a3:aaa2:3fbd with SMTP id ht12-20020a056a2094cc00b001a3aaa23fbdmr1913876pzb.51.1712217972982; Thu, 04 Apr 2024 01:06:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712217972; cv=pass; d=google.com; s=arc-20160816; b=ufcBDcMYkHfgXSdbiMMuTc9AQKxx1Xp9E+4tcuWYW/uVqoPZxcyJI/gyU88SLjoyuw bIOXUrVUdN2w3CNwMdVlmib5E0+TtCFpTTjMgZbif3dN6hHt0f7dJZSC11DRAQQLd/tP MAanUoiEuutmO4Bl5ifuC/1mfPpuUrq811zK261vcPtqCFjSN3BPJwbBtrQ6Z12A7kPe C2hgq90KoLlS3uparsPFbzKj3YnlvUtL97sO0g1QMm+1caGkNw7hGybbJAJauDUSp3sm HlFPpjwclS+wRB/altrj+wdxPoXRZkowRHd5IG+9s9bRJN15W2Jq4nvWZc5Zw4OLFmQY VO3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ZeYFwnuD4+s5uq8uzv2CMZqpLRUptLwvTB2WWLBP4Ag=; fh=TRA8RzFMiQyvDdHx9ylQDQO2Wenf9a1qX8yWABPy2r8=; b=SCcLGr5kgbuLdlZw0dwE+CEo0AixXq5phw0g6upEXzjOAW788GPjQuWaGs7vElv0LE u1wOOkTZTSVka/jY0bNB5Z0Zv9YmqHrML221nGzLVYB+1cuHvo3/hxsgChTYAOEdyYkz AoOd3lc4byNMfm0Z4JkpgWZh9X4SMj+bCWBlWxc3crDXs4siEr3FKzihZf9d/QK+DQGi seFQIJyevvzWUYLL4Tl+N+2RlOLrAQuhgHqEHHGA6XVThsmDKolYJpYIzuzm/lPY0I+W Ep2obEtMwTkFifqaDGL3h59U1FgP3sNhXK6iaAIDY/IRaS+55ZDJSImmH8ttNI24l8Qu 4e8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=FOu5bJCt; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-131063-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f5-20020a170902684500b001e27045fb4esi4620754pln.329.2024.04.04.01.06.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 01:06:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131063-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=FOu5bJCt; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-131063-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id ED859B25EDE for ; Thu, 4 Apr 2024 07:58:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C063692FC; Thu, 4 Apr 2024 07:58:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="FOu5bJCt" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD7695D724 for ; Thu, 4 Apr 2024 07:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712217483; cv=none; b=qZ8lJPn5DEbBJw8XlaQr4SU5aFiqWHo+UFUlOjX566KqE5s03CFf8x1VryBQejtVMdo/RY+ATXbycpJYByi2uiF8CGWXac/vtOgJZ0eUitrks3PMebjPpwPBGFIiPGhkFr0eCs0qAQf5tJcPloS+fCmTe/yAr7QKffsir70v+O8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712217483; c=relaxed/simple; bh=KoiSh/u/4BD9iAcBgjvWczlcgOlHoosLFr6MB3Jm8Xs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZJY3Xx0Q+IbPs4opU9rovmm7n2zGnvKLgpST/povSj1XBoPNL0xKpftx2OjzHk9ZBGTJQ2EXlDD9Fm3fYPGlqcAjx7dQjWhhauB25zNQvMxZM/yEPF//yElVOz5DTyOV1hK3eWLwsZrJsyDgFFBKRLkfL8TQ4hD0eVRBNV7dxHo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=FOu5bJCt; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712217480; bh=KoiSh/u/4BD9iAcBgjvWczlcgOlHoosLFr6MB3Jm8Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FOu5bJCtAyMzxdyr8jDNAhgQn9IKDDnH1uRykOEPX0qZKiHPoXewXk1vwIpt4S0eT Ympln2QU6MvpjNaVYVOcQ/nxpubzcFM8tpC33KfydDSK9znFhR741BEflS3SmDfl5S uZGcPPN8Oiw7kqmWiHOKGcnxUTMP3M/XWvmqRFGcZAAimGst9OqB3r9evoLeiyPFLr dCkcs7u8HUMprfS3Lfe9qJgR+0tqg5yqdp+N3DlWzVRqkFMndK1ItMWp5bHMIOrNf3 F9seAaunCjMunY7GLDEm6ytNHZp/8ABpu0aHiAKrCZ33ynRTjoTo6GNWhBuiuUp0M6 xUponJyRAtm1A== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (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 madrid.collaboradmins.com (Postfix) with ESMTPSA id 15D003782129; Thu, 4 Apr 2024 07:57:59 +0000 (UTC) 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, ck.hu@mediatek.com, nancy.lin@mediatek.com, nathan.lu@mediatek.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 2/3] drm/mediatek: Perform iounmap on simple DDP component destruction Date: Thu, 4 Apr 2024 09:57:53 +0200 Message-ID: <20240404075754.83455-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404075754.83455-1-angelogioacchino.delregno@collabora.com> References: <20240404075754.83455-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a new mtk_ddp_comp_destroy() function and call it in the teardown path of mtk_drm_drv to make sure that we unmap the iospace of the simple DDP components. While at it, also fix iounmapping on mtk_ddp_comp_init() error path. Fixes: ff1395609e20 ("drm/mediatek: Move mtk_ddp_comp_init() from sub driver to DRM driver") Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: CK Hu --- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 38 ++++++++++++++++++++- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 1 + drivers/gpu/drm/mediatek/mtk_drm_drv.c | 4 ++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c index 82d7a6887f44..477fc1950a0e 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c @@ -627,8 +627,11 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp, priv->regs = of_iomap(node, 0); priv->clk = of_clk_get(node, 0); - if (IS_ERR(priv->clk)) + if (IS_ERR(priv->clk)) { + iounmap(priv->regs); + priv->regs = NULL; return PTR_ERR(priv->clk); + } #if IS_REACHABLE(CONFIG_MTK_CMDQ) ret = cmdq_dev_get_client_reg(comp->dev, &priv->cmdq_reg, 0); @@ -640,3 +643,36 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp, return 0; } + +void mtk_ddp_comp_destroy(struct mtk_ddp_comp *comp) +{ + struct mtk_ddp_comp_dev *priv; + + if (!comp || !comp->dev) + return; + + /* Complex components are destroyed with their own remove callback */ + if (mtk_ddp_matches[comp->id].type == MTK_DISP_AAL || + mtk_ddp_matches[comp->id].type == MTK_DISP_BLS || + mtk_ddp_matches[comp->id].type == MTK_DISP_CCORR || + mtk_ddp_matches[comp->id].type == MTK_DISP_COLOR || + mtk_ddp_matches[comp->id].type == MTK_DISP_GAMMA || + mtk_ddp_matches[comp->id].type == MTK_DISP_MERGE || + mtk_ddp_matches[comp->id].type == MTK_DISP_OVL || + mtk_ddp_matches[comp->id].type == MTK_DISP_OVL_2L || + mtk_ddp_matches[comp->id].type == MTK_DISP_PWM || + mtk_ddp_matches[comp->id].type == MTK_DISP_RDMA || + mtk_ddp_matches[comp->id].type == MTK_DPI || + mtk_ddp_matches[comp->id].type == MTK_DP_INTF || + mtk_ddp_matches[comp->id].type == MTK_DSI) + return; + + priv = dev_get_drvdata(comp->dev); + if (!priv) + return; + + if (priv->regs) { + iounmap(priv->regs); + priv->regs = NULL; + } +} diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index 93d79a1366e9..3d147217caa4 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -330,6 +330,7 @@ unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm, struct device *dev); int mtk_ddp_comp_init(struct device_node *comp_node, struct mtk_ddp_comp *comp, unsigned int comp_id); +void mtk_ddp_comp_destroy(struct mtk_ddp_comp *comp); enum mtk_ddp_comp_type mtk_ddp_comp_get_type(unsigned int comp_id); void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value, struct cmdq_client_reg *cmdq_reg, void __iomem *regs, diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 74832c213092..7e240d16d3e5 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -946,8 +946,10 @@ static void mtk_drm_remove(struct platform_device *pdev) component_master_del(&pdev->dev, &mtk_drm_ops); pm_runtime_disable(&pdev->dev); of_node_put(private->mutex_node); - for (i = 0; i < DDP_COMPONENT_DRM_ID_MAX; i++) + for (i = 0; i < DDP_COMPONENT_DRM_ID_MAX; i++) { + mtk_ddp_comp_destroy(&private->ddp_comp[i]); of_node_put(private->comp_node[i]); + } } static int mtk_drm_sys_prepare(struct device *dev) -- 2.44.0