Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1701549pxb; Thu, 16 Sep 2021 13:22:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKh3x5Ao4Fqx9GGUA7N9l4kGGo7zMTUQqMQjGzYPgBZebWTes7k++uvOXoW6ajHF/j6zjo X-Received: by 2002:aa7:c806:: with SMTP id a6mr8453781edt.354.1631823743108; Thu, 16 Sep 2021 13:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631823743; cv=none; d=google.com; s=arc-20160816; b=s4th+/AR0cAIAukEFMGGHLWR8KU3zb6Zb6HEpgPWOQOjqkcVPXQa1dM53kRg69HdKK qCyk1O4+7wFwm90b+PwFfd//FSyMhCZ6NnirLDg4bX5jMbIhzl13fToCLJFauFfiYX/9 IGm+cN7NPH1915AiZ3d6dR7JU1n+MKHKoWqIjrt9n7Xfs8D2EuzHyHzV8pD/UGOzyCC4 kKPR3z6ZJkcxLdzCoEdx2DmX0mWp6XttNlEPKGspQFIOpPofXtJWnDobjbcSmqe28jA/ IWBOiXrADU8KV5MiC3yovKmU9KJC4eN0gZa8D2Yk7/jJ5xlQTSG+6zHsWEEuXC9hSeUk P8bw== 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=9ACX2y51A7GWVJkcYrkFoscPsKsf5M3jqG2NHy9GfAo=; b=yRByL2OhEiaTjtFHbOA8ehtJalkOisa9g71P/LEWbU/0CvXKPl+8vI2Nq4An5h7Ufq W/vwIgDdA5stDEIA2ogEQyFdhnuCRqh5vKtyZ9W9qseV5VHQEN/3qkyCBTpQfJVam78H RQ8oJ1tmWnUmRCtto+KXEPoYnI5wE3cQzXSHTqMGLbTROy0dYFUZix9Fzu9Zqn3PaLs7 ZYWaMWcTlckj+RKmu3lX40/tzt8o+93SKdEDDeZievxmr3aRKx4VPBP31h7cWStSKoJz wauN8WZRRa9sBYbiCWg3qktSZgYhLss8kmt+AzHpWowszxxHFG/pn1xoTnq3oDaa00Bf KCEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l25gYGwx; 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 b1si4556191edv.347.2021.09.16.13.21.59; Thu, 16 Sep 2021 13:22:23 -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=l25gYGwx; 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 S241749AbhIPQZw (ORCPT + 99 others); Thu, 16 Sep 2021 12:25:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:54972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240768AbhIPQRU (ORCPT ); Thu, 16 Sep 2021 12:17:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7364A61353; Thu, 16 Sep 2021 16:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808732; bh=o2FipU2T4oBNLWJncdRN5X/QBl6xzwY3qSkx4eTQtaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l25gYGwxhb1Mo0+V70RFyfnJZXgEqSoXYb+VbdNaLXXqZyCkJe8vQlR3FGrpH0clr uBRSIVuCmP03d6nKV2py5rORLPRbZFQCpaz1LYcUcBLtQSUnIqMxtHqv8AprRSca3A aRMNspN3LZi89XbSf0qX9aLMDBDyFS4cidajfK9k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Quanyang Wang , Laurent Pinchart , Sasha Levin Subject: [PATCH 5.10 201/306] drm: xlnx: zynqmp: release reset to DP controller before accessing DP registers Date: Thu, 16 Sep 2021 17:59:06 +0200 Message-Id: <20210916155800.907036263@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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: Quanyang Wang [ Upstream commit a338619bd76011035d462f0f9e8b2f24d7fe5a1e ] When insmod zynqmp-dpsub.ko after rmmod it, system will hang with the error log as below: root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko [ 88.391289] [drm] Initialized zynqmp-dpsub 1.0.0 20130509 for fd4a0000.display on minor 0 [ 88.529906] Console: switching to colour frame buffer device 128x48 [ 88.549402] zynqmp-dpsub fd4a0000.display: [drm] fb0: zynqmp-dpsubdrm frame buffer device [ 88.571624] zynqmp-dpsub fd4a0000.display: ZynqMP DisplayPort Subsystem driver probed root@xilinx-zynqmp:~# rmmod zynqmp_dpsub [ 94.023404] Console: switching to colour dummy device 80x25 root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko This is because that in zynqmp_dp_probe it tries to access some DP registers while the DP controller is still in the reset state. When running "rmmod zynqmp_dpsub", zynqmp_dp_reset(dp, true) in zynqmp_dp_phy_exit is called to force the DP controller into the reset state. Then insmod will call zynqmp_dp_probe to program the DP registers, but at this moment the DP controller hasn't been brought out of the reset state yet since the function zynqmp_dp_reset(dp, false) is called later and this will result the system hang. Releasing the reset to DP controller before any read/write operation to it will fix this issue. And for symmetry, move zynqmp_dp_reset() call from zynqmp_dp_phy_exit() to zynqmp_dp_remove(). Signed-off-by: Quanyang Wang Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart Signed-off-by: Sasha Levin --- drivers/gpu/drm/xlnx/zynqmp_dp.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c index 59d1fb017da0..13811332b349 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c @@ -402,10 +402,6 @@ static int zynqmp_dp_phy_init(struct zynqmp_dp *dp) } } - ret = zynqmp_dp_reset(dp, false); - if (ret < 0) - return ret; - zynqmp_dp_clr(dp, ZYNQMP_DP_PHY_RESET, ZYNQMP_DP_PHY_RESET_ALL_RESET); /* @@ -441,8 +437,6 @@ static void zynqmp_dp_phy_exit(struct zynqmp_dp *dp) ret); } - zynqmp_dp_reset(dp, true); - for (i = 0; i < dp->num_lanes; i++) { ret = phy_exit(dp->phy[i]); if (ret) @@ -1682,9 +1676,13 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm) return PTR_ERR(dp->reset); } + ret = zynqmp_dp_reset(dp, false); + if (ret < 0) + return ret; + ret = zynqmp_dp_phy_probe(dp); if (ret) - return ret; + goto err_reset; /* Initialize the hardware. */ zynqmp_dp_write(dp, ZYNQMP_DP_TX_PHY_POWER_DOWN, @@ -1696,7 +1694,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm) ret = zynqmp_dp_phy_init(dp); if (ret) - return ret; + goto err_reset; zynqmp_dp_write(dp, ZYNQMP_DP_TRANSMITTER_ENABLE, 1); @@ -1708,15 +1706,18 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm) zynqmp_dp_irq_handler, IRQF_ONESHOT, dev_name(dp->dev), dp); if (ret < 0) - goto error; + goto err_phy_exit; dev_dbg(dp->dev, "ZynqMP DisplayPort Tx probed with %u lanes\n", dp->num_lanes); return 0; -error: +err_phy_exit: zynqmp_dp_phy_exit(dp); +err_reset: + zynqmp_dp_reset(dp, true); + return ret; } @@ -1734,4 +1735,5 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub) zynqmp_dp_write(dp, ZYNQMP_DP_INT_DS, 0xffffffff); zynqmp_dp_phy_exit(dp); + zynqmp_dp_reset(dp, true); } -- 2.30.2