All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: "Michał Winiarski" <michal.winiarski@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [PATCH v3 09/20] drm/xe/device: Introduce xe_device_probe_early
Date: Wed, 15 Nov 2023 14:41:29 +0000	[thread overview]
Message-ID: <ZVTYmdJKiPJJGRUt@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20231114130231.2299661-10-michal.winiarski@intel.com>

On Tue, Nov 14, 2023 at 02:02:20PM +0100, Michał Winiarski wrote:
> SR-IOV VF doesn't have access to MMIO registers used to determine
> graphics/media ID. It can however communicate with GuC.
> Introduce xe_device_probe_early, which initializes enough HW to use
> MMIO GuC communication.
> This will allow both VF and PF/native driver to have unified probe
> ordering.
> 
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>

Reviewed-by: Matthew Brost <matthew.brost@intel.com>

> ---
> v1 -> v2:
> - Add comment to "early" variant (Lucas)
> 
>  drivers/gpu/drm/xe/xe_device.c | 22 ++++++++++++++++++----
>  drivers/gpu/drm/xe/xe_device.h |  5 +++++
>  drivers/gpu/drm/xe/xe_mmio.c   | 16 ++++++++++------
>  drivers/gpu/drm/xe/xe_mmio.h   |  1 +
>  drivers/gpu/drm/xe/xe_pci.c    | 22 +++++++++++++++++++---
>  5 files changed, 53 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index 3a98e7b502190..6fe669fdf1c0a 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -364,6 +364,24 @@ static int xe_set_dma_info(struct xe_device *xe)
>  	return err;
>  }
>  
> +/*
> + * Initialize MMIO resources that don't require any knowledge about tile count.
> + */
> +int xe_device_probe_early(struct xe_device *xe)
> +{
> +	int err;
> +
> +	err = xe_mmio_init(xe);
> +	if (err)
> +		return err;
> +
> +	err = xe_mmio_root_tile_init(xe);
> +	if (err)
> +		return err;
> +
> +	return 0;
> +}
> +
>  int xe_device_probe(struct xe_device *xe)
>  {
>  	struct xe_tile *tile;
> @@ -382,10 +400,6 @@ int xe_device_probe(struct xe_device *xe)
>  	if (err)
>  		return err;
>  
> -	err = xe_mmio_init(xe);
> -	if (err)
> -		return err;
> -
>  	xe_mmio_probe_tiles(xe);
>  
>  	err = drmm_add_action_or_reset(&xe->drm, xe_driver_flr_fini, xe);
> diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
> index c4232de40ae08..b80230c631068 100644
> --- a/drivers/gpu/drm/xe/xe_device.h
> +++ b/drivers/gpu/drm/xe/xe_device.h
> @@ -37,6 +37,7 @@ static inline struct xe_device *ttm_to_xe_device(struct ttm_device *ttm)
>  
>  struct xe_device *xe_device_create(struct pci_dev *pdev,
>  				   const struct pci_device_id *ent);
> +int xe_device_probe_early(struct xe_device *xe);
>  int xe_device_probe(struct xe_device *xe);
>  void xe_device_remove(struct xe_device *xe);
>  void xe_device_shutdown(struct xe_device *xe);
> @@ -123,6 +124,10 @@ static inline bool xe_device_uc_enabled(struct xe_device *xe)
>  	for ((id__) = 0; (id__) < (xe__)->info.tile_count; (id__)++) \
>  		for_each_if((tile__) = &(xe__)->tiles[(id__)])
>  
> +#define for_each_remote_tile(tile__, xe__, id__) \
> +	for ((id__) = 1; (id__) < (xe__)->info.tile_count; (id__)++) \
> +		for_each_if((tile__) = &(xe__)->tiles[(id__)])
> +
>  /*
>   * FIXME: This only works for now since multi-tile and standalone media
>   * happen to be mutually exclusive.  Future platforms may change this...
> diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
> index acf6dfca0bc46..8eb19a4bca9c6 100644
> --- a/drivers/gpu/drm/xe/xe_mmio.c
> +++ b/drivers/gpu/drm/xe/xe_mmio.c
> @@ -15,10 +15,12 @@
>  #include "regs/xe_regs.h"
>  #include "xe_bo.h"
>  #include "xe_device.h"
> +#include "xe_ggtt.h"
>  #include "xe_gt.h"
>  #include "xe_gt_mcr.h"
>  #include "xe_macros.h"
>  #include "xe_module.h"
> +#include "xe_tile.h"
>  
>  #define XEHP_MTCFG_ADDR		XE_REG(0x101800)
>  #define TILE_COUNT		REG_GENMASK(15, 8)
> @@ -375,10 +377,8 @@ static int xe_verify_lmem_ready(struct xe_device *xe)
>  
>  int xe_mmio_init(struct xe_device *xe)
>  {
> -	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
>  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
>  	const int mmio_bar = 0;
> -	int err;
>  
>  	/*
>  	 * Map the entire BAR.
> @@ -392,12 +392,16 @@ int xe_mmio_init(struct xe_device *xe)
>  		return -EIO;
>  	}
>  
> -	err = drmm_add_action_or_reset(&xe->drm, mmio_fini, xe);
> -	if (err)
> -		return err;
> +	return drmm_add_action_or_reset(&xe->drm, mmio_fini, xe);
> +}
> +
> +int xe_mmio_root_tile_init(struct xe_device *xe)
> +{
> +	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
> +	int err;
>  
>  	/* Setup first tile; other tiles (if present) will be setup later. */
> -	root_tile->mmio.size = xe->mmio.size;
> +	root_tile->mmio.size = SZ_16M;
>  	root_tile->mmio.regs = xe->mmio.regs;
>  
>  	err = xe_verify_lmem_ready(xe);
> diff --git a/drivers/gpu/drm/xe/xe_mmio.h b/drivers/gpu/drm/xe/xe_mmio.h
> index 9f1a25cfd2cf0..74976af15ea60 100644
> --- a/drivers/gpu/drm/xe/xe_mmio.h
> +++ b/drivers/gpu/drm/xe/xe_mmio.h
> @@ -21,6 +21,7 @@ struct xe_device;
>  #define GEN12_LMEM_BAR		2
>  
>  int xe_mmio_init(struct xe_device *xe);
> +int xe_mmio_root_tile_init(struct xe_device *xe);
>  void xe_mmio_probe_tiles(struct xe_device *xe);
>  
>  static inline u8 xe_mmio_read8(struct xe_gt *gt, struct xe_reg reg)
> diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
> index c50cc3f7cbe06..a1026b7ee4727 100644
> --- a/drivers/gpu/drm/xe/xe_pci.c
> +++ b/drivers/gpu/drm/xe/xe_pci.c
> @@ -537,10 +537,12 @@ static void handle_gmdid(struct xe_device *xe,
>   * Initialize device info content that only depends on static driver_data passed to the driver at
>   * probe time from PCI ID table.
>   */
> -static void xe_info_init_early(struct xe_device *xe,
> +static int xe_info_init_early(struct xe_device *xe,
>  			       const struct xe_device_desc *desc,
>  			       const struct xe_subplatform_desc *subplatform_desc)
>  {
> +	int err;
> +
>  	xe->info.platform = desc->platform;
>  	xe->info.subplatform = subplatform_desc ?
>  		subplatform_desc->subplatform : XE_SUBPLATFORM_NONE;
> @@ -554,6 +556,12 @@ static void xe_info_init_early(struct xe_device *xe,
>  	xe->info.enable_display = IS_ENABLED(CONFIG_DRM_XE_DISPLAY) &&
>  				  enable_display &&
>  				  desc->has_display;
> +
> +	err = xe_tile_init_early(xe_device_get_root_tile(xe), xe, 0);
> +	if (err)
> +		return err;
> +
> +	return 0;
>  }
>  
>  /*
> @@ -621,13 +629,15 @@ static int xe_info_init(struct xe_device *xe,
>  	 */
>  	xe->info.tile_count = 1 + graphics_desc->max_remote_tiles;
>  
> -	for_each_tile(tile, xe, id) {
> +	for_each_remote_tile(tile, xe, id) {
>  		int err;
>  
>  		err = xe_tile_init_early(tile, xe, id);
>  		if (err)
>  			return err;
> +	}
>  
> +	for_each_tile(tile, xe, id) {
>  		gt = tile->primary_gt;
>  		gt->info.id = xe->info.gt_count++;
>  		gt->info.type = XE_GT_TYPE_MAIN;
> @@ -727,7 +737,13 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	pci_set_master(pdev);
>  	devm_add_action(&pdev->dev, xe_pci_clear_master, pdev);
>  
> -	xe_info_init_early(xe, desc, subplatform_desc);
> +	err = xe_info_init_early(xe, desc, subplatform_desc);
> +	if (err)
> +		return err;
> +
> +	err = xe_device_probe_early(xe);
> +	if (err)
> +		return err;
>  
>  	err = xe_info_init(xe, desc, subplatform_desc);
>  	if (err)
> -- 
> 2.42.1
> 

  reply	other threads:[~2023-11-15 21:43 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14 13:02 [Intel-xe] [PATCH v3 00/20] drm/xe: Probe tweaks and reordering Michał Winiarski
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 01/20] drm/xe: Skip calling drm_dev_put on probe error Michał Winiarski
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 02/20] drm/xe: Use managed pci_enable_device Michał Winiarski
2023-11-15 20:47   ` Matt Roper
2023-11-21 12:45     ` Michał Winiarski
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 03/20] drm/xe/irq: Don't call pci_free_irq_vectors Michał Winiarski
2023-11-15 20:49   ` Matt Roper
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 04/20] drm/xe: Move xe_set_dma_info outside of MMIO setup Michał Winiarski
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 05/20] drm/xe: Move xe_mmio_probe_tiles " Michał Winiarski
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 06/20] drm/xe: Split xe_info_init Michał Winiarski
2023-11-20 19:47   ` Lucas De Marchi
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 07/20] drm/xe: Introduce xe_tile_init_early and use at earlier point in probe Michał Winiarski
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 08/20] drm/xe: Map the entire BAR0 and hold onto the initial mapping Michał Winiarski
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 09/20] drm/xe/device: Introduce xe_device_probe_early Michał Winiarski
2023-11-15 14:41   ` Matthew Brost [this message]
2023-11-15 21:31   ` Matt Roper
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 10/20] drm/xe: Don't "peek" into GMD_ID Michał Winiarski
2023-11-15 14:45   ` Matthew Brost
2023-11-15 21:51   ` Matt Roper
2023-11-20 19:57     ` Lucas De Marchi
2023-11-21 13:27       ` Michał Winiarski
2023-11-21 16:54         ` Lucas De Marchi
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 11/20] drm/xe: Move system memory management init to earlier point in probe Michał Winiarski
2023-11-15 21:55   ` Matt Roper
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 12/20] drm/xe: Move force_wake " Michał Winiarski
2023-11-15 21:59   ` Matt Roper
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 13/20] drm/xe: Reorder GGTT " Michał Winiarski
2023-11-15 22:19   ` Matt Roper
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 14/20] drm/xe/uc: Split xe_uc_fw_init Michał Winiarski
2023-11-15 22:28   ` Matt Roper
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 15/20] drm/xe/uc: Store firmware binary in system-memory backed BO Michał Winiarski
2023-11-15 22:34   ` Matt Roper
2023-11-20 20:04   ` Lucas De Marchi
2023-11-20 21:34     ` Daniele Ceraolo Spurio
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 16/20] drm/xe/uc: Extract xe_uc_sanitize_reset Michał Winiarski
2023-11-16 12:56   ` Matthew Brost
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 17/20] drm/xe/guc: Split GuC params used for "hwconfig" and "post-hwconfig" Michał Winiarski
2023-11-20 13:25   ` Matthew Brost
2023-11-20 20:09   ` Lucas De Marchi
2023-11-21 13:36     ` Michał Winiarski
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 18/20] drm/xe/guc: Allocate GuC data structures in system memory for initial load Michał Winiarski
2023-11-20 20:20   ` Lucas De Marchi
2023-11-21 13:42     ` Michał Winiarski
2023-11-21 16:49       ` Lucas De Marchi
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 19/20] drm/xe/guc: Move GuC power control init to "post-hwconfig" Michał Winiarski
2023-11-20 13:30   ` Matthew Brost
2023-11-14 13:02 ` [Intel-xe] [PATCH v3 20/20] drm/xe: Initialize GuC earlier during probe Michał Winiarski
2023-11-15 15:09   ` Matthew Brost
2023-11-21 16:07     ` Michał Winiarski
2023-11-14 13:07 ` [Intel-xe] ✓ CI.Patch_applied: success for drm/xe: Probe tweaks and reordering (rev2) Patchwork
2023-11-14 13:08 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-11-14 13:09 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-11-14 13:16 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-11-14 13:16 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-11-14 13:18 ` [Intel-xe] ✓ CI.checksparse: " Patchwork
2023-11-14 13:51 ` [Intel-xe] ✓ CI.BAT: " Patchwork

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=ZVTYmdJKiPJJGRUt@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=michal.winiarski@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.