Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2013444imm; Mon, 16 Jul 2018 00:01:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeYJvZhSe98aegTAgP4xK7avygPBL6nKFhabREEZeZbOUt9VQCGcuInrnuxsi+5BlHGfM5j X-Received: by 2002:a62:229a:: with SMTP id p26-v6mr16904490pfj.53.1531724484460; Mon, 16 Jul 2018 00:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531724484; cv=none; d=google.com; s=arc-20160816; b=lHUbG4X/CaOeWRUvXOFwkveVk1xbxBYt+XLeoY9GKR9WtvHjl+ivKaoXXP5uJ1dPhk cCzElcjEHBsr04KizXMF7LEmzSiGmhjYDVlf7ll+KPEYjVcAiv4myG6iZODCjrZQYyp+ 3hydfJNj9tl6dv0Av7l8ZQRGkwbgKKdCuv/uQcRzdK/gEQMaw+qa9L94Jm2k4jZ3qmtK Yq1FCfOW6Ok38NhEJghN5Cuj9jW5r//fPrzuPCDB3P7LcPdboLTY+TqhptrJskek0qkx pBZ+//gi45jPJrm2fC6ca4F9r/N3xXTp3/XweqmDInX7Erybmn7P6HQ5kpPxPXzyQr/v 7lWw== 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=zFMEhzcjCoLfbgP6GO7bucJwJDC9i9HZ0fRZLLUlpTU=; b=PcWMxyYUKXp7rs3DlHLErRKCA2m7rWa0l26+zJl7Awgi2IXWkNX65p+xlRXNDWOuhj G1zWnqibI7ynmFOI5IyC17AzPeJCGW2sNtYCCFrCoEC6Hs/S/wEMATYD60hr/2BYi4n3 hv/7iqU1mn2NgH1WBq/Hzhl7KHfN/8frvQnyhRUOPaw+WqMSwn8132SosHZ7s0CgwGbb 59LvXU4TJgWLn999sN7otByI/x6SiC1Ru14Gjvbv2+Agb0BmpO/t9a4YfAWL4rZapKhP RQkkAn7TTzZJErcPrK56BUIADvvr7K/TxPomJbuKTMXZhwlHLs9yEYbQRt/3oTVpjh/5 dUFA== 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 h5-v6si32564826pfd.112.2018.07.16.00.01.09; Mon, 16 Jul 2018 00:01:24 -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 S1729793AbeGPH0N (ORCPT + 99 others); Mon, 16 Jul 2018 03:26:13 -0400 Received: from mga14.intel.com ([192.55.52.115]:45301 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727540AbeGPH0M (ORCPT ); Mon, 16 Jul 2018 03:26:12 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 00:00:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,360,1526367600"; d="scan'208";a="72647265" Received: from allen-box.sh.intel.com ([10.239.48.172]) by fmsmga001.fm.intel.com with ESMTP; 16 Jul 2018 00:00:18 -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, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu , Jacob Pan Subject: [PATCH 03/10] iommu/vt-d: Move page table helpers into header Date: Mon, 16 Jul 2018 14:49:46 +0800 Message-Id: <1531723793-14607-4-git-send-email-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531723793-14607-1-git-send-email-baolu.lu@linux.intel.com> References: <1531723793-14607-1-git-send-email-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 f9036c8..a139a45 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) } /* - * 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. * 2. It maps to each iommu if successful. diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index 4124cd9..7818b1c 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.7.4