Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2480641lqt; Mon, 22 Apr 2024 11:54:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1RIAeNaNadugVxhovg3H13YVKyWwQUR/MX7O7r6oZLVVc1XLZDjmkQqUUEmwt7cm8shFpaWiWwyQZctKe0/uheJGLyWQyImBl6X/2rA== X-Google-Smtp-Source: AGHT+IE7JJmuN9Kx+4FQ2RUfFs+8C2ORPIfMIS63F3ZQSxAeE5M73F6uF/4eHcBwIf+ADG66IZAg X-Received: by 2002:a17:903:1c9:b0:1e5:5bf8:5b5 with SMTP id e9-20020a17090301c900b001e55bf805b5mr12189233plh.51.1713812062349; Mon, 22 Apr 2024 11:54:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713812062; cv=pass; d=google.com; s=arc-20160816; b=xJdo9cDRsE9Lj+9i/6vGcYGigV5LFocm3wGHy2kunaVSYj08HF6x6i3oRnnkG1Rxpg KyiVLt5TKlHEh3E3iUGY3q9+JWFKaatfDSjO6TFKrLnJbnv9OQZiifEXbrUwfo5p4q2v 51zRAymJNI1H3hHlIqGjiqrQkUl9EzwaRnj6KppSYtHBHO17LZh/nk7zeW6E+RnMWCJC +4cJau9gN/I/jRDBmConu32rnFiRAswXi3eQ4tTenpDQxyPS3pr4DsOqBlVd76qZ5/t0 trA2rNp3ZqtiFB0D2Y//9opoyQgQ5bwWigRmvBQMG2lPWrGjuuT8ma4uuxtltP3P5S3c EcCA== 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=0rQgFLz1f7QToI4bDFxSZ7hIM9V4MkM4i44AYm4dUas=; fh=NFKGmghyy/TSvnzoXgX9rMjnndbtusN4FE9pRXVIZkY=; b=ieAE5cOLZEnpvkFR5BsSa3pCI2G+hcVAnPEDvYe8JC2Elg4zgN4vl+LRPzWuwmN/Hd FRnvr0Uj8O2mL/NR076eE/5uYVvKBayolsJr+HF9GoCmPBOh6rCs0+0InvBZ2ojc5Lw7 tZV2Ci7si285f0XEj4JfFywq1EuJDqV8+ssbVEVfNcwqTI9xj5qabeuqvyufMWTbn30k Ecm+ypXafhJU2sPbOH1RBj8+B4hULEWdvO6qWy40TdPKvwE8QxlDzSzl23Ouxka1fzZH z6jxDwz6rkUA3DTrBu14iurpIfOFJdUR4KhOnMlJtXsNGuR69RwsHTK41zrPZnRJAdk8 pjFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=GJE384Ed; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-153864-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153864-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e11-20020a170902784b00b001e84ad9651asi7991113pln.506.2024.04.22.11.54.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 11:54:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153864-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=@linux.dev header.s=key1 header.b=GJE384Ed; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-153864-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153864-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 521E0B24CD0 for ; Mon, 22 Apr 2024 18:48:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC8BA156866; Mon, 22 Apr 2024 18:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="GJE384Ed" Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 B315D15535B for ; Mon, 22 Apr 2024 18:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713811578; cv=none; b=IzqnDgq4uqUtl8tiuJr+y1bphryITm/inFyuTjiLvKm+KY7avi1UrdKwdRgTzBS9pqE7UhkmYOkHoBMYlqAAzjArEgNJlFaKCeWVlQrA/qNhcMBCbQhbTQSRhzLliHOYNG2RcEK4fxFMsqZK9pFR7n2q/Oy81/ntjqQ5T38RW98= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713811578; c=relaxed/simple; bh=IWIGouBhWDcJkFz4spskFL8l5FxiqBeXF1gsmW44ZK8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AZZp3SYbD9QLrc6c1INJ8W/IauI3R3g6yGNi+8JT2fuhd4XGRfJskKTaTljU8o1aaaOnkQ/o5pF5hFL23gH3f5xv7q0X6k5AJdoxvl/6tNFuYGCT3fhOxXdU2lp7WVUI8xZOQfv+hnIAjQO11A8lh+v9HPJgthNP3f42ow5FXec= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=GJE384Ed; arc=none smtp.client-ip=91.218.175.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713811575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0rQgFLz1f7QToI4bDFxSZ7hIM9V4MkM4i44AYm4dUas=; b=GJE384Edy2R8oJV6eAsnGonfR6MkvnE97yRZqY8VKKr6XZ54Ajj5+ABBfWY8yEkrdRInM9 YQklmrqmUX9qgiU9YK6YYO1U7bOD7qA5yKi06Q5Ar4745I17G37U7iPJpBofcUI0zKuGcO 13Bwy0d3Ir/IAC4XLUWV6nf/+5nb8L8= From: Sean Anderson To: Laurent Pinchart , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org Cc: David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Michal Simek , Sean Anderson Subject: [PATCH v3 08/13] drm: zynqmp_dp: Don't retrain the link in our IRQ Date: Mon, 22 Apr 2024 14:45:48 -0400 Message-Id: <20240422184553.3573009-9-sean.anderson@linux.dev> In-Reply-To: <20240422184553.3573009-1-sean.anderson@linux.dev> References: <20240422184553.3573009-1-sean.anderson@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Retraining the link can take a while, and might involve waiting for DPCD reads/writes to complete. In preparation for unthreading the IRQ handler, move this into its own work function. Signed-off-by: Sean Anderson --- (no changes since v2) Changes in v2: - Document hpd_irq_work - Split this off from the locking changes drivers/gpu/drm/xlnx/zynqmp_dp.c | 45 ++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c index 5eb926f050de..8ad8db01f136 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c @@ -288,6 +288,7 @@ struct zynqmp_dp_config { * @phy: PHY handles for DP lanes * @num_lanes: number of enabled phy lanes * @hpd_work: hot plug detection worker + * @hpd_irq_work: hot plug detection IRQ worker * @status: connection status * @enabled: flag to indicate if the device is enabled * @dpcd: DP configuration data from currently connected sink device @@ -303,6 +304,7 @@ struct zynqmp_dp { struct drm_dp_aux aux; struct drm_bridge bridge; struct work_struct hpd_work; + struct work_struct hpd_irq_work; struct mutex lock; struct drm_bridge *next_bridge; @@ -1626,6 +1628,29 @@ static void zynqmp_dp_hpd_work_func(struct work_struct *work) drm_bridge_hpd_notify(&dp->bridge, status); } +static void zynqmp_dp_hpd_irq_work_func(struct work_struct *work) +{ + struct zynqmp_dp *dp = container_of(work, struct zynqmp_dp, + hpd_irq_work); + u8 status[DP_LINK_STATUS_SIZE + 2]; + int err; + + mutex_lock(&dp->lock); + err = drm_dp_dpcd_read(&dp->aux, DP_SINK_COUNT, status, + DP_LINK_STATUS_SIZE + 2); + if (err < 0) { + dev_dbg_ratelimited(dp->dev, + "could not read sink status: %d\n", err); + } else { + if (status[4] & DP_LINK_STATUS_UPDATED || + !drm_dp_clock_recovery_ok(&status[2], dp->mode.lane_cnt) || + !drm_dp_channel_eq_ok(&status[2], dp->mode.lane_cnt)) { + zynqmp_dp_train_loop(dp); + } + } + mutex_unlock(&dp->lock); +} + static irqreturn_t zynqmp_dp_irq_handler(int irq, void *data) { struct zynqmp_dp *dp = (struct zynqmp_dp *)data; @@ -1650,23 +1675,9 @@ static irqreturn_t zynqmp_dp_irq_handler(int irq, void *data) if (status & ZYNQMP_DP_INT_HPD_EVENT) schedule_work(&dp->hpd_work); - if (status & ZYNQMP_DP_INT_HPD_IRQ) { - int ret; - u8 status[DP_LINK_STATUS_SIZE + 2]; + if (status & ZYNQMP_DP_INT_HPD_IRQ) + schedule_work(&dp->hpd_irq_work); - ret = drm_dp_dpcd_read(&dp->aux, DP_SINK_COUNT, status, - DP_LINK_STATUS_SIZE + 2); - if (ret < 0) - goto handled; - - if (status[4] & DP_LINK_STATUS_UPDATED || - !drm_dp_clock_recovery_ok(&status[2], dp->mode.lane_cnt) || - !drm_dp_channel_eq_ok(&status[2], dp->mode.lane_cnt)) { - zynqmp_dp_train_loop(dp); - } - } - -handled: return IRQ_HANDLED; } @@ -1692,6 +1703,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub) mutex_init(&dp->lock); INIT_WORK(&dp->hpd_work, zynqmp_dp_hpd_work_func); + INIT_WORK(&dp->hpd_irq_work, zynqmp_dp_hpd_irq_work_func); /* Acquire all resources (IOMEM, IRQ and PHYs). */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dp"); @@ -1791,6 +1803,7 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub) zynqmp_dp_write(dp, ZYNQMP_DP_INT_DS, ZYNQMP_DP_INT_ALL); disable_irq(dp->irq); + cancel_work_sync(&dp->hpd_irq_work); cancel_work_sync(&dp->hpd_work); zynqmp_dp_write(dp, ZYNQMP_DP_TRANSMITTER_ENABLE, 0); -- 2.35.1.1320.gc452695387.dirty