From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99E49C54E71 for ; Fri, 22 Mar 2024 21:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HjV3ps2izf68gW6xrrGs4Edd2RIVYx8HB+rdeUGNajY=; b=XrYLMw1vZc4d9x D60kZXtWTHq3NZajl+oP9QFGaKT8sSsToVId6ypoMZ7BnA2PV6In5Z816lgROE+kh6S47nt0madHb g0fpgMQ/cGrRRKoJoKOZCY1nXwXbQ6qiRGsaAiGSeVvQvtZcqWMI9Hf4+RktAbkL5jKvBuo0N0JG8 pHii498OKrVcroBrulMh5deX+z9/Xmu6yNw2iWzhl0bmiOiYt6Hx4WCrBcr8E2fCJbdMGdfQBBkeX rBCbs8FE8eAyTMXLYxMLkD7jydLwkBGu+cGaRbEX0n/Y3nKvEcS1GrBB44iEogY2fHNyJgKP1+ZOW 6G7ORMvNPRrleFivwIAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnmLx-00000008hUU-2tZc; Fri, 22 Mar 2024 21:23:05 +0000 Received: from out-184.mta1.migadu.com ([95.215.58.184]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnmLt-00000008hTp-3JNO for linux-arm-kernel@lists.infradead.org; Fri, 22 Mar 2024 21:23:04 +0000 Message-ID: <7a4c332b-a044-4c82-a5b2-cb4b318f5110@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1711142577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n4WPHqLerzC8ab0n7LldeLvSy2z0lzhG43YXJDO+5do=; b=EYgHCIodIKnO0p2+qooONaEquVNo90Iqoglv8JTq73y3Zt9MEG2QLtmTS3rDCsxdz+zpZv 1TPNQASdDZw7PksAKghkzmF9ZiT4ebwNdw0nBaW//DAmN9Vukgwe1cNaKz11C/iXZqmwnT 5WjhDD3qLvT9CCXEuvbjisjEe5hvNgI= Date: Fri, 22 Mar 2024 17:22:46 -0400 MIME-Version: 1.0 Subject: Re: [PATCH v2 5/8] drm: zynqmp_dp: Don't retrain the link in our IRQ Content-Language: en-US To: Tomi Valkeinen Cc: Michal Simek , David Airlie , linux-kernel@vger.kernel.org, Daniel Vetter , linux-arm-kernel@lists.infradead.org, Laurent Pinchart , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org References: <20240319225122.3048400-1-sean.anderson@linux.dev> <20240319225122.3048400-6-sean.anderson@linux.dev> <53b2df23-d5ea-498b-a501-b64f753c0074@linux.dev> <0514ef71-5baa-4989-9b7d-8bd9526c4d8d@ideasonboard.com> <16ccf678-270c-4770-8cc9-f676b4fabf09@linux.dev> <1f27ce69-9ea6-4df4-9147-332d74febdf0@ideasonboard.com> <2dbf138f-5112-48e1-85a6-9e3ad84ec4a6@linux.dev> <305a8e43-4d65-490c-9f83-afce6490bc83@ideasonboard.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson In-Reply-To: <305a8e43-4d65-490c-9f83-afce6490bc83@ideasonboard.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240322_142302_781728_85E30D09 X-CRM114-Status: GOOD ( 20.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 3/22/24 14:09, Tomi Valkeinen wrote: > On 22/03/2024 18:18, Sean Anderson wrote: >> On 3/22/24 01:32, Tomi Valkeinen wrote: >>> On 21/03/2024 21:17, Sean Anderson wrote: >>>> On 3/21/24 15:08, Tomi Valkeinen wrote: >>>>> On 21/03/2024 20:01, Sean Anderson wrote: >>>>>> On 3/21/24 13:25, Tomi Valkeinen wrote: >>>>>>> On 21/03/2024 17:52, Sean Anderson wrote: >>>>>>>> On 3/20/24 02:53, Tomi Valkeinen wrote: >>>>>>>>> On 20/03/2024 00:51, Sean Anderson wrote: >>>>>>>>> Do we need to handle interrupts while either delayed work is being done? >>>>>>>> >>>>>>>> Probably not. >>>>>>>> >>>>>>>>> If we do need a delayed work, would just one work be enough which >>>>>>>>> handles both HPD_EVENT and HPD_IRQ, instead of two? >>>>>>>> >>>>>>>> Maybe, but then we need to determine which pending events we need to >>>>>>>> handle. I think since we have only two events it will be easier to just >>>>>>>> have separate workqueues. >>>>>>> >>>>>>> The less concurrency, the better...Which is why it would be nice to do it all in the threaded irq. >>>>>> >>>>>> Yeah, but we can use a mutex for this which means there is not too much >>>>>> interesting going on. >>>>> >>>>> Ok. Yep, if we get (hopefully) a single mutex with clearly defined fields that it protects, I'm ok with workqueues. >>>>> >>>>> I'd still prefer just one workqueue, though... >>>> >>>> Yeah, but then we need a spinlock or something to tell the workqueue what it should do. >>> >>> Yep. We could also always look at the HPD (if we drop the big sleeps) in the wq, and have a flag for the HPD IRQ, which would reduce the state to a single bit. >> >> How about something like >> >> zynqmp_dp_irq_handler(...) >> { >> /* Read status and handle underflow/overflow/vblank */ >> >> status &= ZYNQMP_DP_INT_HPD_EVENT | ZYNQMP_DP_INT_HPD_IRQ; >> if (status) { >> atomic_or(status, &dp->status); >> return IRQ_WAKE_THREAD; >> } >> >> return IRQ_HANDLED; >> } >> >> zynqmp_dp_thread_handler(...) >> { >> status = atomic_xchg(&dp->status, 0); >> /* process HPD stuff */ >> } >> >> which gets rid of the workqueue too. > > I like it. We can't use IRQF_ONESHOT, as that would keep the irq masked while the threaded handler is being ran. I don't think that's a problem, but just something to keep in mind that both handlers can run concurrently. Actually, I'm not sure we can do it like this. Imagine we have something like CPU 0 CPU 1 zynqmp_dp_thread_handler() atomic_xchg() __handle_irq_event_percpu zynqmp_dp_irq_handler() atomic_or() return IRQ_WAIT_THREAD __irq_wake_thread() test_and_set_bit(IRQTF_RUNTHREAD, ...) return return IRQ_HANDLED and whoops we now have bits set in dp->status but the thread isn't running. I don't think there's a way to fix this without locking (or two works). TBH I am leaning towards just having two works; it is a clean implementation. We can also convert to use work_struct instead of delayed_work, since we never set a delay. --Sean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel