Received: by 2002:ac8:5491:0:b0:40f:fb00:664b with SMTP id h17csp589552qtq; Thu, 10 Aug 2023 09:54:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWoF93hzJJAVCCvy+KRpe64k1CWHZxrVxeZtZZGkyUaq6qJZBVvZWvxAveNjeVmfKA2FqP X-Received: by 2002:a17:902:d2ca:b0:1bd:b79:3068 with SMTP id n10-20020a170902d2ca00b001bd0b793068mr3209368plc.48.1691686493997; Thu, 10 Aug 2023 09:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691686493; cv=none; d=google.com; s=arc-20160816; b=FWPSESajp9N6R/GyNwa0uMAhKw+FHTw/5Is/p1fYgdI4/FgZcZj7l1d9MJum9kOWYN g/Blh/6oPjz8+H2rCMLEiZPpNbWd3oMzEWeVg+I9vHQ3Mmwz7npii/3GyPqY6eUZFZ07 +JoRUeBJi7uCnUSwV0668VyeiyYU2We2qznrskmUSdHTc4kKVmLG/N9BrPkqyRWuuF65 Qce9YwnV2coKhFh9PUzzL5UsdxjhLokMtR065UXbjX7o6vznOCV4I82EI/2kBv1yTPH+ 2bT0QF12VifxLz3QBv4+FIWJpqZ4c360A0LEompsrGvV/2bLN7HASsS+TKcHXBWasWSF VIKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ceRQTN5LroOTHjPuj22gtWZFBZPuCJO+7kWMziQiVX8=; fh=UcPNuZLtXCMWvwdFRdGd6IzVV+LZMFlmkGHKUGI1KtY=; b=iKcw1TNjij81sHZk2djChYv+tlQOS5umDEp+IyiZw+wohUYPIZL8SCAYNDaAoBKoic l+HwMWQNxc98HDbGxRZu4KdgXjtgPd+xNyc4SUNK6CP5ddkY0ugHoJBGtiSRT3sN0xjF sVX+djUbaXYZsoPtnZgbp9MmvE377PNTiJuJUXF3YulavusuRM855jxJwLlvllakYIWh g031mZn4uX6ZoXVn8F7LlBfgeQ3LtXsf7TlCpWgr1+GcRoOjjS3j9EvMW7VxJ2AdgdEZ rDIoMKxfoiY07iUfnOgAAZDudNfYvyGzdYnU/VJVxbdk9IMW0pCYg1UEDvXU55lBqJwe 1jvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iNo3vyzO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a170902d31200b001bc7c699257si1669810plc.610.2023.08.10.09.54.41; Thu, 10 Aug 2023 09:54:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iNo3vyzO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235796AbjHJQ2G (ORCPT + 99 others); Thu, 10 Aug 2023 12:28:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236001AbjHJQ1w (ORCPT ); Thu, 10 Aug 2023 12:27:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0613D26B2 for ; Thu, 10 Aug 2023 09:27:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83B7C66361 for ; Thu, 10 Aug 2023 16:27:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AEA2C433C8; Thu, 10 Aug 2023 16:27:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691684870; bh=dTku1OjG3tbVRFq4kPSk5Upl89gZucyzeix7zMe8F4A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iNo3vyzOHxV6dXUgQTscPsYAGXN8vOsYys+mEl3VLZ9agM6D+LtxCdFoZQzwdYFtr jn9SukqhEh1T4ariWZ9YMyZrCIyrx8qXWt1Ei4+gYsWkfpe3dF7USgCbeUfh1L4TfB HToZvdGHnVb4wqMrrzXFaaj96huazjiZa8PnkB2lDB4myCP9VUCaIcLj99w2oRO+oB kgMJPYvaB2eGjvaDhJ35SZY/UamKdQRYhsnKr7Tzw0SeBB2MTOM1SQxUMnpDXSJYHH 9iu6GJpgbEOLSLvd5UJ+f17sOF9NhX/ekXceAxZhB3b15eerMLGW06daUCQDyjMWhL P/ANLN3Sefi/w== Date: Thu, 10 Aug 2023 17:27:45 +0100 From: Will Deacon To: Michael Shavit Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robin.murphy@arm.com, nicolinc@nvidia.com, jgg@nvidia.com, jean-philippe@linaro.org Subject: Re: [PATCH v5 8/9] iommu/arm-smmu-v3: Skip cd sync if CD table isn't active Message-ID: <20230810162745.GB5951@willie-the-truck> References: <20230808171446.2187795-1-mshavit@google.com> <20230809011204.v5.8.Idedc0f496231e2faab3df057219c5e2d937bbfe4@changeid> <20230809135011.GC4226@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 10, 2023 at 04:34:39PM +0800, Michael Shavit wrote: > On Wed, Aug 9, 2023 at 9:50 PM Will Deacon wrote: > > > > On Wed, Aug 09, 2023 at 01:12:04AM +0800, Michael Shavit wrote: > > > This commit explicitly keeps track of whether a CD table is installed in > > > an STE so that arm_smmu_sync_cd can skip the sync when unnecessary. This > > > was previously achieved through the domain->devices list, but we are > > > moving to a model where arm_smmu_sync_cd directly operates on a master > > > and the master's CD table instead of a domain. > > > > Why is this path worth optimising? > > I have no idea what the practical impact of this optimization is, but > the motivation here was to make the overall series as close to a nop > as possible. This optimization existed before but is "broken" by the > previous patch. This patch restores it. I'm not sure it's necessary, tbh. It's not like we're calling arm_smmu_sync_cd() all over the place -- it's used when we're actually working with the CD. > > Doesn't this interact badly with the sync in arm_smmu_detach_dev(), which I > > think happens after zapping the STE? > > The arm_smmu_write_ctx_desc call added in arm_smmu_detach_dev() was > inserted after zapping the STE precisely so that we could skip the > sync. Is there a concern that a stale CD could be used when the > CDtable is re-inserted into the STE? Ah, sorry, I went and looked at the architecture and it says for CMD_CFGI_STE: | This command invalidates all Context descriptors (including L1CD) | that were cached using the given StreamID. so as long as we make the CD unreachable in the STE before the STE invalidation (which I think we do by setting the Config field to bypass or abort), then I agree that we don't need the subsequent CD invalidation. > > > /* > > > - * STE is live, and the SMMU might read dwords of this CD in any > > > + * STE may be live, and the SMMU might read dwords of this CD in any > > > * order. Ensure that it observes valid values before reading > > > * V=1. > > > */ > > > > Why does this patch need to update this comment? > > This is a drive-by to make this comment more accurate. Note how > (before this patch series) arm_smmu_domain_finalise_s1 explicitly > mentions that it calls arm_smmu_write_ctx_desc while the STE isn't > installed yet. Yet this comment asserts the STE *is* live. Can you do it as its own patch then, please? Will