Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2455028rdb; Wed, 21 Feb 2024 08:09:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUrWnaT0Yr8rLhoGZRHYGOGcSfA5uX23chWoog16OK1SoKPEZgJ0PPN38NW2nAYs+mTF1VEcCBARMTEr5FFDSCiLMvUiAqHt5Dj3cwsTQ== X-Google-Smtp-Source: AGHT+IHNfB9fivQ8868NYmsLsrPicZbkiPv1TBA3bxLJFNIyro4HJmaSWFsc2QILaO+4dRu4YFSh X-Received: by 2002:a05:6a20:2a16:b0:19e:a531:e489 with SMTP id e22-20020a056a202a1600b0019ea531e489mr12774936pzh.31.1708531744632; Wed, 21 Feb 2024 08:09:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708531744; cv=pass; d=google.com; s=arc-20160816; b=hJYNvv7G7eRZ+y+PjueiIUGOjmvCEXmTXKNIIKxqiFQTZpXrLeu7YZFYZj4d+JvvCr 0Vg9W12D6y5lWUDqGqcgkdCe2+PQH9X1KtYSOnBhx6NXcK9b554GVtUw4f/M4hO5qMkW uVIfeEdfgk2pxDPr084b883tReJWUMHhLI+QIfxvCboS6D4EGffms/O694UTwhkU/81C GNt9KRP3p7xNABuiU7aNuB5yV+mgj7uFz1HLfW1jjjpnKw0l8JXwSs2HcH2effugh6mR KyBA+udPBx0onphYQFx6iGbIkfNH5EiQDMsSxm3jcLmRrCsyGza3Np7CsDrrkLG6EB/R KSnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=cIV/0533TDg6QfGT2La5/OJ2pbn/hOScukdFXpjlFYc=; fh=rEfGQ6LgKy4Otp3yODtwHoQpjj7nZO9FYAaXkUCmRjI=; b=pV55ZaMNEhVhQNJw366zDNwt7rFvAe9swk08BkvGLItpzCC6MbKSNDi6MKAXwD0Sj8 Fjp16B9BjgFFegmCbOvqZrLyfH7Sh2tEbJ9vf0VQG8D+VVsaHaED9qjTo5sFQc4Iqcuw qfeLIlKsjtengFZYXaSqX2oGdGXfxMcyvGThhtM4WKKVQ6zT/OFH1dKUU4925T7fDRnp o0UnQS4fZqtkGb5dga/af5vWDRjvExXP9ouLdvndVrjcVjKz3xKOxTQZUQrpZFk6cIW+ LIYv8j//5TnfY8SFmK8ezze79ghy8rlhh7hI+YeLwQcMKpwSpooTbG9+RdYq27Zsu4Kw I70w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HztFuJxs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id by16-20020a056a02059000b005dcd6508942si8569991pgb.441.2024.02.21.08.09.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:09:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HztFuJxs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 54D922842BB for ; Wed, 21 Feb 2024 16:09:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F5E18121F; Wed, 21 Feb 2024 16:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HztFuJxs" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7B907CF0F; Wed, 21 Feb 2024 16:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708531735; cv=none; b=TkzBE3EqZCzHSTeUSoqq1Ejiax5s2vX8d03KnniS6csm7BoWu6SNCVrgXefLvIPiVm7+OZ8tChYoK1GmTGeLKT07TBvJAqIa+ffK0ln63untxf/0AZ+pViKJ2Uhn61eZP5TSiEjJqtw3ncFloghHKHYQkO164IfwUsNIqIIK9RE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708531735; c=relaxed/simple; bh=65OECqX9KxYAQydC9rm3J5R8qN/iq04mlYabKZdFS5I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j0EwwPQpD6BD6oikbl9HCVMpMuf7bv3HTJmIiiWUfLpG1k674Eej+yKb+njhdUdo/rmO+6fi0l7bztEd3+4y49CvgM+y4ZuwFCIwV4jA94d7VuYCGiqAB94yr9KHsxOR69KWe2QOumMlyq3J+Lwp8HcjMDPFouPmrZ1zyD8+O+Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HztFuJxs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91373C433F1; Wed, 21 Feb 2024 16:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708531735; bh=65OECqX9KxYAQydC9rm3J5R8qN/iq04mlYabKZdFS5I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HztFuJxseaQk0aYkeyC7H7JT1tB8CxESXcerSlvmnFx+KJKuYku4PjG3rzuYuv5MS MHXznbwvVe1NKXst5Wr63JMcZEBYmHTm32SM/eF3avlfczRZKJ4RG5RN9yv/mTH47d /bsQS9JfHR5yiPndbtTYqvl5zKkCz6GRm5bn16K4JZU03tfOaoHoHC29i9kiSs/2F2 ndM8ukJ5RLlTdp78vxD+E6pQ6x0MdNLqvqNU6goGHySWyxwxDcIxcXnYoS3PZymCt7 DpMUJBMFkPUzNky8TA5IZ91yqyTG+t+5PofaFWh58ItJKV0yV/PePTQq6ii07Q/l4N bl03CPNN8bziQ== Date: Wed, 21 Feb 2024 16:08:50 +0000 From: Will Deacon To: "ni.liqiang" Cc: danielmentz@google.com, iommu@lists.linux.dev, jin.qi@zte.com.cn, joro@8bytes.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robin.murphy@arm.com, ni.liqiang@zte.com.cn Subject: Re: [PATCH] drivers/iommu: Ensure that the queue base address is successfully written during SMMU initialization. Message-ID: <20240221160849.GB7362@willie-the-truck> References: <20240219091709.GA4105@willie-the-truck> <20240221152629.3656-1-niliqiang.io@gmail.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: <20240221152629.3656-1-niliqiang.io@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) On Wed, Feb 21, 2024 at 11:26:29PM +0800, ni.liqiang wrote: > >> The SMMU registers are accessed using Device-nGnRE attributes. It is > >> my understanding that, for Device-nGnRE, the Arm architecture requires > >> that writes to the same peripheral arrive at the endpoint in program > >> order. > > > > Yup, that's correct. The "nR" part means "non-Reordering", so something > > else is going on here. > > Yes, the SMMU registers are accessed using Device-nGnRE attributes. > > One additional point to note is: in cases where there is a failure writing > to the CMDQ base address register, the testing environment was a > multi-die, multi-socket server. This issue has not been observed on a > single-die server. I apologize for omitting this information in my initial > patch submission. Uh-oh, smells like a hardware issue ;p I wonder if Device-nGnRnE behaves any differently? > Over the past few days, I have referenced the kernel source code and > ported the SMMU register initialization process. Through multiple stress > tests, I have attempted to reproduce the CMDQ base address register write > failure issue. The summarized results of my experiments are as follows: > 1. When testing with one CPU core bound using taskset, the initialization > process was executed 300,000 times without encountering the CMDQ base > address register write failure issue. However, when not binding CPU using > taskset, the issue was reproduced around 1,000 iterations into the test. > 2. Without CPU binding, I inserted a memory barrier between accesses to > the CMDQ_BASE register and CMDQEN register, similar to the modification > made in the patch. After executing the initialization process 300,000 > times, the CMDQ base address register write failure issue did not occur. > > Based on these observations and joint analysis with CMN colleagues, we > speculate that in the SMMU register initialization process, if the CPU > core changes, and these CPUs are located on different dies, the underlying > 4 CCG ports are utilized to perform die-to-die accesses. However, in our > current strategy, these 4 CCG ports cannot guarantee ordering, resulting > in the completion of CMDQEN writing before the completion of CMDQ base > address writing. (Disclaimer: I don't know what a CCG port is) Hmmm. The part that doesn't make sense to me here is that migrating between CPUs implies context-switching, and we have a DSB on that path in __switch_to(). So why would adding barriers to the driver help? Maybe it just changes the timing? > From the analysis above, it seems that modifying the die-to-die access > strategy to achieve ordering of Device-nGnRE memory might be a better > solution compared to adding a memory barrier? I'm not sure what you're proposing, but I don't think Linux should be changed to accomodate this. Will