Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp818573ybl; Thu, 22 Aug 2019 05:28:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbsYJxttCwOQuWzaCQAF6izqkaCNHVwwPsE8kdVadCVkQRAQluh1ubMD1GlEaeZoVPJFCb X-Received: by 2002:a17:902:fe14:: with SMTP id g20mr36872660plj.54.1566476925019; Thu, 22 Aug 2019 05:28:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566476925; cv=none; d=google.com; s=arc-20160816; b=x2BY2gDE3uTGs4cKv0IKGenERW6XqkagcXLaGhBelIlEeN+XRM8h6GN3GP4cIjkEvu 8eyp43Vhafr4dnGfjSFXt5pGEhIsF2jJJ7m3exc00LMvojqAr6NeavSvljGkwm/7tXQM gcSTzCSnaPpivAab5TR0ozKDws1WaptGICYE4EWPntxOLjx0ZqeZHwmUXBgLvLDoQ1pK cJ3fEmuro7W2K5jgm1RfASHBjQ1seM/A8JyR1VaocceHK1RBysBzmwqVh94R0csvz0N1 UnGRIFnnkzYnBhUyFHr/V5XkdWiq+ttv2xGRvM/Wfe5NwYQa9iz6ljf5jKCyrP65x/d1 t0IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3PgycowOoQQhWcuVdqY/mxSk+9OxZKgJqF6yViSn7Lg=; b=oAhQaKP0+KLO6wvqnrv4E1Ov50OUS1ehi7LcNpLd+BmYe+XOUYNo02Gb9nj7rh3lKi Rk1C1cdYam0V1Tqo2RcfY92BgeNrradiSIX53Oaw366QTd+ND5bgeJRBr0aKMEoC/n9O +051+Ji+RQKQFFFlYQ3QpzVI0y4Le0Y4plEvKAEvB9gc+gLdoRp/q/0qah6m8vyyWoW6 bEHZ1Oo42y/3j7/0EzZQiU5d15Y7OLYF5Q2CE5z6YMHzqtiYtv1S1KyE8hy2AyRnKasA 8L0AMMuexWi6bXuHzHcyOY0HS3QwPx+fdUYj1g4OcMkLR1sQuM2vUdZOQzUhLTCeXb0h bOCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rYThi+h2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11si2284885pjv.95.2019.08.22.05.28.30; Thu, 22 Aug 2019 05:28:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rYThi+h2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1732926AbfHVKIV (ORCPT + 99 others); Thu, 22 Aug 2019 06:08:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:54982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727553AbfHVKIU (ORCPT ); Thu, 22 Aug 2019 06:08:20 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 211D4233FC; Thu, 22 Aug 2019 10:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566468499; bh=IzjFEWdPrIj2HDymvSmNUsqNwBoJqAI3BTqeibzDG/E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rYThi+h21fwi/S9wIORrQaUPUGMjIox00ZAy/cLNVxUJaz/6kvzvI6xPMv6isLnqL YbO4bbC9r60HoObsGkHAzUEccRwIz4Nx9WfgF3REGv09J7Q84lLWfcvFFw1Z4IIaE9 poMHdFUTV0gAyjaHSpmHhHZrxiM+pV+B8wam3iuk= Date: Thu, 22 Aug 2019 11:08:13 +0100 From: Will Deacon To: Yong Wu Cc: youlin.pei@mediatek.com, devicetree@vger.kernel.org, Nicolas Boichat , cui.zhang@mediatek.com, srv_heupstream@mediatek.com, chao.hao@mediatek.com, Joerg Roedel , linux-kernel@vger.kernel.org, Evan Green , Tomasz Figa , iommu@lists.linux-foundation.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , ming-fan.chen@mediatek.com, anan.sun@mediatek.com, Robin Murphy , Matthias Kaehlcke , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v10 09/23] iommu/io-pgtable-arm-v7s: Extend to support PA[33:32] for MediaTek Message-ID: <20190822100812.ketlgxxu64cy2bsk@willie-the-truck> References: <1566395606-7975-1-git-send-email-yong.wu@mediatek.com> <1566395606-7975-10-git-send-email-yong.wu@mediatek.com> <20190821152448.qmoqjh5zznfpdi6n@willie-the-truck> <1566464186.11621.7.camel@mhfsdcap03> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1566464186.11621.7.camel@mhfsdcap03> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 22, 2019 at 04:56:26PM +0800, Yong Wu wrote: > On Wed, 2019-08-21 at 16:24 +0100, Will Deacon wrote: > > On Wed, Aug 21, 2019 at 09:53:12PM +0800, Yong Wu wrote: > > > MediaTek extend the arm v7s descriptor to support up to 34 bits PA where > > > the bit32 and bit33 are encoded in the bit9 and bit4 of the PTE > > > respectively. Meanwhile the iova still is 32bits. > > > > > > Regarding whether the pagetable address could be over 4GB, the mt8183 > > > support it while the previous mt8173 don't, thus keep it as is. > > > > > > Signed-off-by: Yong Wu > > > --- > > > drivers/iommu/io-pgtable-arm-v7s.c | 32 +++++++++++++++++++++++++------- > > > include/linux/io-pgtable.h | 7 +++---- > > > 2 files changed, 28 insertions(+), 11 deletions(-) > > > > [...] > > > > > @@ -731,7 +747,9 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg, > > > { > > > struct arm_v7s_io_pgtable *data; > > > > > > - if (cfg->ias > ARM_V7S_ADDR_BITS || cfg->oas > ARM_V7S_ADDR_BITS) > > > + if (cfg->ias > ARM_V7S_ADDR_BITS || > > > + (cfg->oas > ARM_V7S_ADDR_BITS && > > > + !(cfg->quirks & IO_PGTABLE_QUIRK_ARM_MTK_EXT))) > > > > Please can you instead change arm_v7s_alloc_pgtable() so that it allows an > > ias of up to 34 when the IO_PGTABLE_QUIRK_ARM_MTK_EXT is set? > > Here I only simply skip the oas checking for our case. then which way do > your prefer? something like you commented before:? > > > if (cfg->ias > ARM_V7S_ADDR_BITS) > return NULL; > > if (cfg->quirks & IO_PGTABLE_QUIRK_ARM_MTK_EXT) { > if (!IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT)) > cfg->oas = min(cfg->oas, ARM_V7S_ADDR_BITS); Isn't this always 32 for your IOMMUs? > else if (cfg->oas > 34) > return NULL; > } else if (cfg->oas > ARM_V7S_ADDR_BITS) { > return NULL; > } How about: unsigned int oas_max = ARM_V7S_ADDR_BITS; if (cfg->ias > ARM_V7S_ADDR_BITS) return NULL; if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && cfg->quirks & IO_PGTABLE_QUIRK_ARM_MTK_EXT) oas_max = 34; if (cfg->oas > oas_max) return NULL; Will