From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 7CD4640DFB6 for ; Thu, 19 Mar 2026 00:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773878891; cv=none; b=KM/lPixW9sJNRUB2aK6UfKADc5CgZ3vylPSIwju+MjLJARJyquIwTLDIix/4smDGnF6ob59pWEjrJtu0NaBd+rrcT9i/W/7YNmY/Dumegvobhbxyf3SN4l+2yGaBzyOajqFmeqCVA+nvf28dFmMw4AZN3ISjw5I8HlkpP7RA1wk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773878891; c=relaxed/simple; bh=9Lna6RLq1PceWhp4JFSVoi2qGNT1NzgxgPC7c15ur54=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tTYshFZZeHZT2GaEqzsxsn7N//Y7h2WyjkublcYllSU1LtJ1vzu3K7cOX8qeebtacrJYQC8W8ouzJ8ujEJOHknpZNpUzEVcKLFUKDj7Hh0BtlMFruWK5I8LVPqS3nZg0f5w1CJKzJWk070UCJ6tOw/GI9a9ZscqunR7CEqIfCHk= 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=AYMEnsf+; arc=none smtp.client-ip=209.85.214.179 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="AYMEnsf+" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2b052562254so37355ad.0 for ; Wed, 18 Mar 2026 17:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773878890; x=1774483690; darn=vger.kernel.org; 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=AY/dmLi/z8SUAAMZ2gqdSfQxfr35ot2Vi6eYrVHNvEQ=; b=AYMEnsf+Le994ULy2rEq51eWGliyhrW/hHuHIaV2LvIKJEGj6YPhgmYSac0BiULaw1 etUMK+ydOHcKd3zbtDOqrwjLmzdvFAIuc/gfnoqPE8nhvUWUwvPQg2EjMswxMq8Kgxct Wx7ZFNdgGrPFtBeN3V8WgBfSlEfvBJimI9mzNMDEi6CGvNEf/oL3uhWl2m8nFENnRlll ucGx1rE6BEgwYvrM46iLF34TKbnS8QFZSTHiUFVnovfhxFw7CAksGNysfUA60n+l4Dvu KQaMm64isVNa3VZbG0+prjOyXl5sw0Y6yHNbslSS5iARctXoQRA8FMLea0+g+YUPg/ae gCRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773878890; x=1774483690; 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=AY/dmLi/z8SUAAMZ2gqdSfQxfr35ot2Vi6eYrVHNvEQ=; b=evl2zB86Gy1pbwHgxW73wKwaG30mwVWTxE+TAKnT8jq/ULoAE3QvV6DBu53lxysXTb crwMsz94tWubOq4R8puoyVcpJ5P0f0QC7SI5UNT6FnCE/dpPwf7mKl6vIU6rHAjgolF6 u/nbNepxV7gA9U6HuUGAHH0udEUCy1HFpZD26PNZweoOJSUyssJML+68Zv2sd840YXJ5 zR2MZQ29J/V28yIWe6rXigpdXyK4IjxzIFV+6GYMKSjbokw0Kmpd/EB+/OHXIyHvBRnP G/M3w4GiopFGKPWwf0+isWjQjNgUTleKE6TNKW1pox8+5d4FH4M4otdV04FYQtMTpbDy P5wA== X-Forwarded-Encrypted: i=1; AJvYcCVtwsLLXygdNh5YAF6Kwle6+VZmzI91yT6Wa9EULyZY4mV4o9TKQrkdQgL4xTIj1Q2APLkEygLcnlSeMKs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4bVP4IOiLjVKTiEEEQaHR5hoVCgt+sIlP2MxWZ96Vm3U9/h1h JEJGwCnLJowGeTzT2FKRIUYOhZ/UPH37ir2PJhYFQRzEjR/BXrSG0RXA7wkrL0akRA== X-Gm-Gg: ATEYQzxeNvk5E2jJmgWfTaEDNdujqG1ShwvmMVATmHoPZid2+J/iAya2esfMUaKDEi1 b6ZWjXveWRRLItl4l8PyeD481qlQh/tw05Yv8XTSBDY1WgtcHTZ7/jrqOJ/DWndAkXh02nLqc1Z GMPuE/XZdI9LlUdS7lAcZeQ3vWKuDjqMEY4+X68OEf+m+/RvkoJSftlL/jKJuT3AmmYUwDbRBzK x3Fc/hsKntPArqVPMym/K7mveW2MqvGh85GNl8mfqVfP3uQ5QFru2HfY5L9m27zsgcxWalHvVOr hNePqiHKtVRE6rq0yjYC7JKKrzysoE4ogMhGsOgQqCMA6RtUBFM12dZo5W0/xGi6PUpuS7m99FD c+wFl1rmrmLCV6gw58hh6RLtvUEe+NUC/vAFulSDnxLJ+Gd6XqAullJWHujVOZ+Uh3tS1KRpKkQ ze7OtMIP30BExFOs0yI0G3KeLAv40wrdTMXMPHymlwSltJtz7NECaQ96yMx+G/pg== X-Received: by 2002:a17:903:2ac7:b0:2ae:45cc:aeb6 with SMTP id d9443c01a7336-2b077b4ca86mr1596195ad.6.1773878889199; Wed, 18 Mar 2026 17:08:09 -0700 (PDT) Received: from google.com (168.136.83.34.bc.googleusercontent.com. [34.83.136.168]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82a6bbe6162sm3741880b3a.42.2026.03.18.17.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 17:08:08 -0700 (PDT) Date: Thu, 19 Mar 2026 00:08:04 +0000 From: Samiullah Khawaja To: Nicolin Chen Cc: will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, bhelgaas@google.com, jgg@nvidia.com, rafael@kernel.org, lenb@kernel.org, praan@google.com, baolu.lu@linux.intel.com, xueshuai@linux.alibaba.com, kevin.tian@intel.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, vsethi@nvidia.com Subject: Re: [PATCH v2 4/7] iommu/arm-smmu-v3: Mark ATC invalidate timeouts via lockless bitmap Message-ID: References: <0c5525367cc67ccc84a675544d1d9f8462704065.1773774441.git.nicolinc@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; format=flowed Content-Disposition: inline In-Reply-To: On Wed, Mar 18, 2026 at 04:23:53PM -0700, Nicolin Chen wrote: >Hi Sami, > >On Wed, Mar 18, 2026 at 10:02:32PM +0000, Samiullah Khawaja wrote: >> On Tue, Mar 17, 2026 at 12:15:37PM -0700, Nicolin Chen wrote: >> > @@ -895,9 +898,19 @@ int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, >> > >> > /* 5. If we are inserting a CMD_SYNC, we must wait for it to complete */ >> > if (sync) { >> > + u32 sync_prod; >> > + >> > llq.prod = queue_inc_prod_n(&llq, n); >> > + sync_prod = llq.prod; >> > + >> > ret = arm_smmu_cmdq_poll_until_sync(smmu, cmdq, &llq); >> > - if (ret) { >> > + if (test_and_clear_bit(Q_IDX(&llq, sync_prod), >> > + cmdq->atc_sync_timeouts)) { >> >> This will not be set if a software timeout (1 second) occurs. Do you >> know if the ATC timeout of Arm sMMUv3 is less than the software timeout >> in the driver? > >You brought up a good point! > >I think ATC timeout follows the PCI Completion Timeout Value in >"Device Control 2 Register", which is typically set [50us, 50ms] >but can be set up to [17s, 64s] according to PCI Base spec. Agreed. > >> If not maybe we can handle the software timeout here also as the cmdlist >> is already known? > >I think it's trickier. > >If the software times out first at 1s, it means the CMDQ is still >pending on wait for the completion of ATC invalidation. Then, the >caller sees -ETIMEOUT and tries to bisect the ATC batch or update >the STE directly, either of which involves CMDQ. But CMDQ has not >recovered yet. > >Then, in case of a batch, all the reties could timeout again. So, >it will fail to identify which device is truly broken. This would >end badly by blindly disabling all the devices in the batch. Also >the disabling calls require CMDQ too, so they might fail as well. Yes, looking at VT-d currently and the queue length is 256 and this spirals out of control quickly. > >Thus, partially to answer the question, in case software timeout, >I am afraid that we can hardly do anything.. :-/ Agreed. Do you think we can maybe document this somewhere? Maybe add to the cover letter? > >This means I need to set a different return code for ATC timeouts >v.s. software timeouts. > >Also, there is another problem: when PCI CTO finally reaches, the >GERROR ISR will set atc_sync_timeouts but nobody will clear it.. >So, before calling arm_smmu_cmdq_issue_cmdlist(), we need to make >sure there is no dirty bit on the bitmap too. Yes, Just to confirm, do you think this needs to be handled regardless whether we handle the software timeout for the ATC invalidation? Basically to cleanup the bit on bitmap. > >Thanks! >Nicolin