Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp208247imm; Wed, 29 Aug 2018 18:39:51 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdapy0U/yCluPJMFWaqbFzEJffjRGdEdc55mvHqLmGdbraJAPu5yVVv8YfZgLWVE9u3ua1G8 X-Received: by 2002:a63:5660:: with SMTP id g32-v6mr7544223pgm.227.1535593191349; Wed, 29 Aug 2018 18:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535593191; cv=none; d=google.com; s=arc-20160816; b=j5DVLeVGnNi7rqW1+4TcyONGkMeFQjluVfTFBUo/55ncl6tSWoruyWF7v/CMbiQPVY XQgRJEAdorWcppQDcJea1dJg7AbC4m25vpfHYv9v2YmSdNmokrKhRtHAXu2Q7y3Ln+j3 yIO/0PV9IO52mQZzlPfr81wU0vsqOZWZOID7IW1Il4yL9C9/AozqXSr698eWJowmITNZ oD7oLGU2eF3SjMydvcrPhXyXOe53ajLrIGnPwl53lrB7w3zhOhqLd3Bik45mylmiN5IP jgSonsTRTAezKdKCkbehqihFl7IWwBlaZ7KswPfRKqyChuhvv719G6fp8s3v5YPQdM9n zcdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=EgA3BLx4dxyywNBRYUp8VqNLuu8PfgH2RwEWRnC69UU=; b=f4kyGyDNJTYXC0uyWSJg7/p/V0FjbCHY7x5VfW1/nTK7ViNW9NDcTTUFz0nulXydsg S2yybS2ALH/81LBmYmc/pfcw24YzhsCwpa4QjcfYqFMEYHK3W4QonJVXelu3Y53Ijoep hV/AXVOyk9s/74duUTmwRGL/Qr68aFKPu33p6NfgVN81K/H0KSJdoQIJKtTYuzlEEb4Z qImDiUdygZkDJXv90oJlAxELfqLJbW9nn1rVkmEtI0N/Qqdpad9RlZFUpn2rgkMMKp2F Qa0kXIMSzYr+nDQpitKnSBempIWVmW2jybHJ4RYS4TlahNvKsRZK0Fm5xtTX7IOpN1DE +g/A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9-v6si5232773pgh.500.2018.08.29.18.38.52; Wed, 29 Aug 2018 18:39:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727372AbeH3FgZ (ORCPT + 99 others); Thu, 30 Aug 2018 01:36:25 -0400 Received: from mga11.intel.com ([192.55.52.93]:9350 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbeH3FgY (ORCPT ); Thu, 30 Aug 2018 01:36:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2018 18:36:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,305,1531810800"; d="scan'208";a="79442248" Received: from allen-box.sh.intel.com ([10.239.161.122]) by orsmga003.jf.intel.com with ESMTP; 29 Aug 2018 18:36:39 -0700 From: Lu Baolu To: Joerg Roedel , David Woodhouse Cc: ashok.raj@intel.com, sanjay.k.kumar@intel.com, jacob.jun.pan@intel.com, kevin.tian@intel.com, yi.l.liu@intel.com, yi.y.sun@intel.com, peterx@redhat.com, Jean-Philippe Brucker , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu , Jacob Pan Subject: [PATCH v2 03/12] iommu/vt-d: Move page table helpers into header Date: Thu, 30 Aug 2018 09:35:15 +0800 Message-Id: <20180830013524.28743-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830013524.28743-1-baolu.lu@linux.intel.com> References: <20180830013524.28743-1-baolu.lu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So that they could also be used in other source files. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Lu Baolu Reviewed-by: Ashok Raj --- drivers/iommu/intel-iommu.c | 43 ------------------------------------- include/linux/intel-iommu.h | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index b0da4f765274..93cde957adc7 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -315,49 +315,6 @@ static inline void context_clear_entry(struct context_entry *context) context->hi = 0; } -/* - * 0: readable - * 1: writable - * 2-6: reserved - * 7: super page - * 8-10: available - * 11: snoop behavior - * 12-63: Host physcial address - */ -struct dma_pte { - u64 val; -}; - -static inline void dma_clear_pte(struct dma_pte *pte) -{ - pte->val = 0; -} - -static inline u64 dma_pte_addr(struct dma_pte *pte) -{ -#ifdef CONFIG_64BIT - return pte->val & VTD_PAGE_MASK; -#else - /* Must have a full atomic 64-bit read */ - return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; -#endif -} - -static inline bool dma_pte_present(struct dma_pte *pte) -{ - return (pte->val & 3) != 0; -} - -static inline bool dma_pte_superpage(struct dma_pte *pte) -{ - return (pte->val & DMA_PTE_LARGE_PAGE); -} - -static inline int first_pte_in_page(struct dma_pte *pte) -{ - return !((unsigned long)pte & ~VTD_PAGE_MASK); -} - /* * This domain is a statically identity mapping domain. * 1. This domain creats a static 1:1 mapping to all usable memory. diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index 2173ae35f1dc..41791903a5e3 100644 --- a/include/linux/intel-iommu.h +++ b/include/linux/intel-iommu.h @@ -501,6 +501,49 @@ static inline void __iommu_flush_cache( clflush_cache_range(addr, size); } +/* + * 0: readable + * 1: writable + * 2-6: reserved + * 7: super page + * 8-10: available + * 11: snoop behavior + * 12-63: Host physcial address + */ +struct dma_pte { + u64 val; +}; + +static inline void dma_clear_pte(struct dma_pte *pte) +{ + pte->val = 0; +} + +static inline u64 dma_pte_addr(struct dma_pte *pte) +{ +#ifdef CONFIG_64BIT + return pte->val & VTD_PAGE_MASK; +#else + /* Must have a full atomic 64-bit read */ + return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK; +#endif +} + +static inline bool dma_pte_present(struct dma_pte *pte) +{ + return (pte->val & 3) != 0; +} + +static inline bool dma_pte_superpage(struct dma_pte *pte) +{ + return (pte->val & DMA_PTE_LARGE_PAGE); +} + +static inline int first_pte_in_page(struct dma_pte *pte) +{ + return !((unsigned long)pte & ~VTD_PAGE_MASK); +} + extern struct dmar_drhd_unit * dmar_find_matched_drhd_unit(struct pci_dev *dev); extern int dmar_find_matched_atsr_unit(struct pci_dev *dev); -- 2.17.1