From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 927A03A75A3 for ; Tue, 25 Aug 2026 17:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787679017; cv=none; b=PMLCHeYv0qmJ2lETZaGXAppFasayG0lwS8yrylgPLtDqhwHcJ9FxdZ+CsZJM7k05OmnuDsXtB9hIuclFqOah0ugmIb8mq4s8cnfMvgX9EtiXPOKvw5K5hpF54emCBOX5fg6K+2Oc5Wmxn1ax8RStSufqsidB06qSxgGIKlsqptg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787679017; c=relaxed/simple; bh=WF09Bx2mtfrt6hRVd0SLFSWF4rEJup3wBMbdU8OJyJ4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qdKmqUzWD1A0fOJKqoMe8UL1lbpQaXh5Nn1OXF8qvy4f3K+bkWFotHbtt+XkXqqclPQVzExAzrL31tS5lWOlwYp1wQ0N+/Jj9TDJBf2/mCUliUIyvfWoSEX1MUZ9cbOBgDUL1zJLq1uyoAzzdwLrTx18iLhUdFtUW/Er60t48nI= 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=tugWrJuC; arc=none smtp.client-ip=209.85.214.176 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="tugWrJuC" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2cede6375caso8815ad.0 for ; Tue, 25 Aug 2026 10:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787679006; x=1788283806; 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=8wBJpCqawgcwqwfKU05d1Z2ZrVuf5nK5DNpdSKbZyiM=; b=tugWrJuC3EM4AgIlu0Qrp3lcyBTXhAZgQT07rwANBz0gp94Iyp0qv51b5wVR5O9tnr iH0tTeonwPQWcUykkXq8AewnxUUeRlVNv7yf5WiBTQSXDMPGgGwCULwpVYtxocAYskLW 8HRzWDbfcez1pHsf4OeWTPVNc3Uta+hjZUMdF9U057sjtMngNqCNLr3VBZYqX37Gj+It pqm5A5Q/s9KuZ1ZOTl3akDp6fnIDOciEqaew3VG9zyJ/NqSLYo5EU3n8ByTKyslwKTCL QuZU+qro8/zuLzxeI+ClpL9nwQ7gplBKpk0NtO1tJICN6ga7a/rPbtB3Q9xa+D80XlFQ RZGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787679006; x=1788283806; 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=8wBJpCqawgcwqwfKU05d1Z2ZrVuf5nK5DNpdSKbZyiM=; b=knRrDyXZXtc36tL+3P65XfFYXt/WpViGhyrBGj97g8pNzNwmScwdACFqBtB8Xu8+eg SK+tQRqdCiD2LE5urUUqkmN+LKRSvdLAIa3cziPY/8hk9nU+tJy+489mC8PzpoURRsyF i8OkPBh4zYH/o0BvADleEi4Dm8HKVlbc+Qpl3fvvdEvqx+bqBRG3HvET60HZtu/mF0zX qP9h0sRP1lMUQVpM9/o0kGG7X3QOvutaVUQnHHv7edMRjL0rjhPioqHGtfSEA/rI8BHq TrNKKMF8xyhcDS8NqFAs+A6sbm4hpes6zWDUpBamYrnzQvXuNGQUBme6zYZtIeUJX2IG pMWw== X-Forwarded-Encrypted: i=1; AHgh+RoQyNL7D6Kx66rbMUvGsNEkCC95oite+OpDybCsqcg2IsL94muSDePrM22mnuQi4OzBR+2VpVqG/fh6iPo=@vger.kernel.org X-Gm-Message-State: AFuF++kSsG6lbhIHDkCdW9WeNfgUX3l3mqHp56SREpYTPQN/z13yN8Lk MaEWSknjnBCIj4fm71JPcyd78rCH6/UXvTDhj9qiYlXjFibD/vbyP4wlxuXZU5AkQ7ZQST8l2aY cocg3hw== X-Gm-Gg: AR+sD12oKRGgpFYbTESk6i7v7fctOf5aQMCeXB7+KxqFcSfdlPfEonJH4bOfM+ulo8K GKzB3fpH7L1ezxCjPt8G41zpzEHkf9cclgvGHgGkuxZQsnXFCrsjdBjf9PLG1qQvJjgddEjaOAs 8lINf5gI2pvpknaL+qY8fMFXy5dMdMhrjezRFw1lrLwFZ0VVaSjPGtjPp9CtExvsohWdz5Guobe qg1imPwoWQJ64pl96Uzw/+JBJSoDLIGmrwlkOjVBZLm/1RKc/qhciFbpRkLe8HnfgtfuuQ409GC yp1T93gHOer5p1hAN6jh67e9DJ73A3KW8UtY5unXMhq7fntsJVm2vcDmt9h2aq4UJrEY4wAYUZv xkq1YUlPhmxzv2EzBcWPPNRkz8oVxkq6gssxeJd8vgSbc2Z+z/34BEoAKLzVYZEmqiRatz3wo8W /3qidkKCHdbYLE6adjfMVnCnUiS6U31VBOiurpXrN0eVur3ciTVWh70gphVu6zCNf79OMwe1Oyn BQtjep1/uuWmtF7N00f6V7hylKPCiFSp1RCxA== X-Received: by 2002:a17:903:acf:b0:2cf:4353:f117 with SMTP id d9443c01a7336-2d6e036d4cbmr8058505ad.0.1787679005676; Tue, 25 Aug 2026 10:30:05 -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-39662c80d6csm1544432a91.1.2026.08.25.10.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 10:30:05 -0700 (PDT) Date: Tue, 25 Aug 2026 17:29:59 +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> <20260825114916.GT244917@nvidia.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: <20260825114916.GT244917@nvidia.com> On Tue, Aug 25, 2026 at 08:49:16AM -0300, Jason Gunthorpe wrote: > On Tue, Aug 25, 2026 at 10:32:07AM +0000, Pranjal Shrivastava wrote: > > 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). > > There is no reason to do that, the DTE isn't written by > amd_iommu_probe_device(), so there is no reason to clear it on an > error path. > > It is wrong to write to the DTE table without flushing the > HW cache. > I agree, but I wonder why the existing code used memset here (in ignore_device): memset(&dev_table[devid], 0, sizeof(struct dev_table_entry)); I was thinking it might've been done for probe failures in a kdump kernel (normal kexec would've called shutdown for clearing all DTEs). (I see this was added long time back and existed when PCI segments were added [1]). Are you suggesting to remove the DTE clearing from this path entirely? Thanks, Praan [1] https://lore.kernel.org/all/20220706113825.25582-23-vasant.hegde@amd.com/