All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Dani Liberman <dliberman@habana.ai>
Cc: <intel-xe@lists.freedesktop.org>, <illevi@habana.ai>
Subject: Re: [PATCH 1/8] drm/xe/irq: refactor irq flows to support also msix
Date: Wed, 26 Jun 2024 11:03:05 -0400	[thread overview]
Message-ID: <ZnwtqcykLb1E0wq3@intel.com> (raw)
In-Reply-To: <20240626103345.2801735-2-dliberman@habana.ai>

On Wed, Jun 26, 2024 at 01:33:38PM +0300, Dani Liberman wrote:
> When enabling MSIX, there is no need for HW to aggregate interrupts.
> Added a separate MSIX flow that skips unnecessary code in irq init,
> reset, and fini.
> 
> Signed-off-by: Dani Liberman <dliberman@habana.ai>

just a heads up that I just pushed this patch:
https://patchwork.freedesktop.org/patch/597392/

so I believe you might need to rebase.

Cc: Ilia Levi <illevi@habana.ai>

> ---
>  drivers/gpu/drm/xe/xe_device_types.h |  2 +
>  drivers/gpu/drm/xe/xe_irq.c          | 99 +++++++++++++++++++++-------
>  2 files changed, 77 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
> index c37be471d11c..09ce7ba1b4ed 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -306,6 +306,8 @@ struct xe_device {
>  
>  		/** @irq.enabled: interrupts enabled on this device */
>  		bool enabled;
> +		/** @irq.msix_enabled: msix interrupts enabled on this device */
> +		bool msix_enabled;
>  	} irq;
>  
>  	/** @ttm: ttm device */
> diff --git a/drivers/gpu/drm/xe/xe_irq.c b/drivers/gpu/drm/xe/xe_irq.c
> index ab3d5b7a1e8c..663a86edecc0 100644
> --- a/drivers/gpu/drm/xe/xe_irq.c
> +++ b/drivers/gpu/drm/xe/xe_irq.c
> @@ -666,28 +666,46 @@ static irq_handler_t xe_irq_handler(struct xe_device *xe)
>  		return xelp_irq_handler;
>  }
>  
> -static void irq_uninstall(void *arg)
> +static void xe_irq_msi_free(struct xe_device *xe)
>  {
> -	struct xe_device *xe = arg;
>  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
>  	int irq;
>  
> +	irq = pci_irq_vector(pdev, 0);
> +	free_irq(irq, xe);
> +}
> +
> +static void xe_irq_msix_free(struct xe_device *xe)
> +{
> +
> +}
> +
> +static void xe_irq_free(struct xe_device *xe)
> +{
> +	if (xe->irq.msix_enabled)
> +		xe_irq_msix_free(xe);
> +	else
> +		xe_irq_msi_free(xe);
> +}
> +
> +static void irq_uninstall(void *arg)
> +{
> +	struct xe_device *xe = arg;
> +
>  	if (!xe->irq.enabled)
>  		return;
>  
>  	xe->irq.enabled = false;
>  	xe_irq_reset(xe);
>  
> -	irq = pci_irq_vector(pdev, 0);
> -	free_irq(irq, xe);
> +	xe_irq_free(xe);
>  }
>  
> -int xe_irq_install(struct xe_device *xe)
> +static int xe_irq_msi_request(struct xe_device *xe)
>  {
>  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> -	unsigned int irq_flags = PCI_IRQ_MSIX;
>  	irq_handler_t irq_handler;
> -	int err, irq, nvec;
> +	int irq, err;
>  
>  	irq_handler = xe_irq_handler(xe);
>  	if (!irq_handler) {
> @@ -695,32 +713,55 @@ int xe_irq_install(struct xe_device *xe)
>  		return -EINVAL;
>  	}
>  
> -	xe_irq_reset(xe);
> +	irq = pci_irq_vector(pdev, 0);
> +	err = request_irq(irq, irq_handler, IRQF_SHARED, DRIVER_NAME, xe);
> +	if (err < 0) {
> +		drm_err(&xe->drm, "Failed to request MSI IRQ %d\n", err);
> +		return err;
> +	}
> +
> +	return 0;
> +}
> +
> +static int xe_irq_msix_request(struct xe_device *xe)
> +{
> +	return 0;
> +}
> +
> +int xe_irq_install(struct xe_device *xe)
> +{
> +	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> +	unsigned int irq_flags = PCI_IRQ_MSIX;
> +
> +	int err, nvec;
>  
>  	nvec = pci_msix_vec_count(pdev);
> -	if (nvec <= 0) {
> -		if (nvec == -EINVAL) {
> -			/* MSIX capability is not supported in the device, using MSI */
> -			irq_flags = PCI_IRQ_MSI;
> -			nvec = 1;
> -		} else {
> -			drm_err(&xe->drm, "MSIX: Failed getting count\n");
> -			return nvec;
> -		}
> +	if (nvec > 0) {
> +		xe->irq.msix_enabled = true;
> +	} else if (nvec == -EINVAL) {
> +		/* MSIX capability is not supported in the device, using MSI */
> +		irq_flags = PCI_IRQ_MSI;
> +		nvec = 1;
> +	} else {
> +		drm_err(&xe->drm, "MSIX: Failed getting count\n");
> +		return nvec;
>  	}
>  
> +	xe_irq_reset(xe);
> +
>  	err = pci_alloc_irq_vectors(pdev, nvec, nvec, irq_flags);
>  	if (err < 0) {
>  		drm_err(&xe->drm, "MSI/MSIX: Failed to enable support %d\n", err);
>  		return err;
>  	}
>  
> -	irq = pci_irq_vector(pdev, 0);
> -	err = request_irq(irq, irq_handler, IRQF_SHARED, DRIVER_NAME, xe);
> -	if (err < 0) {
> -		drm_err(&xe->drm, "Failed to request MSI/MSIX IRQ %d\n", err);
> +	if (xe->irq.msix_enabled)
> +		err = xe_irq_msix_request(xe);
> +	else
> +		err = xe_irq_msi_request(xe);
> +
> +	if (err)
>  		return err;
> -	}
>  
>  	xe->irq.enabled = true;
>  
> @@ -733,7 +774,7 @@ int xe_irq_install(struct xe_device *xe)
>  	return 0;
>  
>  free_irq_handler:
> -	free_irq(irq, xe);
> +	xe_irq_free(xe);
>  
>  	return err;
>  }
> @@ -743,6 +784,11 @@ void xe_irq_shutdown(struct xe_device *xe)
>  	irq_uninstall(xe);
>  }
>  
> +static void xe_irq_msix_synchronize_irq(struct xe_device *xe)
> +{
> +
> +}
> +
>  void xe_irq_suspend(struct xe_device *xe)
>  {
>  	int irq = to_pci_dev(xe->drm.dev)->irq;
> @@ -751,7 +797,12 @@ void xe_irq_suspend(struct xe_device *xe)
>  	xe->irq.enabled = false; /* no new irqs */
>  	spin_unlock_irq(&xe->irq.lock);
>  
> -	synchronize_irq(irq); /* flush irqs */
> +	/* flush irqs */
> +	if (xe->irq.msix_enabled)
> +		xe_irq_msix_synchronize_irq(xe);
> +	else
> +		synchronize_irq(irq);
> +
>  	xe_irq_reset(xe); /* turn irqs off */
>  }
>  
> -- 
> 2.34.1
> 

  reply	other threads:[~2024-06-26 15:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26 10:33 [PATCH 0/8] Add MSIX functionality to XE Dani Liberman
2024-06-26 10:33 ` [PATCH 1/8] drm/xe/irq: refactor irq flows to support also msix Dani Liberman
2024-06-26 15:03   ` Rodrigo Vivi [this message]
2024-06-26 10:33 ` [PATCH 2/8] drm/xe/irq: add msix allocator Dani Liberman
2024-06-26 10:33 ` [PATCH 3/8] drm/xe/irq: add hw engine irq handler Dani Liberman
2024-06-26 10:33 ` [PATCH 4/8] drm/xe/exec: adding msix infra to exec queue Dani Liberman
2024-06-26 10:33 ` [PATCH 5/8] drm/xe: move the kernel lrc from hwe to execlist port Dani Liberman
2024-06-26 10:33 ` [PATCH 6/8] drm/xe: move memirq out of vf Dani Liberman
2024-06-26 10:33 ` [PATCH 7/8] drm/xe: msix support preparations - enable memirq Dani Liberman
2024-06-26 10:33 ` [PATCH 8/8] drm/xe: msix support for hw engines Dani Liberman
2024-06-26 10:50   ` Nirmoy Das
2024-06-27  8:36     ` Ilia Levi
2024-06-26 10:39 ` ✓ CI.Patch_applied: success for Add MSIX functionality to XE Patchwork
2024-06-26 10:39 ` ✗ CI.checkpatch: warning " Patchwork
2024-06-26 10:40 ` ✓ CI.KUnit: success " Patchwork
2024-06-26 10:52 ` ✓ CI.Build: " Patchwork
2024-06-26 10:55 ` ✗ CI.Hooks: failure " Patchwork
2024-06-26 10:56 ` ✓ CI.checksparse: success " Patchwork
2024-06-26 11:21 ` ✓ CI.BAT: " Patchwork
2024-06-26 14:25 ` ✓ CI.FULL: " 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=ZnwtqcykLb1E0wq3@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=dliberman@habana.ai \
    --cc=illevi@habana.ai \
    --cc=intel-xe@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 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.