Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp69602rdb; Thu, 21 Dec 2023 03:07:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnuNZuWpkR/Vt0/mCD9PGeviq5KZoKL8wA51lGOWwDu817j1crK2Nr2IrzzPNLY3NhOHsf X-Received: by 2002:a05:6214:acc:b0:67f:7ef9:4a09 with SMTP id g12-20020a0562140acc00b0067f7ef94a09mr1803740qvi.43.1703156874300; Thu, 21 Dec 2023 03:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703156874; cv=none; d=google.com; s=arc-20160816; b=LfAi2d87SMKFZrN5Tez0v6qO+sOrIE5+Rbc+YTqtsLMiwM4nV+cON7n278FXeAv4Kb zyQe7BxfC8xmHIlEPLydVocHLjyxYbKjktdjxPbdpl51R+hGoRGTvNnDtAei5HthcQVL WKuJohoZzSQUxCFMoh422QqPqfQX97RCVHhIrVN1Bno0RCOvWYppsA7g56G29zmjqfhU ASdOrzb51u50xzB87+KTxDg+90sCdAVUkjkqNRMFk38oGazEIhv1d6zQtrx/TCwZTXSH t8/3BdR0VfgcQ4gvWwioYRuSGkfK4qmnKfFLRcklZhTlJqxwtMX3WG4km+J7IZqoZ/Yx ewOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=QA5/Ib3FGWChrMPRBY8V5dE9o3SSmqwCDhPqUVB/sWc=; fh=yh+Sss/76szH56CqbqATaaHCKRqvH4wjNEsuA57o8vc=; b=SEVDsp0/RMhgE2ORJ2NcEy6j2QCDzqmFetvX5s9ixDSADzwvBAg09rinSpQx7lzmxl HwI+4dmN533GuQ4q466xWugB1iYS64qZXWrPo/pzIpvRAY6U2aMGhdqYLNyw4+TEGHSZ oDKYGzzRyOiwpI2dhgYQ8/y6neuViLnyHc4Jbri8IdJC+76JcgDP1F0xyV+8y7ke/r4U N0Wb8eT2oL3ois1ms6Trt/u6qUk6xYAss76r9KpqMHYyBvAukgvmvDSyMrqTiYKfoRGt R3QQM4YQ/XVhwqK9+V+Cp9QmGCYFztHpH4lHv6Nr1K5plwO98fpt1HXeQfFoUSwFLV/8 AxWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8263-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g5-20020a05620a108500b00781210781ebsi720708qkk.327.2023.12.21.03.07.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 03:07:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8263-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 134E41C23CED for ; Thu, 21 Dec 2023 11:07:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3AFD6ABB9; Thu, 21 Dec 2023 11:07:47 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from bmailout3.hostsharing.net (bmailout3.hostsharing.net [176.9.242.62]) (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 78E1B6AB8F; Thu, 21 Dec 2023 11:07:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=h08.hostsharing.net Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS RSA CA G1" (verified OK)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id 65DC21003D0EC; Thu, 21 Dec 2023 12:07:43 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 3411B1E5F; Thu, 21 Dec 2023 12:07:43 +0100 (CET) Date: Thu, 21 Dec 2023 12:07:43 +0100 From: Lukas Wunner To: Robin Murphy Cc: Ethan Zhao , bhelgaas@google.com, baolu.lu@linux.intel.com, dwmw2@infradead.org, will@kernel.org, linux-pci@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Haorong Ye Subject: Re: [PATCH 2/2] iommu/vt-d: don's issue devTLB flush request when device is disconnected Message-ID: <20231221110743.GA1619@wunner.de> References: <20231213034637.2603013-1-haifeng.zhao@linux.intel.com> <20231213034637.2603013-3-haifeng.zhao@linux.intel.com> <20231213104417.GA31964@wunner.de> <3b7742c4-bbae-4a78-a5a6-30df936a17d4@arm.com> <20231221104254.GB12714@wunner.de> <6f49be01-89e3-4407-9813-51d62e723947@arm.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <6f49be01-89e3-4407-9813-51d62e723947@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) On Thu, Dec 21, 2023 at 11:01:56AM +0000, Robin Murphy wrote: > On 2023-12-21 10:42 am, Lukas Wunner wrote: > > On Wed, Dec 13, 2023 at 11:54:05AM +0000, Robin Murphy wrote: > > > I think if we want to ensure ATCs are invalidated on hot-unplug we need an > > > additional pre-removal notifier to take care of that, and that step would > > > then want to distinguish between an orderly removal where cleaning up is > > > somewhat meaningful, and a surprise removal where it definitely isn't. > > > > Even if a user starts the process for orderly removal, the device may be > > surprise-removed *during* that process. So we cannot assume that the > > device is actually accessible if orderly removal has been initiated. > > If the form factor supports surprise removal, the device may be gone > > at any time. > > Sure, whatever we do there's always going to be some unavoidable > time-of-check-to-time-of-use race window so we can never guarantee that > sending a request to the device will succeed. I was just making the point > that if we *have* already detected a surprise removal, then cleaning up its > leftover driver model state should still generate a BUS_NOTIFY_REMOVE_DEVICE > call, but in that case we can know there's no point trying to send any > requests to the device that's already gone. Right, using pci_dev_is_disconnected() as a *speedup* when we definitely know the device is gone, that's perfectly fine. So in that sense the proposed patch is acceptable *after* this series has been extended to make sure hard lockups can *never* occur on unplug. Thanks, Lukas