Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5771012rwb; Wed, 9 Aug 2023 08:55:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2pBbGN0bGWl+yA/wYet6k/74gmhp2ZAkHkuU5mpUGvYDB6kguSjHy42xjr6gFABuPtf9b X-Received: by 2002:a05:6402:120a:b0:523:3f45:5678 with SMTP id c10-20020a056402120a00b005233f455678mr2531433edw.31.1691596529727; Wed, 09 Aug 2023 08:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691596529; cv=none; d=google.com; s=arc-20160816; b=L95lp+xHAWfVhA1Mmh0lp1KNS79k7C5pjGQRTvAT5EPrauqLdLFDneDY3oLzW/lfpI EeGi0/eV2fNs0sLBSPLFajGS8sgr6R/sTPUCYS+ZFbihxh8Ss8T7SdF0ucH/c9CaJKPR SiPm+bH8EW0prA57YHnWq8zg4YrUIvcCQia9z15OW7k8l6bIkLzxJaWDEt4nmxpPUOVr 4qqVez1N7jEhUWNZO37R+8c407QYF/pjLbCZLIcgQB0JuzEUVIwFUIInPFVbA8ucbYj0 mLqVpRurj+zBm7DBVu2HSjsxbiFpyq50KISBaEokcjoik4X//8ADKtE2AE/OabdIWhem 8Reg== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=/juNPIMNzqnK4HYRoBj0V5GORsxJLfIG1bJuNizVcWE=; fh=gKxNtBLcIlkDAAdU4DT+1bzP1rj6peu2lhDBCnAExJM=; b=ddGzeiPb3En8xq0Fh2h7sgqXi4TF01EBVBWtf+SblovwkF9miFi+HYLq6S2x5q0A0X yed7/eH1ZynUOffq7KWajZSiErgH0klfAt4MO2zRhAWEZKhbbgcv7jyt7AAVgCTqB70H cv9tAXTAW4e/MYmkCCfW2ZpXpio5EnizedJpMeLEqDEm0gmbnaheHhNps9KTo/2aT2/d 7g3xE9lz7W6AiKlwx6/kN+mb3TVBW6J8gWbm87/riTwGz7f0A46sSh2ICDQq7MxZfY19 hj4pXsz7lY0Cw+n1wZusde/lhLDzf+uLXL0SKY8zGld6ip61gZplcBYxqCgNuwABIB83 ze4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vMkhiJrD; 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 n1-20020a170906724100b009938cb10548si8780726ejk.549.2023.08.09.08.55.04; Wed, 09 Aug 2023 08:55:29 -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=vMkhiJrD; 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 S232274AbjHIOzu (ORCPT + 99 others); Wed, 9 Aug 2023 10:55:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbjHIOzt (ORCPT ); Wed, 9 Aug 2023 10:55:49 -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 610F4DC for ; Wed, 9 Aug 2023 07:55:49 -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 E9B3962F68 for ; Wed, 9 Aug 2023 14:55:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1117C433C9; Wed, 9 Aug 2023 14:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691592948; bh=RstcmDjitf3VE+sqHRb0jBKHbUC65fA41JgJoreOdZU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vMkhiJrDNXcnOWjqeCiE879G8K15cFnCSkPW83MJZ3fWKmd82APotaJrQXuS7/2Jm 5w17xvX8DmRulfCXAHIGs2k/1tyg+MPCZ6M2jCg2NL6NFiDiC9dVuHM2pnnKjkkzRL bGL9/gsGEQtoS0au4gvLF0UNbJ4hQ0kXLcCpxJoTnIjbJG/DzsZq7IBXy6E2vDfWOv MEhrE9LlUjthDXWXNpEQfwGroiN8UJPUgPGLyK2jJuhcnICswnklKRz+Zjbd1oCYR3 kVPkCvLf+BWe5adeW4hzqib36cVpmepCO93Q82hS+Di0wK0KGP/bSi/69o9kdIp73T IlS3S0icFNiWQ== Date: Wed, 9 Aug 2023 15:55:43 +0100 From: Will Deacon To: Jason Gunthorpe Cc: Michael Shavit , iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robin.murphy@arm.com, nicolinc@nvidia.com, jean-philippe@linaro.org Subject: Re: [PATCH v5 2/9] iommu/arm-smmu-v3: Replace s1_cfg with cdtab_cfg Message-ID: <20230809145542.GB4472@willie-the-truck> References: <20230808171446.2187795-1-mshavit@google.com> <20230809011204.v5.2.I1ef1ed19d7786c8176a0d05820c869e650c8d68f@changeid> <20230809134941.GA4226@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Wed, Aug 09, 2023 at 10:59:33AM -0300, Jason Gunthorpe wrote: > On Wed, Aug 09, 2023 at 02:49:41PM +0100, Will Deacon wrote: > > > > @@ -1360,10 +1357,14 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, > > > !master->stall_enabled) > > > dst[1] |= cpu_to_le64(STRTAB_STE_1_S1STALLD); > > > > > > - val |= (s1_cfg->cdcfg.cdtab_dma & STRTAB_STE_0_S1CTXPTR_MASK) | > > > - FIELD_PREP(STRTAB_STE_0_CFG, STRTAB_STE_0_CFG_S1_TRANS) | > > > - FIELD_PREP(STRTAB_STE_0_S1CDMAX, s1_cfg->s1cdmax) | > > > - FIELD_PREP(STRTAB_STE_0_S1FMT, s1_cfg->s1fmt); > > > + val |= (cd_table->cdtab_dma & STRTAB_STE_0_S1CTXPTR_MASK) | > > > + FIELD_PREP(STRTAB_STE_0_CFG, STRTAB_STE_0_CFG_S1_TRANS) | > > > + FIELD_PREP(STRTAB_STE_0_S1CDMAX, > > > + cd_table->max_cds_bits) | > > > + FIELD_PREP(STRTAB_STE_0_S1FMT, > > > + cd_table->l1_desc ? > > > + STRTAB_STE_0_S1FMT_64K_L2 : > > > + STRTAB_STE_0_S1FMT_LINEAR); > > > > magically know that we're using 64k tables. > > > > Why is this an improvement to the driver? > > Put the above in a function > > arm_smmu_get_cd_ste(struct arm_smmu_ctx_desc_cfg *cdtab, void *ste) > > And it makes more sense. Sorry, but I'm not seeing it :/ > We don't need the driver to precompute the "s1_cfg" parameters and > store them in a redundant struct along side the ctx_desc_cfg when we > can compute those same values on the fly with no cost. But the computation isn't happening -- the STRTAB_STE_0_S1FMT_64K_L2 constant is hardcoded here. If we want to use 4k leaf tables in some cases, how would you add that? Such a change shouldn't need the low-level strtab creation code to change. Will