From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 3FA113BBA09 for ; Thu, 4 Jun 2026 18:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780597293; cv=none; b=q2/880EJ6U+ua6BjDvkhx5HtNEDqd/ES5wjidwVOTTY1oy4y8c8R23JxEON1pRp9izIPxXnQozVHWbKt3k0dhwgg67dSPyRwjoeKX+dDnGgyahzHSO3iPJC1IX9gfdWELRrV8Ovo377cgeTDA9k8ESbCITomWg9jIhVFr5hSXbo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780597293; c=relaxed/simple; bh=w57WWqbuVg1C46CefALqiJ2Pvgfc2qJJo+gvJ+wT4u0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kWBCKOgdCAX7TP6Pa6EDQQCIB09xKIvoSje8gBQvjNRL4mgMtLh5MMWUxb6uKofuVQZeS5ns0Qh0yXrPj0HajYgodw5ynvQ1yvkRQ0ycYXDlyxWPDY/asYFbhjrxgLPoaM5m0bwQpCEWvowyX+pap91vNQQF4rwCbRGlO/Rbqfw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--praan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=STL+5Ytu; arc=none smtp.client-ip=209.85.216.73 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=flex--praan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="STL+5Ytu" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-36bc5e97950so1184293a91.1 for ; Thu, 04 Jun 2026 11:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780597289; x=1781202089; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lIiNR1cRpyTRt2RrDtP+DBDRqvojsy7fBnMse0sQxKI=; b=STL+5YtuXwXutOWeM/3D9ikrRMie68CjVids4tmFX8vCdCUhydgXDFfp/Wr7JwWAp6 4czuikXCU8UPW/t9lK/XLQ4pTWmB2PpD3kWISo7bisqM1Nr2RUpXtXIcPdC6lnlIq6oa 8z7bYQvuzC+fwQ/E6o3LP0XZDVTzpDRO4ZJYi5U5YgvyUOknORHnh8D8iPlNs5f7AL+W AV+hJ+hkeZlesmltjyDFq8JBJe/XHNF8Y7nHDy8tMs/OQXZSi8Yd/o9i2fakktv29Oo5 Rgc2FSxRoBpb+3f8q0Jb+MtOU+37IEH194sW4hGFvdU0G/Bw2F/ov/5w0CZFifR+7ATE Y9Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780597289; x=1781202089; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lIiNR1cRpyTRt2RrDtP+DBDRqvojsy7fBnMse0sQxKI=; b=XMIuR1kaq95xJR/kvD6DhRAOgRs7cwNrrIt96cPag1H68JNAuTabodWl8sgUqb8j5Z QekQUZAmyg4rAjDuRxM/hXk4NL6EaAIqdbHCa2FHsPaX5yPOeVCXYlyf6l+b7IsPlRFD ctEXOLv2eF17Y1dMsveVSUheZfxdeUXoA2CA6nyNfue/AxVSgXzlk277mpDZ7nyDFX3z b7YcFmEFEGvveTBbVExyiOKL8y/7Mq/9re8/dat/rkmKP3sHi9Yi4gl1L00Xv0UJHLJb BgdfKoBy2jRFVcrLZwLdxDhJca7lbLt2x4kB4BrOw25AjvtHy5a3stWhktxoPmpE7DTT 7ouw== X-Forwarded-Encrypted: i=1; AFNElJ+Ze30/2XCRyJTQgsLzAkc+w9FO5/uDCqPeAQdq5BpB5/oyto5V6svBFax/EWi5X+btEuiywpuekRrW84w=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8Or4lvXGFw7PuhMNrslcl0szxLyXAaP6XHWe2jLSNoXTuLBjI lCMAeUQJRffmlv1rco3xM3cFDZuhSoB404V+3Qq5rNxlwP08emmY/D20kGZ11cz2uY1R51cme89 ofw== X-Received: from pjez16.prod.google.com ([2002:a17:90a:150:b0:36b:be09:e0f7]) (user=praan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1ccd:b0:368:a297:bd38 with SMTP id 98e67ed59e1d1-370eedfff8dmr139009a91.7.1780597289305; Thu, 04 Jun 2026 11:21:29 -0700 (PDT) Date: Thu, 4 Jun 2026 18:21:16 +0000 In-Reply-To: <20260604182116.3179005-1-praan@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260604182116.3179005-1-praan@google.com> X-Mailer: git-send-email 2.54.0.1032.g2f8565e1d1-goog Message-ID: <20260604182116.3179005-5-praan@google.com> Subject: [PATCH v8 4/4] iommu/vt-d: Fail probe on ATS configuration failure From: Pranjal Shrivastava To: iommu@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Joerg Roedel , Will Deacon , Robin Murphy , Baolu Lu , Jason Gunthorpe , Kevin Tian , Bjorn Helgaas , Samiullah Khawaja , Pranjal Shrivastava Content-Type: text/plain; charset="UTF-8" Update the Intel VT-d driver to handle ATS configuration and enablement more strictly. Specifically, update the device probe to fail if pci_prepare_ats() returns an error. This ensures that any ATS-capable master reaching the attach phase is guaranteed to have a valid config. Additionally, update iommu_enable_pci_ats() to WARN() if pci_enable_ats fails. Since earlier checks in the probe phase preclude config-related failures, any failure during hardware enablement is considered a kernel bug. Reviewed-by: Lu Baolu Reviewed-by: Kevin Tian Signed-off-by: Pranjal Shrivastava --- drivers/iommu/intel/iommu.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 849d06dfe1ae..f39451323553 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -876,8 +876,14 @@ static void iommu_enable_pci_ats(struct device_domain_info *info) if (!pci_ats_page_aligned(pdev)) return; - if (!pci_enable_ats(pdev, VTD_PAGE_SHIFT)) - info->ats_enabled = 1; + /* + * pci_enable_ats() should not fail here because earlier checks + * have already verified support and configuration. + */ + if (WARN_ON(pci_enable_ats(pdev, VTD_PAGE_SHIFT))) + return; + + info->ats_enabled = 1; } static void iommu_disable_pci_ats(struct device_domain_info *info) @@ -3292,7 +3298,10 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev) dev_iommu_priv_set(dev, info); if (pdev && pci_ats_supported(pdev)) { - pci_prepare_ats(pdev, VTD_PAGE_SHIFT); + ret = pci_prepare_ats(pdev, VTD_PAGE_SHIFT); + if (ret) + goto free; + ret = device_rbtree_insert(iommu, info); if (ret) goto free; -- 2.54.0.1032.g2f8565e1d1-goog