Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1184318lqt; Tue, 19 Mar 2024 15:52:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV2jt0FbKit/EUmWWo3eY1cJop6iIm8CyXzOoIrCtJE5HPHvwNYn4Hay/HWrdBY29rrFMQQ4WJ61UWgXmigxATFUkK5K6P2Y3reOxp7fw== X-Google-Smtp-Source: AGHT+IFIELYjDtT6FFLShcVHdXNy6xSwJMx4N0kUCHqLbznlHJqzm+uWYHYhiBdG364eM3lhg3WT X-Received: by 2002:a05:620a:8107:b0:789:e951:41bc with SMTP id os7-20020a05620a810700b00789e95141bcmr4384510qkn.4.1710888776888; Tue, 19 Mar 2024 15:52:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710888776; cv=pass; d=google.com; s=arc-20160816; b=EOVX2eOAmpsSOvFvepRyC/PyDQEt0DYZA38gYqi7eMUDcmIZ36CdegmFbqE/yO/pJJ Jh3KFpcZS+iGSCwSV3A9zOJE84u03nsWoJ0PA0xzKvBF6jhwJDtjgJ8MIpmJA+kqMAGX mG9PQxVLkzjqPb2OG2aWhYTOp6XoRl6ITpO6JLit+WRrjZ3qKypuCbCHiM+HgsCsPBrG 3M9L1qFJLhaQiVGDWqy7ewCG3ykOZQ0mULWU1kIcjqQr15ETLASLDf7/H0X/jh0KSzbC bllOTV8q5f5GtTERSlW6jPclmAY/8FmzPZhXmp9ZznkXibl5Lyq7lJUFh6Fvka/g9Mkf jmww== 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=IyA1pp/Og9a0uR7KxvRUeBHWPGqjk6cC2yqaXPFBa2g=; fh=QE5KDpQBDaw6TTdTDvqDjBOLgOLBm0Tl23jUjnXnKrk=; b=HSkSczC8J578p0mxMuSG27/x07YDc+hNzoM2twMcUJxV7Wm2yiDMhhsJQM6t9FUTRc EsGdPXaFCjtt633qihewtc42UjsWdmk4xVp2QPRzlDSJ4Q0Zm4ZvayGBObyIhZzRR3XA ecfJ4zur9KIU6prwcmta64bGNe4zMKrlIkD6ZyvgsO3Ha2/ViG9aAzIFi4gKqFO3lPsR uwdx2e6IKRIYFF3cbuMLUHS6isuoRKL5cYw4z6OHqL2wFTnp8169Mc+dtE4dLQs41Owk YYbmIyyJMZ22XshmAG2BtiDzYrUgBih2UTXuYxBTSd2wgO/O1dQwtwMPFMowimVML+t7 L8GQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=OMzjesS1; 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-108205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108205-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s17-20020a05620a081100b00789e729e18fsi9771746qks.343.2024.03.19.15.52.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 15:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=OMzjesS1; 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-108205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108205-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9DC931C21FC4 for ; Tue, 19 Mar 2024 22:52:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E2135A11C; Tue, 19 Mar 2024 22:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="OMzjesS1" Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (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 8A1F260250 for ; Tue, 19 Mar 2024 22:51:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710888710; cv=none; b=D0ZodjP41Fbj/Edexj3cXZD36fajhv7BchG8N26LDNvhmKz4IhlbmMdp7tm4COIsRVW1/Fmq84TcJLqynlzPEi+8AKSWiJFEcZ4UiuhzW6NnQDWSJIObn8d/2AKejluTYu7Sa6T424bAwT+zAyndr2MEwBA5X9XehEm263icfEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710888710; c=relaxed/simple; bh=s64Pf1BLDbOpOL2f4d7AToLS9pNdSyVcToFfD9BN+Qs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PoaVCsUW6pyw3FI4G17O6EogSGTLkuA56gGW0lGmV3j/rB3c7QPMaI1ZjY46SJMTuSe1A4uuwX9KlEWWktPLw8NWaDNDzeMzyXdo0UPielUCuCQjED6Xhf8P+F3iNEwstje+nquN8IO2d+mWpBhAs+TrzC5xceq/0shnZT50t9E= 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=OMzjesS1; arc=none smtp.client-ip=91.218.175.184 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=1710888706; 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=IyA1pp/Og9a0uR7KxvRUeBHWPGqjk6cC2yqaXPFBa2g=; b=OMzjesS1g9SgReAooXmXRO+rEeJVZZbO6Fw4R7WVyiz+Aa9xbBeLmtWXnAt5W4EGrFHIuc ZcKCCp5Hx1RcmuU3fc+KSCRCbJ+N7vMEMGQiXQsM7vz/qA90NBCUbHwtOSe5SWcia4bzV1 DhIc4OJlMAb1g4JIKmfOCdsLzRRijLI= From: Sean Anderson To: Laurent Pinchart , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org Cc: Michal Simek , David Airlie , linux-kernel@vger.kernel.org, Daniel Vetter , linux-arm-kernel@lists.infradead.org, Sean Anderson Subject: [PATCH v2 5/8] drm: zynqmp_dp: Don't retrain the link in our IRQ Date: Tue, 19 Mar 2024 18:51:18 -0400 Message-Id: <20240319225122.3048400-6-sean.anderson@linux.dev> In-Reply-To: <20240319225122.3048400-1-sean.anderson@linux.dev> References: <20240319225122.3048400-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. This is inappropriate for an IRQ handler. Just schedule this work for later completion. This is racy, but will be fixed in the next commit. Signed-off-by: Sean Anderson --- Actually, on second look this IRQ is threaded. So why do we have a workqueue for HPD events? Maybe we should make it unthreaded? Changes in v2: - Document hpd_irq_work - Split this off from the lcoking changes drivers/gpu/drm/xlnx/zynqmp_dp.c | 43 ++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c index f1834c8e3c02..f3fcdbf662fa 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c @@ -287,6 +287,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 @@ -298,6 +299,7 @@ struct zynqmp_dp { struct drm_dp_aux aux; struct drm_bridge bridge; struct delayed_work hpd_work; + struct delayed_work hpd_irq_work; struct drm_bridge *next_bridge; struct device *dev; @@ -1611,6 +1613,27 @@ 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.work); + u8 status[DP_LINK_STATUS_SIZE + 2]; + int err; + + 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); + } + } +} + static irqreturn_t zynqmp_dp_irq_handler(int irq, void *data) { struct zynqmp_dp *dp = (struct zynqmp_dp *)data; @@ -1635,23 +1658,9 @@ static irqreturn_t zynqmp_dp_irq_handler(int irq, void *data) if (status & ZYNQMP_DP_INT_HPD_EVENT) schedule_delayed_work(&dp->hpd_work, 0); - if (status & ZYNQMP_DP_INT_HPD_IRQ) { - int ret; - u8 status[DP_LINK_STATUS_SIZE + 2]; + if (status & ZYNQMP_DP_INT_HPD_IRQ) + schedule_delayed_work(&dp->hpd_irq_work, 0); - 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; } @@ -1676,6 +1685,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub) dp->status = connector_status_disconnected; INIT_DELAYED_WORK(&dp->hpd_work, zynqmp_dp_hpd_work_func); + INIT_DELAYED_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"); @@ -1775,6 +1785,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_delayed_work_sync(&dp->hpd_irq_work); cancel_delayed_work_sync(&dp->hpd_work); zynqmp_dp_write(dp, ZYNQMP_DP_TRANSMITTER_ENABLE, 0); -- 2.35.1.1320.gc452695387.dirty