Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3104749lqt; Tue, 23 Apr 2024 10:21:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsNzLLF1vbfU3y7UvuKoT1rh+3SonjQ9IKmISR0Ybsh1P/oIAAElSmz2U3ccCypr7ULOyhmZlLhGNDQjP3wP+gyMwZMKuYz3/2V43qVA== X-Google-Smtp-Source: AGHT+IEIqOrWlcNcn7cC98i9Qs54/KUvmlOZRDG7yLIrodOCYEGeMDjPuRlkKUnbWRH/Tscty2V1 X-Received: by 2002:a50:d745:0:b0:56d:e73d:6d74 with SMTP id i5-20020a50d745000000b0056de73d6d74mr9212edj.12.1713892879646; Tue, 23 Apr 2024 10:21:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713892879; cv=pass; d=google.com; s=arc-20160816; b=eGHbfnZplYiObdqeuDRjwtdx1XPY4GnEgJfZ9Dj5S6xR1rbqaSCprfqYuF6kecSOhA Fafh8E7Gf3BDAcqdqzQqsXN6KeCJcTugliViwjbAanD7FgIdjucyPmUTLayLSbZvPOak p5bZ+zp6H/Ppl/iSlGDtVKaEuTlH4nvUBibra1GYSI4TiHM1GUwhypgnpY9K5Ua+g+Ia bbaKMmJTa7CjdxwnlA8nbp3H+FhUvM7SMRQrnzxm1dz5s4uRD/9JSgyw0dsoVNZFiIA8 w5XoLb8oPEyDilcLQa6Tb9SZW3CzksewlVgf8zq2uuDiJ95dz1B0gUQeucHSpnszwUv7 J0Hw== 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=RmSFa+/zcwP0QaIdNDOJ1SuDsADV5qigCZtp1Yg0z+k=; fh=y/ZWbFXBmP32xuuB2aPYQ037wxAyEGcK3dXjHSf7t2w=; b=zI90/XVDScXBfLhsg9hNUc8t6s9q1M3Nk+uRzvNF6KLpD2YaPKsKipf6seVhVW+oGk y+m8KhpnRnu2XuEDiC6vrjQvgOdXJEyOM2BX0CDjQyAfUrJVb+ZjwbaVfjAL/ehbduEM MAjaQYO/hBsfcNEeR6/FHRPESsCR7aNceYtHBGc5SPPjuBXOBcTv5lqPzXpOIjMLlYnL fMIGxmVbVhA+1vaiS4ITLyeiopxaZsXaz64mbdk1LwOyFDHxj5qryuazi9jiepzSx2cF Vdy2PvWgLkeQsELSl/wStPhJsoyDPBMol0z7r0Y45rOD2gIHxHTJejyZV97a6f313uFX LyAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eawL3ejK; 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-155659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155659-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x63-20020a50bac5000000b0057220f85d13si1090990ede.132.2024.04.23.10.21.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 10:21:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eawL3ejK; 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-155659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155659-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3796E1F23EC1 for ; Tue, 23 Apr 2024 17:21:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 84C4B142636; Tue, 23 Apr 2024 17:19:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="eawL3ejK" Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (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 1497B1422BA for ; Tue, 23 Apr 2024 17:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713892773; cv=none; b=YMbwtWG+FAazdZ5JajDbV8v6dlPQfMB31m7gdCfsCyw0qpqRmzU9pqRoyJAUkbuwBTL3WjYvFY4Ooyx87i3MrKYatf5bAnli4LtsLJXoiJ9KbWbsmsIQgiu2o/NCz865SNeDy9qwGzRFGKgBybHj8FqpGh7lB0M0Wzicqb2zgFo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713892773; c=relaxed/simple; bh=JsQs/P4jKp9LfG3MxSTU0mCfPIqvsCGGyiJ32GEguKI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=foYqoUbmZ+fxt7Hy7QfKOwvDFlzcXE1yErjyawJ4gHGeb3ALS6QnEj1nAOyBrNIP0ODh1zVPyMvO2fjqDNlm89P+lnpNY51IHYAECsCnIOrWeFOO9q4Hj+5GuY3IXdbrYDssBdX/Ht4wRGy4YtbSW/oerY9T3PpVNpwuZDVdW8o= 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=eawL3ejK; arc=none smtp.client-ip=91.218.175.182 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=1713892770; 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=RmSFa+/zcwP0QaIdNDOJ1SuDsADV5qigCZtp1Yg0z+k=; b=eawL3ejKMUZaIuqtY569XLEzlZ65oAr1u8k/lPeBMfmOQZsJTSb0CdCAJhn9pVuZ5w+4w2 bycS97rw9I9WELVIkeIybBJ5upEBCjiDgKaZDHu7Adoprw4gYzxd2ZTyZLAxBuvw4dcK35 VoK77CgLDTxPv65QC8vwYeyBGNiV/uc= From: Sean Anderson To: Laurent Pinchart , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org Cc: Daniel Vetter , linux-arm-kernel@lists.infradead.org, Michal Simek , linux-kernel@vger.kernel.org, David Airlie , Tomi Valkeinen , Sean Anderson Subject: [PATCH v4 10/13] drm: zynqmp_dp: Use AUX IRQs instead of polling Date: Tue, 23 Apr 2024 13:18:56 -0400 Message-Id: <20240423171859.3953024-11-sean.anderson@linux.dev> In-Reply-To: <20240423171859.3953024-1-sean.anderson@linux.dev> References: <20240423171859.3953024-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 Instead of polling the status register for the AUX status, just enable the IRQs and signal a completion. Signed-off-by: Sean Anderson --- (no changes since v3) Changes in v3: - New drivers/gpu/drm/xlnx/zynqmp_dp.c | 35 +++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c index 9d61b6b8f2d4..863668642190 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c @@ -285,6 +285,7 @@ struct zynqmp_dp_config { * @next_bridge: The downstream bridge * @config: IP core configuration from DTS * @aux: aux channel + * @aux_done: Completed when we get an AUX reply or timeout * @phy: PHY handles for DP lanes * @num_lanes: number of enabled phy lanes * @hpd_work: hot plug detection worker @@ -305,6 +306,7 @@ struct zynqmp_dp { struct drm_bridge bridge; struct work_struct hpd_work; struct work_struct hpd_irq_work; + struct completion aux_done; struct mutex lock; struct drm_bridge *next_bridge; @@ -941,12 +943,15 @@ static int zynqmp_dp_aux_cmd_submit(struct zynqmp_dp *dp, u32 cmd, u16 addr, u8 *buf, u8 bytes, u8 *reply) { bool is_read = (cmd & AUX_READ_BIT) ? true : false; + unsigned long time_left; u32 reg, i; reg = zynqmp_dp_read(dp, ZYNQMP_DP_INTERRUPT_SIGNAL_STATE); if (reg & ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REQUEST) return -EBUSY; + reinit_completion(&dp->aux_done); + zynqmp_dp_write(dp, ZYNQMP_DP_AUX_ADDRESS, addr); if (!is_read) for (i = 0; i < bytes; i++) @@ -961,17 +966,14 @@ static int zynqmp_dp_aux_cmd_submit(struct zynqmp_dp *dp, u32 cmd, u16 addr, zynqmp_dp_write(dp, ZYNQMP_DP_AUX_COMMAND, reg); /* Wait for reply to be delivered upto 2ms */ - for (i = 0; ; i++) { - reg = zynqmp_dp_read(dp, ZYNQMP_DP_INTERRUPT_SIGNAL_STATE); - if (reg & ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY) - break; + time_left = wait_for_completion_timeout(&dp->aux_done, + msecs_to_jiffies(2)); + if (!time_left) + return -ETIMEDOUT; - if (reg & ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY_TIMEOUT || - i == 2) - return -ETIMEDOUT; - - usleep_range(1000, 1100); - } + reg = zynqmp_dp_read(dp, ZYNQMP_DP_INTERRUPT_SIGNAL_STATE); + if (reg & ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY_TIMEOUT) + return -ETIMEDOUT; reg = zynqmp_dp_read(dp, ZYNQMP_DP_AUX_REPLY_CODE); if (reply) @@ -1055,6 +1057,9 @@ static int zynqmp_dp_aux_init(struct zynqmp_dp *dp) (w << ZYNQMP_DP_AUX_CLK_DIVIDER_AUX_FILTER_SHIFT) | (rate / (1000 * 1000))); + zynqmp_dp_write(dp, ZYNQMP_DP_INT_EN, ZYNQMP_DP_INT_REPLY_RECEIVED | + ZYNQMP_DP_INT_REPLY_TIMEOUT); + dp->aux.name = "ZynqMP DP AUX"; dp->aux.dev = dp->dev; dp->aux.drm_dev = dp->bridge.dev; @@ -1072,6 +1077,9 @@ static int zynqmp_dp_aux_init(struct zynqmp_dp *dp) static void zynqmp_dp_aux_cleanup(struct zynqmp_dp *dp) { drm_dp_aux_unregister(&dp->aux); + + zynqmp_dp_write(dp, ZYNQMP_DP_INT_DS, ZYNQMP_DP_INT_REPLY_RECEIVED | + ZYNQMP_DP_INT_REPLY_TIMEOUT); } /* ----------------------------------------------------------------------------- @@ -1685,6 +1693,12 @@ static irqreturn_t zynqmp_dp_irq_handler(int irq, void *data) if (status & ZYNQMP_DP_INT_HPD_IRQ) schedule_work(&dp->hpd_irq_work); + if (status & ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY) + complete(&dp->aux_done); + + if (status & ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY_TIMEOUT) + complete(&dp->aux_done); + return IRQ_HANDLED; } @@ -1708,6 +1722,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub) dp->dpsub = dpsub; dp->status = connector_status_disconnected; mutex_init(&dp->lock); + init_completion(&dp->aux_done); INIT_WORK(&dp->hpd_work, zynqmp_dp_hpd_work_func); INIT_WORK(&dp->hpd_irq_work, zynqmp_dp_hpd_irq_work_func); -- 2.35.1.1320.gc452695387.dirty