Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1416586lqp; Fri, 22 Mar 2024 14:23:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW9xsQLuTk0VC5FTMYsw5hEYB53TRQlca8/fzL7jOCzGtaQdrP8i6d+3Cv7Sw8JBS9V8le/IOzwvL4EBcEmnTrsYsPNHFaFlRFkXQUulg== X-Google-Smtp-Source: AGHT+IHf/a252rIZWz6YCw81c4kVCWA6jsEmlUzwiDh+yNbee9GkBJUP8ccDg1TPFD53iprvk5WU X-Received: by 2002:a05:6a20:1e53:b0:1a3:683a:2cd8 with SMTP id cy19-20020a056a201e5300b001a3683a2cd8mr737940pzb.28.1711142596295; Fri, 22 Mar 2024 14:23:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711142596; cv=pass; d=google.com; s=arc-20160816; b=BIdH+bjxb3tiYMAgIamQzBm37IKXhW0Il9zbQKB6FTa3z8HNF+mU4gessSyL4rlnxX utVlGa0AtzMEZp02a6yb0OzMvsLoENzzr6aESVZa+Ryt2pJ8iTboHN1GkEGx0lGHbs3E 7KFHBDpIDGNOiVP34hx32pVQpPKtMTUAoVeRNrYrV21rET1X1ybSFPQ089iuqgiFaX2v n/BwmwVrS0wSN6+1aKSjO7aFxtCfwJhQTe6U2zLJVHRMorVmwvdLJFRXgFCUSxQQtgWh CR+nk1A/hi0gc3CEzPMiWESfPW86AbH8HzZKOtVQLrkQvHkBdUqR9grXFkFeZYtmJu6L kM5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=n4WPHqLerzC8ab0n7LldeLvSy2z0lzhG43YXJDO+5do=; fh=Tjrdt/RtV1BbMi/RWh79PEXdRY8Dlhde1AbpWkRi2R0=; b=tyWB+hD2VeubnvNz+yi/H0O6JsVBukJRJ2BjcwsxnEfKWvdmCLo8nKZHmh6Kfgi9Kd RYAodH6ihDSuoyjAmtuC7w8hVl3RpebD8tt2Cy5I78ghEKJrRhCI6qfMYlEwqr4pxY2o ZJkX6QeBmmp1RDkbNmufsP17HdVeHFEIvroSlqNYM70x9xKnPnxpkFfCGxTWbfaFPeda M4og+IVZxe60XOfObZ0pneKn2giFI54VpDj0vLMGdqV9lhN46hWlGuE/ovzaZ6c7Vl3J Y86jlYqEt+HPD8HGRgulZOGzTC9WN3H3nL+ZkZr+1BF1B/VPmx26IX6VAzq8grBcro7c 2Wjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=EYgHCIod; 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-112034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112034-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 s185-20020a632cc2000000b005dc4f9ceccdsi2731752pgs.609.2024.03.22.14.23.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 14:23:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112034-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=EYgHCIod; 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-112034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112034-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 DDC1DB223E0 for ; Fri, 22 Mar 2024 21:23:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B78FD7FBBF; Fri, 22 Mar 2024 21:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="EYgHCIod" Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (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 A206753361 for ; Fri, 22 Mar 2024 21:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711142582; cv=none; b=WeeIKHgkOqgL9pWTuZHxOL4pfNcQXF0QZz5vos9ewGZZkbx98DvG+LWnHDzRVKMZuBMUN7JNqrzVLlcaQNH6MpeDjD/h9aRjyM0Qpr3xpDLd+/rVBChxLvxhZLhxOyx5bXraQn4yeJfbQdKDWzC5Iq5dB21KpLMOli06q8Rz6qY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711142582; c=relaxed/simple; bh=GVGq8gIwxjkrBu9nOLgq1KZZJT77R8jEbBlOrRh91qM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kjHIRKXqj2tDraWM69LyF2StU/scWFzjZ+aStHxZtSdquGTbof+jxbmnORfE+48Rhenn+FrVF/vMnKdLmJzMuhrUHoXtf68Im8DfefRHetMxNTGIzTd7WxfozzYWz4SXwGE36hEpwMei6TRJHdyOeItCKPs0RH03udeMzKBy2QQ= 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=EYgHCIod; arc=none smtp.client-ip=95.215.58.174 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 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT 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