Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp416177pxb; Wed, 15 Sep 2021 05:11:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP3ICXE47JC3Pv+X7ZavA15k2V8W7q3aBJF6eKcQc8aUYZBg9JTCNOz2lDEG/+MqZA40aq X-Received: by 2002:a17:907:6297:: with SMTP id nd23mr24776782ejc.62.1631707916631; Wed, 15 Sep 2021 05:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631707916; cv=none; d=google.com; s=arc-20160816; b=FNAlkpeTjUwjCLFn5xT1xVRAewjAGSbBM2geIP5hzxTMwfvkxFX5l+H3htKWLzsuba d/vKa/QMf6103qY6y13P8M8HVhvt66qtt5cbspopVY2PUXX0YDFgwflpPXM8xUiF/lEc 3nQyozPzLLh1CCIGVsMM8pA5nFvuo+DlwQxZbM/Bqg27cAVQj0OZLHo/2uawZFO8I/dU S0iUONtNLoDguY68nIt0Ra6hVOAFNoEY+2cnzU7RO5fA4NYrfbCd6ADbSfN8e0G/6oYZ 4//iLuu2NogUYoZb3gIEz33J2FQMo94hDLKvizOrsQK9whGKn1Mqhh9c9lXboEMQif60 4MAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=nsbC/14C+kMeJoOAkh98qBGl2wGnLGSFlhXpNUqwCFE=; b=Ymd0idAhAcUimWx1bInr44xqTq1n7LgK2YI37NTtrcJBFqOIvObVvYejaMKnQU76vT PmvWgaUFEyxhWxXC8FcNw+Ctb4V2Mzb/bWQodRurjxoKPRQkPy1xxLsICHeI6I6f4ZLX u0wz3bXA+yEMtqQaoJAse3llxRVx/aSmdv29YF3uQv/UNqTwoLH/baHYzjGF13vNYAb4 pELIt20XgbnMx21nBXE5MnZLkDnyuKGAB9kjtl5rN0gTkQWkCUr7uQ6EcePUnUKrqz/p tgkVOivVHe++KlbJnjZU9lu3Iqan6MkF9Zfu8gPXIG3ejVx+4zg/Dbmrf9Xqza/GX+2y 1erA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LhPdYdNB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr6si19288833ejc.711.2021.09.15.05.11.30; Wed, 15 Sep 2021 05:11:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LhPdYdNB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236487AbhIOMLM (ORCPT + 99 others); Wed, 15 Sep 2021 08:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231500AbhIOMLL (ORCPT ); Wed, 15 Sep 2021 08:11:11 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7A5CC061574; Wed, 15 Sep 2021 05:09:52 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id c33so576249ljr.8; Wed, 15 Sep 2021 05:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nsbC/14C+kMeJoOAkh98qBGl2wGnLGSFlhXpNUqwCFE=; b=LhPdYdNBwz8NgzDrN2yfcZ22U38rnPVJDJATIRjG63cwjSqJeLcOJ7rb7Mqkfcwr33 3/auLAlxO62WVV4QiDO2Df8ksHGq6u9HEH3oLpPwx4Cq9Qj5dUy22XthraTolzPolOaJ E96kLqsddIYf83sJUP/zJ5eyEXN+fxcw2imlkHqzTrIeUZsdad/E3q0cC2y9z5UUqlI5 ifZGau8FbHZDNZXkRREq1RuEUHjYLqRrIEK/pF3SQczPs6bpDrNI64nHDcCj81CzN4Na aEB1HaqB8+/GWyI0+TrO8Fh4E1l5bJCHLuFwLvlPKH5nysZxgvKVRb9jvMnVkARREFoB MD8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nsbC/14C+kMeJoOAkh98qBGl2wGnLGSFlhXpNUqwCFE=; b=zfOnTH9OFXyayjiRl5LJEcwe17/vaMAyFiJwtGShVMTHRc5fSs/CwDZxbVmCKK14Jm rE5N1E0o0HUZ58fWrcbbDwiEetVebsFSs2JOFl53IvfCqLGW1sUmEOT3zQwl2kHa1gHg 9wkASa+qn4M4SdhuK6gfcnlKmIFP9/YpvT5CZ+h81qhu0GZXKVyPrPtTBkqk0dsfx0Ko zUsXIHJcOBQnq94vggih2OvZwLYCQ9aa+rmU5VWZIHiC/f11J2cbVnfMlZt8TwYQ3oGf B67kkNXS110AucDkf2tEbTlltc9OnvmPqX0LuIYV9+OiOpLw4A3lPn3NYZ2WZZwmCdGz tGQw== X-Gm-Message-State: AOAM532Y235VCzstQ77kVtq2ZsZNi+7m+EPiKd+DUS0GMUZxhlFoJYS5 PH4ym0E28aGePZGNbtjYSb+dYSRF6zc= X-Received: by 2002:a2e:8804:: with SMTP id x4mr18646458ljh.437.1631707789844; Wed, 15 Sep 2021 05:09:49 -0700 (PDT) Received: from [192.168.2.145] (94-29-62-67.dynamic.spd-mgts.ru. [94.29.62.67]) by smtp.googlemail.com with ESMTPSA id u16sm1798222ljl.9.2021.09.15.05.09.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Sep 2021 05:09:49 -0700 (PDT) Subject: Re: [PATCH v6 6/6] iommu/tegra-smmu: Add pagetable mappings to debugfs To: Nicolin Chen Cc: thierry.reding@gmail.com, joro@8bytes.org, will@kernel.org, vdumpa@nvidia.com, jonathanh@nvidia.com, linux-tegra@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20210914013858.31192-1-nicoleotsuka@gmail.com> <20210914013858.31192-7-nicoleotsuka@gmail.com> <31501a62-3312-9f04-3bb8-790d0481746c@gmail.com> <20210914184933.GA32705@Asurada-Nvidia> <25d68aff-323a-df54-45f9-55b22f3089e0@gmail.com> <20210915043806.GA19185@Asurada-Nvidia> From: Dmitry Osipenko Message-ID: Date: Wed, 15 Sep 2021 15:09:48 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210915043806.GA19185@Asurada-Nvidia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 15.09.2021 07:38, Nicolin Chen пишет: > On Tue, Sep 14, 2021 at 10:20:30PM +0300, Dmitry Osipenko wrote: >> 14.09.2021 21:49, Nicolin Chen пишет: >>> On Tue, Sep 14, 2021 at 04:29:15PM +0300, Dmitry Osipenko wrote: >>>> 14.09.2021 04:38, Nicolin Chen пишет: >>>>> +static unsigned long pd_pt_index_iova(unsigned int pd_index, unsigned int pt_index) >>>>> +{ >>>>> + return ((dma_addr_t)pd_index & (SMMU_NUM_PDE - 1)) << SMMU_PDE_SHIFT | >>>>> + ((dma_addr_t)pt_index & (SMMU_NUM_PTE - 1)) << SMMU_PTE_SHIFT; >>>>> +} >>>> >>>> We know that IOVA is fixed to u32 for this controller. Can we avoid all >>>> these dma_addr_t castings? It should make code cleaner a tad, IMO. >>> >>> Tegra210 actually supports 34-bit IOVA... >>> >> >> It doesn't. 34-bit is PA, 32-bit is VA. >> >> Quote from T210 TRM: >> >> "The SMMU is a centralized virtual-to-physical translation for MSS. It >> maps a 32-bit virtual address to a 34-bit physical address. If the >> client address is 40 bits then bits 39:32 are ignored." > > If you scroll down by a couple of sections, you can see 34-bit > virtual addresses in section 18.6.1.2; and if checking one ASID > register, you can see it mention the extra two bits va[33:32]. Thanks for the pointer. It says that only certain memory clients allow to combine 4 ASIDs to form 34bit VA space. In this case the PA space is split into 4GB areas and there are additional bitfields which configure the ASID mapping of each 4GB area. Still each ASID is 32bit. This is what TRM says: "For the GPU and other clients with 34-bit address interfaces, the ASID registers are extended to point to four ASIDs. The SMMU supports 4GB of virtual address space per ASID, so mapping addr[33:32] into ASID[1:0] extends the virtual address space of a client to 16GB." > However, the driver currently sets its geometry.aperture_end to > 32-bit, and we can only get 32-bit IOVAs using PDE and PTE only, > so I think it should be safe to remove the castings here. I'll > wait for a couple of days and see if there'd be other comments > for me to address in next version. You will need to read the special "ASID Assignment Register" which supports 4 sub-ASIDs to translate the PA address into the actual VA. By default all clients are limited to a single ASID and upstream kernel doesn't support programming of 34bit VAs. So doesn't worth the effort to fully translate the VA, IMO. >> Even if it supported more than 32bit, then the returned ulong is 32bit, >> which doesn't make sense. > > On ARM64 (Tegra210), isn't ulong 64-bit? Yes, indeed.