From: Daniel Vetter Subject: Re: [PATCH 5/7] intel_gtt: Properly support gen6+ GTT PTEs Date: Mon, 2 Sep 2013 09:14:24 +0200 Message-ID: <20130902071424.GQ9374@phenom.ffwll.local> References: <1378065086-28705-1-git-send-email-benjamin.widawsky@intel.com> <1378065086-28705-5-git-send-email-benjamin.widawsky@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com [74.125.83.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 72F35E63CC for ; Mon, 2 Sep 2013 00:14:11 -0700 (PDT) Received: by mail-ee0-f42.google.com with SMTP id b45so2173086eek.1 for ; Mon, 02 Sep 2013 00:14:10 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1378065086-28705-5-git-send-email-benjamin.widawsky@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Ben Widawsky Cc: intel-gfx@lists.freedesktop.org, Ben Widawsky List-Id: intel-gfx@lists.freedesktop.org On Sun, Sep 01, 2013 at 12:51:24PM -0700, Ben Widawsky wrote: > This finishes the objective in the last patch which was to actually deal > with physical addresses, and not the PTEs. > > GEN6+ Provided support for physical addresses above 4GB. I'm not > actually sure what Ironlake supported, and don't feel like firing up the > timemachine. > > Haswell caveat is coming up next. > > Signed-off-by: Ben Widawsky gen4/5 and pnv/g33 simply have + pae = (phys & 0xf0) << 28; + + return (phys | pae) & ~0xfff; Cheers, Daniel > --- > tools/intel_gtt.c | 26 ++++++++++++++++++-------- > 1 file changed, 18 insertions(+), 8 deletions(-) > > diff --git a/tools/intel_gtt.c b/tools/intel_gtt.c > index 32a6618..874a4f6 100644 > --- a/tools/intel_gtt.c > +++ b/tools/intel_gtt.c > @@ -25,6 +25,8 @@ > * > */ > > +#define __STDC_FORMAT_MACROS > +#include > #include > #include > #include > @@ -37,18 +39,26 @@ > #define KB(x) ((x) * 1024) > #define MB(x) ((x) * 1024 * 1024) > unsigned char *gtt; > +uint32_t devid; > > #define INGTT(offset) (*(volatile uint32_t *)(gtt + (offset) / (KB(4) / 4))) > static uint64_t get_phys(uint32_t pt_offset) > { > - return INGTT(pt_offset); > + uint64_t pae = 0; > + uint64_t phys = INGTT(pt_offset); > + > + if (intel_gen(devid) < 6) > + return phys; > + > + pae = (phys & 0xff0) << 28; > + > + return (phys | pae) & ~0xfff; > } > > int main(int argc, char **argv) > { > struct pci_device *pci_dev; > int start, aper_size; > - uint32_t devid; > int flag[] = { > PCI_DEV_MAP_FLAG_WRITE_COMBINE, > PCI_DEV_MAP_FLAG_WRITABLE, > @@ -94,14 +104,14 @@ int main(int argc, char **argv) > aper_size = pci_dev->regions[2].size; > > for (start = 0; start < aper_size; start += KB(4)) { > - uint32_t start_phys = INGTT(start); > + uint64_t start_phys = get_phys(start); > uint32_t end; > int constant_length = 0; > int linear_length = 0; > > /* Check if it's a linear sequence */ > for (end = start + KB(4); end < aper_size; end += KB(4)) { > - uint32_t end_phys = INGTT(end); > + uint64_t end_phys = get_phys(end); > if (end_phys == start_phys + (end - start)) > linear_length++; > else > @@ -109,7 +119,7 @@ int main(int argc, char **argv) > } > if (linear_length > 0) { > printf("0x%08x - 0x%08x: linear from " > - "0x%08x to 0x%08x\n", > + "0x%" PRIx64 " to 0x%" PRIx64 "\n", > start, end - KB(4), > start_phys, start_phys + (end - start) - KB(4)); > start = end - KB(4); > @@ -118,20 +128,20 @@ int main(int argc, char **argv) > > /* Check if it's a constant sequence */ > for (end = start + KB(4); end < aper_size; end += KB(4)) { > - uint32_t end_phys = INGTT(end); > + uint64_t end_phys = get_phys(end); > if (end_phys == start_phys) > constant_length++; > else > break; > } > if (constant_length > 0) { > - printf("0x%08x - 0x%08x: constant 0x%08x\n", > + printf("0x%08x - 0x%08x: constant 0x%" PRIx64 "\n", > start, end - KB(4), start_phys); > start = end - KB(4); > continue; > } > > - printf("0x%08x: 0x%08x\n", start, start_phys); > + printf("0x%08x: 0x%" PRIx64 "\n", start, start_phys); > } > > return 0; > -- > 1.8.4 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch