From patchwork Tue Aug 15 21:31:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Zhi A" X-Patchwork-Id: 9901895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C542260244 for ; Tue, 15 Aug 2017 13:32:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8693287F0 for ; Tue, 15 Aug 2017 13:32:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD91C287FB; Tue, 15 Aug 2017 13:32:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=2.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 65B9B287F0 for ; Tue, 15 Aug 2017 13:32:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE1076E2B6; Tue, 15 Aug 2017 13:32:32 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 184966E2B5; Tue, 15 Aug 2017 13:32:30 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Aug 2017 06:32:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,377,1498546800"; d="scan'208";a="300352116" Received: from zhiwang1-mobl.bj.intel.com ([10.238.154.56]) by fmsmga004.fm.intel.com with ESMTP; 15 Aug 2017 06:32:28 -0700 From: Zhi Wang To: intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org Date: Wed, 16 Aug 2017 05:31:11 +0800 Message-Id: <1502832675-6123-4-git-send-email-zhi.a.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502832675-6123-1-git-send-email-zhi.a.wang@intel.com> References: <1502832675-6123-1-git-send-email-zhi.a.wang@intel.com> Subject: [Intel-gfx] [RFC 3/7] drm/i915: Introduce GEN8 {set, get} private PAT index ops X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Introduce operations of {set, get} private PAT index to decode and encode the private PAT index in a guest/shadow PPGTT page table entry. Signed-off-by: Zhi Wang --- drivers/gpu/drm/i915/gvt/gtt.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/gtt.h | 3 +++ 2 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c index 16bfca9..c630015 100644 --- a/drivers/gpu/drm/i915/gvt/gtt.c +++ b/drivers/gpu/drm/i915/gvt/gtt.c @@ -378,6 +378,42 @@ static void gtt_entry_clear_present(struct intel_gvt_gtt_entry *e) } /* + * For GEN8 platform. + * PAT: bit 7, PCD: bit 4, PWT: bit 3. + * Index: index = 4 * PAT + 2 * PCD + PWT + */ +static unsigned int gen8_get_pat_index(struct intel_gvt_gtt_entry *e) +{ + u8 index = 0; + + if (_PAGE_PWT & e->val64) + index |= (1 << 0); + + if (_PAGE_PCD & e->val64) + index |= (1 << 1); + + if (_PAGE_PAT & e->val64) + index |= (1 << 2); + + return index; +} + +static void gen8_set_pat_index(struct intel_gvt_gtt_entry *e, + unsigned int index) +{ + e->val64 &= ~(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT); + + if (index & (1 << 0)) + e->val64 |= _PAGE_PWT; + + if (index & (1 << 1)) + e->val64 |= _PAGE_PCD; + + if (index & (1 << 2)) + e->val64 |= _PAGE_PAT; +} + +/* * Per-platform GMA routines. */ static unsigned long gma_to_ggtt_pte_index(unsigned long gma) @@ -484,6 +520,8 @@ static struct intel_gvt_gtt_pte_ops gen8_gtt_pte_ops = { .test_pse = gen8_gtt_test_pse, .get_pfn = gen8_gtt_get_pfn, .set_pfn = gen8_gtt_set_pfn, + .get_pat_index = gen8_get_pat_index, + .set_pat_index = gen8_set_pat_index, }; static struct intel_gvt_gtt_gma_ops gen8_gtt_gma_ops = { diff --git a/drivers/gpu/drm/i915/gvt/gtt.h b/drivers/gpu/drm/i915/gvt/gtt.h index 7a9eb05..02f6bd9 100644 --- a/drivers/gpu/drm/i915/gvt/gtt.h +++ b/drivers/gpu/drm/i915/gvt/gtt.h @@ -66,6 +66,9 @@ struct intel_gvt_gtt_pte_ops { bool (*test_pse)(struct intel_gvt_gtt_entry *e); void (*set_pfn)(struct intel_gvt_gtt_entry *e, unsigned long pfn); unsigned long (*get_pfn)(struct intel_gvt_gtt_entry *e); + unsigned int (*get_pat_index)(struct intel_gvt_gtt_entry *e); + void (*set_pat_index)(struct intel_gvt_gtt_entry *e, + unsigned int index); }; struct intel_gvt_gtt_gma_ops {