public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: Ben Widawsky <benjamin.widawsky@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel GFX <intel-gfx@lists.freedesktop.org>,
	Ben Widawsky <ben@bwidawsk.net>
Subject: Re: [PATCH 18/62] drm/i915/bdw: Make gen8_gmch_probe
Date: Tue, 05 Nov 2013 00:01:53 +0200	[thread overview]
Message-ID: <1383602513.4073.7.camel@ideak-mobl> (raw)
In-Reply-To: <1383451680-11173-19-git-send-email-benjamin.widawsky@intel.com>

On Sat, 2013-11-02 at 21:07 -0700, Ben Widawsky wrote:
> Probing gen8 is similar to gen6. To make the code cleaner and more
> maintainable however we can use the probe functions to split it out.
> 
> v2: Rebased on top of update gtt probe infrastructure.
> 
> v3: Rebased on top of Kenneth' Graunke's ->pte_encode refactoring.
> 
> V4: Resolve conflicts with Ben's latest ppgtt patches, also switch to
> gen < 8 testing instead of gen <= 7.
> 
> v5: Resolve conflicts with address space vfunc changes in upstream.
> 
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net> (v1)
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 92 +++++++++++++++++++++++++++----------
>  1 file changed, 68 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 19016b7..c6d38d0 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -892,6 +892,66 @@ static inline size_t gen8_get_stolen_size(u16 bdw_gmch_ctl)
>  	return bdw_gmch_ctl << 25; /* 32 MB units */
>  }
>  
> +static int ggtt_probe_common(struct drm_device *dev,
> +			     size_t gtt_size)
> +{
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +	phys_addr_t gtt_bus_addr;
> +	int ret;
> +
> +	/* For Modern GENs the PTEs and register space are split in the BAR */
> +	gtt_bus_addr = pci_resource_start(dev->pdev, 0) +
> +		(pci_resource_len(dev->pdev, 0) / 2);
> +
> +	dev_priv->gtt.gsm = ioremap_wc(gtt_bus_addr, gtt_size);
> +	if (!dev_priv->gtt.gsm) {
> +		DRM_ERROR("Failed to map the gtt page table\n");
> +		return -ENOMEM;
> +	}
> +
> +	ret = setup_scratch_page(dev);
> +	if (ret) {
> +		DRM_ERROR("Scratch setup failed\n");
> +		/* iounmap will also get called at remove, but meh */
> +		iounmap(dev_priv->gtt.gsm);
> +	}
> +
> +	return ret;
> +}
> +
> +static int gen8_gmch_probe(struct drm_device *dev,
> +			   size_t *gtt_total,
> +			   size_t *stolen,
> +			   phys_addr_t *mappable_base,
> +			   unsigned long *mappable_end)
> +{
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +	unsigned int gtt_size;
> +	u16 snb_gmch_ctl;
> +	int ret;
> +
> +	/* TODO: We're not aware of mappable constraints on gen8 yet */
> +	*mappable_base = pci_resource_start(dev->pdev, 2);
> +	*mappable_end = pci_resource_len(dev->pdev, 2);
> +
> +	if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(40)))
> +		pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(40));

Not that this would be a practical problem, but according to bspec the
maximum physical address size is 39 bits for all PTE formats. Is that a
documentation error? (SNB supported 40 bits)

Other than this the patch looks ok to me:
Reviewed-by: Imre Deak <imre.deak@intel.com>

> +
> +	pci_read_config_word(dev->pdev, SNB_GMCH_CTRL, &snb_gmch_ctl);
> +
> +	*stolen = gen8_get_stolen_size(snb_gmch_ctl);
> +
> +	gtt_size = gen8_get_total_gtt_size(snb_gmch_ctl);
> +	*gtt_total = (gtt_size / 8) << PAGE_SHIFT;
> +
> +	ret = ggtt_probe_common(dev, gtt_size);
> +
> +	dev_priv->gtt.base.clear_range = NULL;
> +	dev_priv->gtt.base.insert_entries = NULL;
> +
> +	return ret;
> +}
> +
>  static int gen6_gmch_probe(struct drm_device *dev,
>  			   size_t *gtt_total,
>  			   size_t *stolen,
> @@ -899,7 +959,6 @@ static int gen6_gmch_probe(struct drm_device *dev,
>  			   unsigned long *mappable_end)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
> -	phys_addr_t gtt_bus_addr;
>  	unsigned int gtt_size;
>  	u16 snb_gmch_ctl;
>  	int ret;
> @@ -920,30 +979,12 @@ static int gen6_gmch_probe(struct drm_device *dev,
>  		pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(40));
>  	pci_read_config_word(dev->pdev, SNB_GMCH_CTRL, &snb_gmch_ctl);
>  
> -	if (IS_GEN8(dev)) {
> -		gtt_size = gen8_get_total_gtt_size(snb_gmch_ctl);
> -		*gtt_total = (gtt_size / 8) << PAGE_SHIFT;
> -		*stolen = gen8_get_stolen_size(snb_gmch_ctl);
> -	} else {
> -		gtt_size = gen6_get_total_gtt_size(snb_gmch_ctl);
> -		*gtt_total = (gtt_size / sizeof(gen6_gtt_pte_t)) << PAGE_SHIFT;
> -		*stolen = gen6_get_stolen_size(snb_gmch_ctl);
> -	}
> -
> -	/* For Modern GENs the PTEs and register space are split in the BAR */
> -	gtt_bus_addr = pci_resource_start(dev->pdev, 0) +
> -		(pci_resource_len(dev->pdev, 0) / 2);
> -
> -	dev_priv->gtt.gsm = ioremap_wc(gtt_bus_addr, gtt_size);
> -	if (!dev_priv->gtt.gsm) {
> -		DRM_ERROR("Failed to map the gtt page table\n");
> -		return -ENOMEM;
> +	*stolen = gen6_get_stolen_size(snb_gmch_ctl);
>  
> -	}
> +	gtt_size = gen6_get_total_gtt_size(snb_gmch_ctl);
> +	*gtt_total = (gtt_size / sizeof(gen6_gtt_pte_t)) << PAGE_SHIFT;
>  
> -	ret = setup_scratch_page(dev);
> -	if (ret)
> -		DRM_ERROR("Scratch setup failed\n");
> +	ret = ggtt_probe_common(dev, gtt_size);
>  
>  	dev_priv->gtt.base.clear_range = gen6_ggtt_clear_range;
>  	dev_priv->gtt.base.insert_entries = gen6_ggtt_insert_entries;
> @@ -997,7 +1038,7 @@ int i915_gem_gtt_init(struct drm_device *dev)
>  	if (INTEL_INFO(dev)->gen <= 5) {
>  		gtt->gtt_probe = i915_gmch_probe;
>  		gtt->base.cleanup = i915_gmch_remove;
> -	} else {
> +	} else if (INTEL_INFO(dev)->gen < 8) {
>  		gtt->gtt_probe = gen6_gmch_probe;
>  		gtt->base.cleanup = gen6_gmch_remove;
>  		if (IS_HASWELL(dev) && dev_priv->ellc_size)
> @@ -1010,6 +1051,9 @@ int i915_gem_gtt_init(struct drm_device *dev)
>  			gtt->base.pte_encode = ivb_pte_encode;
>  		else
>  			gtt->base.pte_encode = snb_pte_encode;
> +	} else {
> +		dev_priv->gtt.gtt_probe = gen8_gmch_probe;
> +		dev_priv->gtt.base.cleanup = gen6_gmch_remove;
>  	}
>  
>  	ret = gtt->gtt_probe(dev, &gtt->base.total, &gtt->stolen_size,

  reply	other threads:[~2013-11-04 22:01 UTC|newest]

Thread overview: 145+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-03  4:06 [PATCH 00/62] Broadwell kernel driver support Ben Widawsky
2013-11-03  4:06 ` [PATCH 01/62] drm/i915/bdw: IS_GEN8 definition Ben Widawsky
2013-11-03  4:07 ` [PATCH 02/62] drm/i915/bdw: Handle forcewake for writes on gen8 Ben Widawsky
2013-11-04 14:19   ` Chris Wilson
2013-11-05  9:24   ` Mika Kuoppala
2013-11-03  4:07 ` [PATCH 03/62] drm/i915/bdw: Disable PPGTT for now Ben Widawsky
2013-11-04 14:44   ` Chris Wilson
2013-11-03  4:07 ` [PATCH 04/62] drm/i915/bdw: Add device IDs Ben Widawsky
2013-11-03 21:58   ` Chris Wilson
2013-11-04  0:36     ` [PATCH 04/62] [v6] " Ben Widawsky
2013-11-04 14:49       ` Chris Wilson
2013-11-04 15:49         ` Daniel Vetter
2013-11-04 16:04           ` Chris Wilson
2013-11-04 16:56         ` Ben Widawsky
2013-11-04  0:43     ` [PATCH 04/62] " Ben Widawsky
2013-11-04  0:47     ` [PATCH 04/62] [v7] " Ben Widawsky
2013-11-05 14:45       ` Mika Kuoppala
2013-11-03  4:07 ` [PATCH 05/62] drm/i915/bdw: Fences on gen8 look just like gen7 Ben Widawsky
2013-11-03  4:07 ` [PATCH 06/62] drm/i915/bdw: Swizzling support Ben Widawsky
2013-11-05  9:59   ` Mika Kuoppala
2013-11-03  4:07 ` [PATCH 07/62] drm/i915/bdw: HW context support Ben Widawsky
2013-11-03  4:07 ` [PATCH 08/62] drm/i915/bdw: Clock gating init Ben Widawsky
2013-11-03  4:07 ` [PATCH 09/62] drm/i915/bdw: display stuff Ben Widawsky
2013-11-06  8:13   ` Daniel Vetter
2013-11-03  4:07 ` [PATCH 10/62] drm/i915/bdw: support GMS and GGMS changes Ben Widawsky
2013-11-04  0:53   ` [PATCH 10/62] [v5] " Ben Widawsky
2013-11-03  4:07 ` [PATCH 11/62] drm/i915/bdw: Implement interrupt changes Ben Widawsky
2013-11-06  8:39   ` Daniel Vetter
2013-11-03  4:07 ` [PATCH 12/62] drm/i915/bdw: Add interrupt info to debugfs Ben Widawsky
2013-11-03  4:07 ` [PATCH 13/62] drm/i915/bdw: Support 64b relocations Ben Widawsky
2013-11-03  4:07 ` [PATCH 14/62] drm/i915/bdw: dispatch updates (64b related) Ben Widawsky
2013-11-05 15:50   ` Paulo Zanoni
2013-11-03  4:07 ` [PATCH 15/62] drm/i915/bdw: Update MI_FLUSH_DW Ben Widawsky
2013-11-03  4:07 ` [PATCH 16/62] drm/i915/bdw: debugfs updates Ben Widawsky
2013-11-04 14:28   ` Chris Wilson
2013-11-05  3:03     ` Ben Widawsky
2013-11-05 16:40   ` Paulo Zanoni
2013-11-03  4:07 ` [PATCH 17/62] drm/i915/bdw: Update relevant error state Ben Widawsky
2013-11-05 17:03   ` Paulo Zanoni
2013-11-03  4:07 ` [PATCH 18/62] drm/i915/bdw: Make gen8_gmch_probe Ben Widawsky
2013-11-04 22:01   ` Imre Deak [this message]
2013-11-05  3:32     ` [PATCH 18/62] [v6] " Ben Widawsky
2013-11-03  4:07 ` [PATCH 19/62] drm/i915/bdw: Create gen8_gtt_pte_t Ben Widawsky
2013-11-04 14:36   ` Chris Wilson
2013-11-04 22:03   ` Imre Deak
2013-11-03  4:07 ` [PATCH 20/62] drm/i915/bdw: Add GTT functions Ben Widawsky
2013-11-04 22:22   ` Imre Deak
2013-11-06  8:28   ` Bloomfield, Jon
2013-11-03  4:07 ` [PATCH 21/62] drm/i915/bdw: Support BDW caching Ben Widawsky
2013-11-04 14:39   ` Chris Wilson
2013-11-05  3:56     ` [PATCH 21/62] [v4] " Ben Widawsky
2013-11-05 15:19   ` [PATCH 21/62] " Imre Deak
2013-11-03  4:07 ` [PATCH 22/62] drm/i915/bdw: Implement Full Force Miss disables Ben Widawsky
2013-11-05 15:41   ` Imre Deak
2013-11-05 16:17     ` Daniel Vetter
2013-11-06  9:33       ` Daniel Vetter
2013-11-03  4:07 ` [PATCH 23/62] drm/i915/bdw: PPGTT init & cleanup Ben Widawsky
2013-11-04 14:58   ` Imre Deak
2013-11-05  4:47     ` [PATCH] " Ben Widawsky
2013-11-03  4:07 ` [PATCH 24/62] drm/i915/bdw: Initialize the PDEs Ben Widawsky
2013-11-04 14:10   ` Damien Lespiau
2013-11-05  5:20     ` [PATCH 24/62] [v3] " Ben Widawsky
2013-11-03  4:07 ` [PATCH 25/62] drm/i915/bdw: Implement PPGTT clear range Ben Widawsky
2013-11-03  4:07 ` [PATCH 26/62] drm/i915/bdw: Implement PPGTT insert Ben Widawsky
2013-11-03  4:07 ` [PATCH 27/62] drm/i915/bdw: Implement PPGTT enable Ben Widawsky
2013-11-04 14:47   ` Damien Lespiau
2013-11-05  6:29     ` [PATCH 27/62] [v7] " Ben Widawsky
2013-11-03  4:07 ` [PATCH 28/62] drm/i915/bdw: unleash PPGTT Ben Widawsky
2013-11-03  4:07 ` [PATCH 29/62] drm/i915/bdw: Render ring flushing Ben Widawsky
2013-11-03  4:07 ` [PATCH 30/62] drm/i915/bdw: BSD init for gen8 also Ben Widawsky
2013-11-03  4:07 ` [PATCH 31/62] drm/i915/bdw: Don't muck with gtt_size on Gen8 when PPGTT setup fails Ben Widawsky
2013-11-03  4:07 ` [PATCH 32/62] drm/i915/bdw: ppgtt info in debugfs Ben Widawsky
2013-11-03  4:07 ` [PATCH 33/62] drm/i915/bdw: add IS_BROADWELL macro Ben Widawsky
2013-11-03  4:07 ` [PATCH 34/62] drm/i915/bdw: Broadwell has 3 pipes Ben Widawsky
2013-11-03  4:07 ` [PATCH 35/62] drm/i915/bdw: add Broadwell sprite/plane/cursor checks Ben Widawsky
2013-11-03  4:07 ` [PATCH 36/62] drm/i915/bdw: Broadwell also has the "power down well" Ben Widawsky
2013-11-03 11:05   ` Ville Syrjälä
2013-11-03 11:24     ` Daniel Vetter
2013-11-03 11:25       ` Ville Syrjälä
2013-11-03  4:07 ` [PATCH 37/62] drm/i915/bdw: pretend we have LPT LP on Broadwell Ben Widawsky
2013-11-03 11:19   ` Ville Syrjälä
2013-11-03  4:07 ` [PATCH 38/62] drm/i915/bdw: get the correct LCPLL frequency " Ben Widawsky
2013-11-03 11:07   ` Ville Syrjälä
2013-11-03  4:07 ` [PATCH 39/62] drm/i915/bdw: on Broadwell, the panel fitter is on the pipe Ben Widawsky
2013-11-03 11:19   ` Ville Syrjälä
2013-11-03  4:07 ` [PATCH 40/62] drm/i915/bdw: Broadwell has PIPEMISC Ben Widawsky
2013-11-03 11:11   ` Ville Syrjälä
2013-11-03  4:07 ` [PATCH 41/62] drm/i915/bdw: Use pipe CSC on Broadwell Ben Widawsky
2013-11-03  4:07 ` [PATCH 42/62] drm/i915/bdw: Implement WaSwitchSolVfFArbitrationPriority Ben Widawsky
2013-11-03 11:07   ` Ville Syrjälä
2013-11-03 17:44     ` Ben Widawsky
2013-11-04 14:23       ` Ville Syrjälä
2013-11-03  4:07 ` [PATCH 43/62] drm/i915/bdw: Add BDW DDI buffer translation values Ben Widawsky
2013-11-04 23:59   ` Ben Widawsky
2013-11-03  4:07 ` [PATCH 44/62] drm/i915/bdw: add BDW DDI buf translations for eDP Ben Widawsky
2013-11-05  0:09   ` Ben Widawsky
2013-11-03  4:07 ` [PATCH 45/62] drm/i915/bdw: add support for BDW DP voltage swings and pre-emphasis Ben Widawsky
2013-11-05  0:45   ` Ben Widawsky
2013-11-05 13:01     ` Paulo Zanoni
2013-11-06  3:15       ` Todd Previte
2013-11-03  4:07 ` [PATCH 46/62] drm/i915/bdw: BDW also has only 2 FDI lanes Ben Widawsky
2013-11-03  4:07 ` [PATCH 47/62] drm/i915/bdw: check DPD on port D when setting the DDI buffers Ben Widawsky
2013-11-05  0:46   ` Ben Widawsky
2013-11-03  4:07 ` [PATCH 48/62] drm/i915/bdw: Add Broadwell display FIFO limits Ben Widawsky
2013-11-04  9:39   ` Jani Nikula
2013-11-04 13:59     ` Ville Syrjälä
2013-11-03  4:07 ` [PATCH 49/62] drm/i915/bdw: Use The GT mailbox for IPS enable/disable Ben Widawsky
2013-11-04 10:15   ` Jani Nikula
2013-11-03  4:07 ` [PATCH 50/62] drm/i915/bdw: Support eDP PSR Ben Widawsky
2013-11-04 10:34   ` Jani Nikula
2013-11-05  6:45     ` [PATCH 50/62] [v5] " Ben Widawsky
2014-03-04  9:31       ` Kumar, Kiran S
2014-03-05  6:31         ` Ben Widawsky
2013-11-03  4:07 ` [PATCH 51/62] drm/i915/bdw: Use HSW formula for ring freq scaling Ben Widawsky
2013-11-06 13:34   ` Daniel Vetter
2013-11-03  4:07 ` [PATCH 52/62] drm/i915/bdw: Don't wait for c0 threads on forcewake Ben Widawsky
2013-11-04 13:47   ` Jani Nikula
2013-11-03  4:07 ` [PATCH 53/62] drm/i915/bdw: Broadwell has a max port clock of 300Mhz on HDMI Ben Widawsky
2013-11-04 13:33   ` Jani Nikula
2013-11-03  4:07 ` [PATCH 54/62] drm/i915/bdw: Create a separate BDW rps enable Ben Widawsky
2013-11-04 21:04   ` Jesse Barnes
2013-11-03  4:07 ` [PATCH 55/62] drm/i915/bdw: Disable semaphores Ben Widawsky
2013-11-04 18:18   ` Jesse Barnes
2013-11-05  3:45     ` [PATCH 55/62] [v2] " Ben Widawsky
2013-11-03  4:07 ` [PATCH 56/62] drm/i915/bdw: Implement edp PSR workarounds Ben Widawsky
2013-11-05 17:19   ` Jesse Barnes
2013-11-06 15:44   ` Daniel Vetter
2013-11-03  4:07 ` [PATCH 57/62] drm/i915/bdw: BWGTLB clock gate disable Ben Widawsky
2013-11-05 17:22   ` Jesse Barnes
2013-11-03  4:07 ` [PATCH 58/62] drm/i915/bdw: Disable centroid pixel perf optimization Ben Widawsky
2013-11-04 13:20   ` Paulo Zanoni
2013-11-05  6:52     ` [PATCH] " Ben Widawsky
2013-11-05 17:24       ` Jesse Barnes
2013-11-03  4:07 ` [PATCH 59/62] drm/i915/bdw: Sampler power bypass disable Ben Widawsky
2013-11-03  4:07 ` [PATCH 60/62] drm/i915/bdw: Limit SDE poly depth FIFO to 2 Ben Widawsky
2013-11-03  4:07 ` [PATCH 61/62] drm/i915/bdw: conservative SBE VUE cache mode Ben Widawsky
2013-11-03  4:08 ` [PATCH 62/62] drm/i915/bdw: WaSingleSubspanDispatchOnAALinesAndPoints Ben Widawsky
2013-11-03  8:45 ` [PATCH 00/62] Broadwell kernel driver support Daniel Vetter
2013-11-04 14:15   ` Jani Nikula
2013-11-04 15:04   ` Damien Lespiau
2013-11-05 15:14   ` Daniel Vetter
2013-11-05 15:54   ` Imre Deak
2013-11-03 11:47 ` [PATCH 63/62] drm/i915/bdw: Enable trickle feed on Broadwell ville.syrjala
2013-11-04 15:05   ` Damien Lespiau
2013-11-05  7:11 ` [PATCH 64/62] drm/i915/bdw: Change dp aux timeout to 600us on DDIA Ben Widawsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383602513.4073.7.camel@ideak-mobl \
    --to=imre.deak@intel.com \
    --cc=ben@bwidawsk.net \
    --cc=benjamin.widawsky@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox