From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2B74C433DB for ; Fri, 8 Jan 2021 14:10:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 823AD22A99 for ; Fri, 8 Jan 2021 14:10:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbhAHOKT (ORCPT ); Fri, 8 Jan 2021 09:10:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:43686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbhAHOKS (ORCPT ); Fri, 8 Jan 2021 09:10:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0268E22525; Fri, 8 Jan 2021 14:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610114977; bh=fjs87wmD1dhPTR3MDXSplx7dascsW/EY1STyOCAmXes=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kmWvRbk9mV7sNidMTbEW/3w5cx8bPc12n+7n7z/hFgGQWU7aZmKrx++KoYtd4OaFX taVIFEYO3Xz0sTR4zRGZ1qvBSEAYTYi70BtMlj9APaO5D0eJj4hjRVTNvrJRfEk+GJ quAK16/5j1/lSq57NaGJo5GWgNukj+PD1LunPd08CFC4MfxlV9OuB4QedvuptGm9Q7 O4jGrscXHjgRms6vKJhc3twlp87R0ld3iT2zUiRmsST2eHpXzzNqSNpZK2s3w364YV ODP4n9CsGhvvf7a7J/lY0cYk/vtVgMZQgqpivwFhwCRKk4FyYXePF18voOoLT0Tg9E hEvJSMHxsZQFg== Date: Fri, 8 Jan 2021 14:09:32 +0000 From: Will Deacon To: Lu Baolu Cc: Joerg Roedel , Ashok Raj , Jacob Pan , Guo Kaijie , Liu Yi L , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/5] iommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev() Message-ID: <20210108140932.GA4811@willie-the-truck> References: <20201231005323.2178523-1-baolu.lu@linux.intel.com> <20201231005323.2178523-2-baolu.lu@linux.intel.com> <20210105190357.GA12182@willie-the-truck> <9b26b7ac-b5c7-f38a-a078-b53a6b6bf375@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9b26b7ac-b5c7-f38a-a078-b53a6b6bf375@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lu, On Fri, Jan 08, 2021 at 07:52:47AM +0800, Lu Baolu wrote: > On 2021/1/6 9:09, Lu Baolu wrote: > > On 2021/1/6 3:03, Will Deacon wrote: > > > On Thu, Dec 31, 2020 at 08:53:20AM +0800, Lu Baolu wrote: > > > > @@ -170,6 +172,22 @@ static void intel_flush_svm_range_dev > > > > (struct intel_svm *svm, struct intel_svm_d > > > >       } > > > >   } > > > > +static void intel_flush_svm_range_dev(struct intel_svm *svm, > > > > +                      struct intel_svm_dev *sdev, > > > > +                      unsigned long address, > > > > +                      unsigned long pages, int ih) > > > > +{ > > > > +    unsigned long shift = ilog2(__roundup_pow_of_two(pages)); > > > > +    unsigned long align = (1ULL << (VTD_PAGE_SHIFT + shift)); > > > > +    unsigned long start = ALIGN_DOWN(address, align); > > > > +    unsigned long end = ALIGN(address + (pages << > > > > VTD_PAGE_SHIFT), align); > > > > + > > > > +    while (start < end) { > > > > +        __flush_svm_range_dev(svm, sdev, start, align >> > > > > VTD_PAGE_SHIFT, ih); > > > > +        start += align; > > > > +    } > > > > +} > > > > > > Given that this only seems to be called from > > > intel_invalidate_range(), which > > > has to compute 'pages' only to have it pulled apart again here, > > > perhaps it > > > would be cleaner for intel_flush_svm_range() to take something like an > > > 'order' argument instead? > > > > > > What do you think? > > > > We need to clean up here. It's duplicate with the qi_flush_piotlb() > > helper. I have a patch under testing for this. I will post it for review > > later. > > I'm sorry, above reply is a little vague. > > I meant to say, let's take 'pages' as the argument. We are going to use > qi_flush_piotlb() here to avoid duplicate QI interactions. The > qi_flush_piotlb() helper also takes 'pages', so keep 'pages' here will > make things easier. > > My cleanup patch is for v5.12. Can you please take this for v5.11? Ah sorry, I didn't realise that was your plan. Please just include this patch in a series of 2 when you post a fixed version of the trace event removal and then I'll queue them up next week, as I've already prepared the pull for today. Apologies, Will