From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 16C0D39B94C for ; Wed, 20 May 2026 14:24:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779287097; cv=none; b=aoP92bkEawRep4neqxKGIMu5WG09vHa6cJqg97Q/CxHu4zGPs3a0PzIwb/bseYzoofOg4fjYt/HOktHEvJtrvBiqBU6vvHWBTLyGb62P/RbdlEV6F3YGRUmH9BYYi3WE/dcaSA5T3VfC+G+i2fY8bJxd4dP64fFXgZKKEWmk3lE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779287097; c=relaxed/simple; bh=KKCcdWqFNYQ5lipEqQIK8EuzMF7TRsUFT4LWZRN90h0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ecP3HHLI2inV7x3bgjEEFbgyNloUAgFk1l3tFf17pIL5NNsNqoFVjtyfSJ62XSlmH0REgT1NvmDlfQhs0TiVbHQcyzVl/6qHvBQokMm2P8iALYDlHZrTQUZQ4Ms6qgw/429gPYAF4po42d0uWwJ8ZFLVquPtKEmmhIU1MJHYXIY= 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=onXVOQpD; arc=none smtp.client-ip=209.85.214.180 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="onXVOQpD" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2b46da8c48eso1375ad.1 for ; Wed, 20 May 2026 07:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779287095; x=1779891895; darn=lists.linux.dev; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BXG3Uft8ZSTS8sDCEl0ZuECcCo/afwgtykht3rN3rLI=; b=onXVOQpD1v6/9OftLozolWHOSFEi1amvjqa3qo7sJh2JmQmOQ9BmAIOgA1Dj4FoTSf CgXpkocZCLy3a9cYv3brOCNQiyIotRQpVMRGGgYxAGdVsoLDUNLkItWBLualQ4oSEjvF PwNv/r6TOIegBM3fXUug3TzW3SM0w0m3ckZcZrctzjQFWZcIWZpMgTVioHNnWCidD1T1 UutcgvxGkzUVq+lpChtjgpM0Haq/AtfMMqAX2DU7/xdDeKILrCdDgPbG2UdYmvb+9D/R CZcy7bz4I9rujDgEnX4lkF0l9lB7lW9a1DciktO9iVINv7/xjAFkCg8/oR0z30Bb3Dyz OZRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779287095; x=1779891895; h=in-reply-to:content-disposition: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; bh=BXG3Uft8ZSTS8sDCEl0ZuECcCo/afwgtykht3rN3rLI=; b=kndrGKI1jPfU8qSuuIbHeLlVKFTNPZJ80jS6xKeE+i4/fcfLdnBVlJkIHGankciLSY 9xqblulU85v2JlhgXdHaqBjmR3uNlcDAgcKSAAPb+lSftrIoN10Lveb+JlpRs735U9zN B829czsl/Io/wJhMj2ZHzEa33YCyUnw8BtmvE2dLgI5UB4wDFQCv3hDce3X/FVEiTzS4 IbE7gv0X5MJQnoOGssa+1/y6ZAKOzwsba9HDW3DV3HDZ54mkKHiXCMLNpokIA9JDXHbc x+5j6hsdKFzyllap0HOjANSnWWbHuErqDUdmyZ8WkQli78pR1ex0A8AagidFn0IdokN2 RxJA== X-Gm-Message-State: AOJu0Yx6Q854BLRRwsWQwil47/XkgTOxl8U41T3jWP/1yKdtfmI9j20y yRvfAL9HKQ5zsvalUetibcmdU861VB3qEUZAtyDsQrvLKhEwDsovST4nNgWU8M8mVQ== X-Gm-Gg: Acq92OFbGuGyD8yQwWFkafdX4nkGmWHXqBuEtpXr4FqJ+Ogvv2Zq5unibvbnjyDPevu sL8vyABIzbfFgOpKdU/J42WneQnDMA88hlmvhwdMve14Oo9HZcNkmDe5GjLkzOuDi6FIZi4bYKZ yLZbqeJ6WHQF2WMNrDLLOLa+1n1TpGcRaCgHYxVuma6ksoXyVTrk3YnLTZu578GU40/wTGxxVbX A4czxffPqiWy34+fTZfLHBffBYN+bTgDngSINNwcj4uVu0LnHsXBiwhGyCpIGDtjmg5fIr8KzBd +xLpsSFoGVEWz69vT6Lm1PmGS7J00rYEtUOYht13DZ7QIDZ4yKhYFQiW/9qh5j/KtQmke878CGY sbV7oIVVKV6/jtuvHes0Sy5iOVrw25T+mP/EFt3GIsAMuCj5Z7lfs3XIE3s7MLDCtizhCBfDXAs voNwXGfyjK3XVntxcK8FyZeq0KCbhuG3HZjZTPoot8/LEoLKvj0u60jHvn9NX2I9F7UTqeql/k4 LBrTwA= X-Received: by 2002:a17:902:da4b:b0:2bc:a58c:fd7a with SMTP id d9443c01a7336-2bdb0410499mr9865105ad.16.1779287094622; Wed, 20 May 2026 07:24:54 -0700 (PDT) Received: from google.com (44.234.124.34.bc.googleusercontent.com. [34.124.234.44]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bd5c05f5d2sm220239565ad.23.2026.05.20.07.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 07:24:53 -0700 (PDT) Date: Wed, 20 May 2026 14:24:47 +0000 From: Pranjal Shrivastava To: Jason Gunthorpe Cc: iommu@lists.linux.dev, linux-pci@vger.kernel.org, Will Deacon , Joerg Roedel , Bjorn Helgaas , Robin Murphy , Mostafa Saleh , Nicolin Chen , Samiullah Khawaja , Daniel Mentz , Pasha Tatashin , David Matlack Subject: Re: [PATCH v3 3/3] iommu/arm-smmu-v3: Fix ATS state tracking via ats_prepared gate Message-ID: References: <20260519135323.1558777-1-praan@google.com> <20260519135323.1558777-4-praan@google.com> <20260519144430.GI7702@ziepe.ca> <20260519145947.GK7702@ziepe.ca> Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260519145947.GK7702@ziepe.ca> On Tue, May 19, 2026 at 11:59:47AM -0300, Jason Gunthorpe wrote: > On Tue, May 19, 2026 at 02:55:54PM +0000, Pranjal Shrivastava wrote: > > On Tue, May 19, 2026 at 11:44:30AM -0300, Jason Gunthorpe wrote: > > > On Tue, May 19, 2026 at 01:53:22PM +0000, Pranjal Shrivastava wrote: > > > > @@ -4450,7 +4450,8 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev) > > > > if (dev_is_pci(dev)) { > > > > unsigned int stu = __ffs(smmu->pgsize_bitmap); > > > > > > > > - pci_prepare_ats(to_pci_dev(dev), stu); > > > > + if (!pci_prepare_ats(to_pci_dev(dev), stu)) > > > > + master->ats_prepared = true; > > > > } > > > > > > This should fail not keep going, it is a kernel bug if > > > pci_prepare_ats() fails. > > [...] > > If ats isn't supported or if there's a STU mismatch, shuoldn't we just > > ensure that we don't try enabling ATS for that device? > > No, the kernel is broken somehow. > > > Returning an error here would fail the device probe.. which seems like a > > big hammer for devices that can't reliably use ATS.. > > It has nothing to do with devices, the kernel is broken if it fails. Ack. I see your point.. none of these should happen if the kernel isn't broken somewhere. > > > We have a special case in SMMUv3 where we pre-allocate stuff in prepare > > but actually enable ATS in attach_commit, which IMO neeeds to be gated > > based on client device's ATS capabilities? > > Yes, all of this should be gated by pci_ats_supported() > > But also failing to enable should translate into a failed attach. Ack. I guess we already check pci_ats_supported during attach_prepare() while setting the state->ats_enable. Based on this state->ats_enable we call pci_enable_ats() in attach_commit(). However, I'm thinking what's the right thing to do if pci_enable_ats() fails in attach_commit(): 1. Fail to attach but unmerging the invs_array entry is complicated. 2. Move the pci_enable_ats() to attach_prepare() 3. Continue without *really* enabling ATS.. Thanks, Praan