Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp16487lqh; Mon, 6 May 2024 09:51:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQEgXs5D7qURcR6GkflNFnkV0TDNNKu1MjMzMT1OQ5kbLjt+Xe7d9xbY1tgtCgPmvQkY65woTCFx11djb27xzDSSx5DQmMMMPevrqQ6g== X-Google-Smtp-Source: AGHT+IHH5Gd8JaL6yqoEFagrCSqZeTmtwQW7MEiZ9G9Y3fD6S7SuqP2K1td8CNoQNNz8oHedUh32 X-Received: by 2002:a05:620a:394b:b0:790:cc3b:fe65 with SMTP id qs11-20020a05620a394b00b00790cc3bfe65mr15973926qkn.10.1715014275022; Mon, 06 May 2024 09:51:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715014275; cv=pass; d=google.com; s=arc-20160816; b=qfrmdDNnBJ56D5KxRtBc+lKY2Zk2Dzn2VlkRxg3eAP9NRqQcMAt9HHEIULduGTEm8O h6dI6SAyIce+p1TzmsyLoXWiYlaz52etBxJ+sNTAbD2ft6oQ7BlSXNDdGBSnV447pAJY ANqJaENn/4nDFYF/77cyFC3CQmwdtKWwT0OyOv+jc0iram4TKIYq2QFJArxL1mxLt4Cr VGLlyGUeYDI6wo6rx/v86gEUTN/51+qjQBxdJzclUgXtLZMES9is0gb5XUs/9H4V+Y6Z MQK+1bH+LGGfoUrJ9EPGDIXMJyjiSQLuUF6Vp/1kmrc+3ULaSUXzqPmpOB5CWDa+fpDB RX0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Mr8ohMOIrRX0IBKaRIOCe7PAsOFy83XbHiXOCOvjlQU=; fh=HmSMERdl/dFkIh+iV+L/zZtoni5er3/4CQozV7s4bv8=; b=PiN6ysKDwucfNeUwYM1KCrvoP7MEiKiELOK6Z2RQVQ0sd8hGwSZz3RCLErnZBkmCHt 9XHhfFTXoKopL7rpJevQm2e+EaH66h+C0gmEqf/x1z9cmQmw4EPZQdcW855U5rjE5hwB vdYCajCSDAOSWwR73nKrSrQ8M0Tv05r5Jv5Mebgq8F/lHTl5FkMOePKNWftJFZTxHkVq CzZHCrvBpmXMe8nngtDQ/hVLk1QDBwHFdz+fzAnVhJfZbMr3SeEEnt0uhyDxij3kxjwH 4nQTwfiGELzwjf7r0m9NXHDiFPzOHT7NTN5EY8Bm99UuC6BtKFJMEOdrfTGCCCyHewoP dMqQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=NlR0WF+d; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-170191-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170191-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x8-20020a05620a098800b00792981ce613si2804753qkx.82.2024.05.06.09.51.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 09:51:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170191-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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=NlR0WF+d; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-170191-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170191-linux.lists.archive=gmail.com@vger.kernel.org" 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 A3A301C20F7A for ; Mon, 6 May 2024 16:51:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64E5B156C69; Mon, 6 May 2024 16:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NlR0WF+d" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 4ECF2156962 for ; Mon, 6 May 2024 16:51:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715014267; cv=none; b=Z5X70mTCxRfExso2toLBN3cHsnb5/D4MMbDDRp3Aq7YCcuB3nVBiRD7fwMxm/QpTwCd0WPy7JMsMNxHfYw5HsdNCXpKTdnMRnMh1O239RQ/mdigQ5PRIpqzQDFm9G1sLB59mHXa0OJ761CgT29dx7MBzCjUpkxV6TX91NG2cihw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715014267; c=relaxed/simple; bh=8+i50YterCbwSCR8dhufT5e0/xJ1TjQeaFJDpeKsoMQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n7+ENF90c7bBlFTP58la1GW8W95qze8mPiHFXZjW7nzwbLPabsA4+aGEjCWT6TJWiyG4Jfc2S+mPctnujQWuQ5000NRZKqnUQViD6XaTy+jpqwMPZ/6KIm7TDgGX+dEz7ntlY0n4Qgg5N1ddE/OUyGNwnAHvZrseKW72g1+FeMw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=NlR0WF+d; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9596E908; Mon, 6 May 2024 18:51:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1715014263; bh=8+i50YterCbwSCR8dhufT5e0/xJ1TjQeaFJDpeKsoMQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NlR0WF+dBNw/IcKF1IrTZLvIQyl/DjBfUtWWr+XCb3BcSrrOHid5t6h28Y8j8jpIR 2EGaeJKVMM1b4qBJ3+v99XTjbBDCqzoeAgYE8gk3J62FreHQzTyO9WSWuNQ/s0LyLG 72GoE96KsoL+ueCItx8AUaKTFavKV6c8WOnc+NYw= Date: Mon, 6 May 2024 19:50:57 +0300 From: Laurent Pinchart To: Sean Anderson Cc: Maxime Ripard , Tomi Valkeinen , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Michal Simek , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [BUG] drm: zynqmp_dp: Lockup in zynqmp_dp_bridge_detect when device is unbound Message-ID: <20240506165057.GD29108@pendragon.ideasonboard.com> References: <4d8f4c9b-2efb-4774-9a37-2f257f79b2c9@linux.dev> <20240504122118.GB24548@pendragon.ideasonboard.com> <20240506-charcoal-griffin-of-tact-174dde@houat> <20240506073531.GA10260@pendragon.ideasonboard.com> <97811bfe-a1fb-419c-a148-74e3d84aa0e2@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <97811bfe-a1fb-419c-a148-74e3d84aa0e2@linux.dev> On Mon, May 06, 2024 at 10:57:17AM -0400, Sean Anderson wrote: > On 5/6/24 03:35, Laurent Pinchart wrote: > > On Mon, May 06, 2024 at 09:29:36AM +0200, Maxime Ripard wrote: > >> Hi Laurent, Sean, > >> > >> On Sat, May 04, 2024 at 03:21:18PM GMT, Laurent Pinchart wrote: > >> > On Fri, May 03, 2024 at 05:54:32PM -0400, Sean Anderson wrote: > >> > > I have discovered a bug in the displayport driver on drm-misc-next. To > >> > > trigger it, run > >> > > > >> > > echo fd4a0000.display > /sys/bus/platform/drivers/zynqmp-dpsub/unbind > >> > > > >> > > The system will become unresponsive and (after a bit) splat with a hard > >> > > LOCKUP. One core will be unresponsive at the first zynqmp_dp_read in > >> > > zynqmp_dp_bridge_detect. > >> > > > >> > > I believe the issue is due the registers being unmapped and the block > >> > > put into reset in zynqmp_dp_remove instead of zynqmp_dpsub_release. > >> > > >> > That is on purpose. Drivers are not allowed to access the device at all > >> > after .remove() returns. > >> > >> It's not "on purpose" no. Drivers indeed are not allowed to access the > >> device after remove, but the kernel shouldn't crash. This is exactly > >> why we have drm_dev_enter / drm_dev_exit. > > > > I didn't mean the crash was on purpose :-) It's the registers being > > unmapped that is, as nothing should touch those registers after > > .remove() returns. > > OK, so then we need to have some kind of flag in the driver or in the drm > subsystem so we know not to access those registers. To avoid race conditions, the .remove() function should mark the device as removed, wait for all ongoing access from userspace to be complete, and then proceed to unmapping registers and doing other cleanups. Userspace may still have open file descriptors to the device at that point. Any new userspace access should be disallowed (by checking the removed flag), with the only userspace-initiated operations that still need to run being the release-related operations (unmapping memory, closing file descriptors, ...). -- Regards, Laurent Pinchart