From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED0132FFF8D for ; Tue, 25 Aug 2026 10:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787653936; cv=none; b=D6IpG02N2wJmBhJSBaWDiTFX6YhiI1d1GvqTB5O1CrqpSNdB7hzkRrqR2MbAf4K7xSGHLZ+MnG+2pIFlOln4SRA16yfy1ybF4h13g03ccP2X69fg4ppo9vPicaIZ5WS2Jj6WcKAn5h84CpdmFzSc5FiH2LKgR/1+VHRVgyMVOmw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787653936; c=relaxed/simple; bh=4QTkjd/s8diQPSf8tQmphgnN9lPOUKEI5Qx+/DyJBEY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AsvCr43ezAHjH4OMBhM6MNUuyua7axBKtqSO6dw5i9KOzHkVJm/h+b8PHJ0sISO3RmlL4nbuFdJDfthPTyf0+ugPeGk5Tv7w18CdZkdAvULqktLJzFWjc9aBJ4sRig9HhUYFuUnqzMfSzQNULo4TWdI5AcvlQLN1i60FIX0QB+Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kGK5ubmS; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kGK5ubmS" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2d3b440b97aso78455ad.1 for ; Tue, 25 Aug 2026 03:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787653934; x=1788258734; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=+r+5no3iFtMSZafzKDoU+7TmlqdFwa3seHnjZcCnMD8=; b=kGK5ubmSTY+k3oc8Du5p06qhDAaMeLlBhsQWOHUKKAwm8d4wyk+bcZKK3enIti7WIM +w201phzjkIwfu23Px68Kmgy8cl9d7dZZ2So9tYrs0hop80bW+6spcO9azxHbguLesOH iaxbisqGmdsc0/ldDJNcX+yXBUofdgnwnzxP6sbBy9aMa2txgTzqnWaTtqbnXdB5SMpe Kb/klqYahD5nVD582cP1IcK6W+aHFjRfaN2HxmuidLIPm4NoR319QWePxw84iJJGcWuJ dc7MyXM3x1+zOZNEpQSQirakLSM1GjUcb2/lq53Fv3Z1fjzeRFa4xkFnbQJCROM9v54H OLWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787653934; x=1788258734; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+r+5no3iFtMSZafzKDoU+7TmlqdFwa3seHnjZcCnMD8=; b=foyIEsfQT21Ri+j+VERQ6Ex81u+piIz7j8R7cQnkNyzSd+CeB1g3aW2x954rXCuqiT Ci6ZVCo+uY4OzQT1U33v54nBoxyC/QKlDdPbsUkdUAHSX1fzq+vg9n7lyVQBz4dXePqO I+0Lrs5cmPTPxV8ivo/UNpuCb1jbMyRy0Q3zXt2dHlGY9b+50lHR9j0iQbYlNShDan3s 1gyhxF7WwuUmUj9Fy3izg9TmY2GOs/e4d/oI1jp8fXKCP1nNtvSq8I4fxgrwoGq44yCX A9B4COeza6neJFqcpYfn8weUYtyDzNMZzq+ZChxeBevVCPn64unT3jf5J8XGqwkhukI2 XZ4g== X-Forwarded-Encrypted: i=1; AHgh+RrpFgseqnowykgRXTRyrTjZOLMNW6/5VWq+VQm1fTblqBSjuSJdLw+VSwZIrgx2YKjRGM15wBafV+BWI8U=@vger.kernel.org X-Gm-Message-State: AFuF++lMb6WyCNxYTZnyLu/qhqFB4MsvY+m4710z6lSftiH2oGsdiTd0 613p+wkLGIKFT5DnQ0mOzSZbWYX1XKQ06nn0Abzvl5Rq8+7atLt+mPqm9BffgxwyQA== X-Gm-Gg: AR+sD13+ypqqAcUn+9Ay2pMjtA0Wo/9OrXNg9D8TjtiIjFGj3kHca/fur6Zmy7gW2lU IdM8O9DEl1McOf4pZ/RciBPpS3AaRaOdo1GWODyJPn8iHCmpCSls+vwIMuMsptUOKQZTLuIcrzC 6s2GYK+Zn80KVQ8OVsxxhevGlTDGxmCJbyYsipXqwycw7XvgiDfOErdxALH4M2bYuj2nOjB2jhX Swdgin2jcrrFSRJ84RgSZ+7hauamJTsDfVvLyowUAwMUD6X0gozGIwV4Y+G4xKQakQV8rMYKm/i 4FFhsbq3h/flJfDL9xwtHZua5c54Nfs6NokP+HNY6NwsZCOIwemx6zYXwVSZZHi+fHHDAcxcEoy acKEXtfLxBBhPB/UhijfxErA6gMcYJfB5CqxYZS74zEXZPYefhcfMuJxE2NxfAvZN2x545xDFYT Cdxnnhf8qqLH2hSK+debGD7jOHdJpRKXyUIQJUR1y9LoaWjtxSPNwKPs+V7wQ8jlLH17v6OuWTR d/okeohRzZ1V5SF5RxxQdx8pckl16c5X7Z+/Wn7Hw== X-Received: by 2002:a17:902:c394:b0:2c7:b1e7:501e with SMTP id d9443c01a7336-2d6e0833465mr4854905ad.3.1787653933633; Tue, 25 Aug 2026 03:32:13 -0700 (PDT) Received: from google.com (164.210.142.34.bc.googleusercontent.com. [34.142.210.164]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39645bbb87esm3420518a91.13.2026.08.25.03.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 03:32:13 -0700 (PDT) Date: Tue, 25 Aug 2026 10:32:07 +0000 From: Pranjal Shrivastava To: Jason Gunthorpe Cc: iommu@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel , Suravee Suthikulpanit , Vasant Hegde , Ankit Soni , Bjorn Helgaas , Samiullah Khawaja , sashiko-bot@kernel.org Subject: Re: [PATCH v3 2/5] iommu/amd: Fix DTE clearing and rename iommu_ignore_device() Message-ID: References: <20260824122347.1588592-1-praan@google.com> <20260824122347.1588592-3-praan@google.com> <178759520117.3131778.15279605903087565179.b4-review@b4> 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: <178759520117.3131778.15279605903087565179.b4-review@b4> On Mon, Aug 24, 2026 at 03:13:21PM -0300, Jason Gunthorpe wrote: > > [ ... 52 lines skipped ... ] > > +/* > > + * Invalidate a DTE by clearing the Valid bit first. > > + * Note: Lockless; Not to be used on a fully probed > > + * device with live dev_data. > > + */ > > +static void amd_iommu_disable_dte(struct dev_table_entry *ptr) > > +{ > > + struct dev_table_entry new = {}; > > + > > + write_dte_lower128(ptr, &new); > > + write_dte_upper128(ptr, &new); > > +} > > No need just call update_dte256() with a 0'd new. This is how all the > update flows work, and it flushes the DTE which this looks like it has > been missing all long. > I originally considered using update_dte256(), but iommu_disable_device is called from the early probe error path (err_deinit). If iommu_init_device() fails before dev_data is fully allocated and attached to dev->iommu->priv, we don't have a valid dev_data pointer. Passing NULL into update_dte256() would cause a NULL pointer deref when it tries to acquire dev_data->dte_lock. That's why I introduced this helper amd_iommu_disable_dte(), specifically for this early teardown scenario where the device isn't fully live yet. Thanks, Praan