Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3891365pxj; Mon, 21 Jun 2021 08:48:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzFeq9JCM2D5N/uD3bj6HAY4gxdZxlT/qH4oA1GfU3UtB8MOc8EG/hpMNcygAR9B1qnaGa X-Received: by 2002:a05:6402:4c5:: with SMTP id n5mr22053709edw.322.1624290481990; Mon, 21 Jun 2021 08:48:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624290481; cv=none; d=google.com; s=arc-20160816; b=Cpfc8LMiP5Bd4I7a0bAOOietWX5WfcqHI+ui6o14p6RW+7YmOi+8tl8TkUPdPhXvkC NN0nTX1xVlkeYQSe0or7KIyb4FLHHaFKX0QXdpRkdgFtSJeB6Z8asFPWN+lqcvD4GZK9 uJemZhkKgTUAF0fdtywhsa8On3GbJwycoIUW3XawaCSmEGu/Bpqnw0nlBD9Tore3QmfX 99FuCaUCHKDr81sBI0yMwfwYUelQ4D8Ba2WdBbaybGfP3fz+ZjnTVglmCsQ6/eG89EBt z0YiRLkgI91UkNfq7PWz8rTUG1uHXfnaHFMQAmLQEMgo4sbqTy5srIZcRiAFz3SOqAsX slgA== 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; bh=w4F7kYaLwJfjmH3/o1p5bczktAhRg5+d+eZRR6g/A2c=; b=BAItdYiF7dXkAtLgMc+GkVEu5k82x/H31Gv7aXaQ51jM5O9vMjghcC9J2ZipfL7sRm vWLYZu997RbyyLwY8ZFwh4ZcJbBKihPHod5uD6DzggxUADTIAqoRVifXgTjpseRxWNPC mzr3KZoQfMZ7i+lJjz/0pU1fCdp0qEysXvMr8Skp8NQeKgrwIQ/r027Y4vPPIplVvcn9 2JWa2ARxhDnLg0zF+eVZjpqNwNJqXekpCQcFQ9MAs2tXbnN06wrXRfSCQY1ppAyqJvcq hVR11OcH4xmWQj3+nN/mkIalu4lxqpgCWzN2qutL1pVwmYAzZHkCcCP5y9kuL4tEQlkB QCNg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bh4si11882638ejb.680.2021.06.21.08.47.39; Mon, 21 Jun 2021 08:48:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhFUPsO (ORCPT + 99 others); Mon, 21 Jun 2021 11:48:14 -0400 Received: from foss.arm.com ([217.140.110.172]:36386 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229837AbhFUPsM (ORCPT ); Mon, 21 Jun 2021 11:48:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A4C051042; Mon, 21 Jun 2021 08:45:57 -0700 (PDT) Received: from [10.57.9.136] (unknown [10.57.9.136]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 44A4D3F694; Mon, 21 Jun 2021 08:45:56 -0700 (PDT) Subject: Re: [PATCHv2 1/3] iommu/io-pgtable: Add a quirk to use tlb_flush_all() for partial walk flush To: Sai Prakash Ranjan , Will Deacon , Joerg Roedel Cc: Thierry Reding , linux-arm-msm@vger.kernel.org, Douglas Anderson , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org References: From: Robin Murphy Message-ID: <904f283c-f8b1-ba84-d010-eacc87bb53c5@arm.com> Date: Mon, 21 Jun 2021 16:45:50 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-06-18 03:51, Sai Prakash Ranjan wrote: > Add a quirk IO_PGTABLE_QUIRK_TLB_INV_ALL to invalidate entire context > with tlb_flush_all() callback in partial walk flush to improve unmap > performance on select few platforms where the cost of over-invalidation > is less than the unmap latency. I still think this doesn't belong anywhere near io-pgtable at all. It's a driver-internal decision how exactly it implements a non-leaf invalidation, and that may be more complex than a predetermined boolean decision. For example, I've just realised for SMMUv3 we can't invalidate multiple levels of table at once with a range command, since if we assume the whole thing is mapped at worst-case page granularity we may fail to invalidate any parts which are mapped as intermediate-level blocks. If invalidating a 1GB region (with 4KB granule) means having to fall back to 256K non-range commands, we may not want to invalidate by VA then, even though doing so for a 2MB region is still optimal. It's also quite feasible that drivers might want to do this for leaf invalidations too - if you don't like issuing 512 commands to invalidate 2MB, do you like issuing 511 commands to invalidate 2044KB? - and at that point the logic really has to be in the driver anyway. Robin. > Signed-off-by: Sai Prakash Ranjan > --- > drivers/iommu/io-pgtable-arm.c | 3 ++- > include/linux/io-pgtable.h | 5 +++++ > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c > index 87def58e79b5..5d362f2214bd 100644 > --- a/drivers/iommu/io-pgtable-arm.c > +++ b/drivers/iommu/io-pgtable-arm.c > @@ -768,7 +768,8 @@ arm_64_lpae_alloc_pgtable_s1(struct io_pgtable_cfg *cfg, void *cookie) > if (cfg->quirks & ~(IO_PGTABLE_QUIRK_ARM_NS | > IO_PGTABLE_QUIRK_NON_STRICT | > IO_PGTABLE_QUIRK_ARM_TTBR1 | > - IO_PGTABLE_QUIRK_ARM_OUTER_WBWA)) > + IO_PGTABLE_QUIRK_ARM_OUTER_WBWA | > + IO_PGTABLE_QUIRK_TLB_INV_ALL)) > return NULL; > > data = arm_lpae_alloc_pgtable(cfg); > diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h > index 4d40dfa75b55..45441592a0e6 100644 > --- a/include/linux/io-pgtable.h > +++ b/include/linux/io-pgtable.h > @@ -82,6 +82,10 @@ struct io_pgtable_cfg { > * > * IO_PGTABLE_QUIRK_ARM_OUTER_WBWA: Override the outer-cacheability > * attributes set in the TCR for a non-coherent page-table walker. > + * > + * IO_PGTABLE_QUIRK_TLB_INV_ALL: Use TLBIALL/TLBIASID to invalidate > + * entire context for partial walk flush to increase unmap > + * performance on select few platforms. > */ > #define IO_PGTABLE_QUIRK_ARM_NS BIT(0) > #define IO_PGTABLE_QUIRK_NO_PERMS BIT(1) > @@ -89,6 +93,7 @@ struct io_pgtable_cfg { > #define IO_PGTABLE_QUIRK_NON_STRICT BIT(4) > #define IO_PGTABLE_QUIRK_ARM_TTBR1 BIT(5) > #define IO_PGTABLE_QUIRK_ARM_OUTER_WBWA BIT(6) > + #define IO_PGTABLE_QUIRK_TLB_INV_ALL BIT(7) > unsigned long quirks; > unsigned long pgsize_bitmap; > unsigned int ias; >