Commit 087e89b6 authored by Fenghua Yu's avatar Fenghua Yu Committed by Vinod Koul
Browse files

dmaengine: idxd: Add idxd_pci_probe_alloc() helper



Add the idxd_pci_probe_alloc() helper to probe IDXD PCI device with or
without allocating and setting idxd software values.

The idxd_pci_probe() function is refactored to call this helper and
always probe the IDXD device with allocating and setting the software
values.

This helper will be called later in the Function Level Reset (FLR)
process without modifying the idxd software data.

Signed-off-by: default avatarFenghua Yu <fenghua.yu@intel.com>
Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20241122233028.2762809-2-fenghua.yu@intel.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 5d667003
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -740,6 +740,8 @@ void idxd_unmask_error_interrupts(struct idxd_device *idxd);

/* device control */
int idxd_device_drv_probe(struct idxd_dev *idxd_dev);
int idxd_pci_probe_alloc(struct idxd_device *idxd, struct pci_dev *pdev,
			 const struct pci_device_id *id);
void idxd_device_drv_remove(struct idxd_dev *idxd_dev);
int idxd_drv_enable_wq(struct idxd_wq *wq);
void idxd_drv_disable_wq(struct idxd_wq *wq);
+62 −40
Original line number Diff line number Diff line
@@ -725,17 +725,30 @@ static void idxd_cleanup(struct idxd_device *idxd)
		idxd_disable_sva(idxd->pdev);
}

static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
/*
 * Probe idxd PCI device.
 * If idxd is not given, need to allocate idxd and set up its data.
 *
 * If idxd is given, idxd was allocated and setup already. Just need to
 * configure device without re-allocating and re-configuring idxd data.
 * This is useful for recovering from FLR.
 */
int idxd_pci_probe_alloc(struct idxd_device *idxd, struct pci_dev *pdev,
			 const struct pci_device_id *id)
{
	struct device *dev = &pdev->dev;
	struct idxd_device *idxd;
	struct idxd_driver_data *data = (struct idxd_driver_data *)id->driver_data;
	bool alloc_idxd = idxd ? false : true;
	struct idxd_driver_data *data;
	struct device *dev;
	int rc;

	pdev = idxd ? idxd->pdev : pdev;
	dev = &pdev->dev;
	data = id ? (struct idxd_driver_data *)id->driver_data : NULL;
	rc = pci_enable_device(pdev);
	if (rc)
		return rc;

	if (alloc_idxd) {
		dev_dbg(dev, "Alloc IDXD context\n");
		idxd = idxd_alloc(pdev, data);
		if (!idxd) {
@@ -754,11 +767,13 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
		rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
		if (rc)
			goto err;
	}

	dev_dbg(dev, "Set PCI master\n");
	pci_set_master(pdev);
	pci_set_drvdata(pdev, idxd);

	if (alloc_idxd) {
		idxd->hw.version = ioread32(idxd->reg_base + IDXD_VER_OFFSET);
		rc = idxd_probe(idxd);
		if (rc) {
@@ -781,10 +796,12 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
		rc = idxd_device_init_debugfs(idxd);
		if (rc)
			dev_warn(dev, "IDXD debugfs failed to setup\n");
	}

	dev_info(&pdev->dev, "Intel(R) Accelerator Device (v%x)\n",
		 idxd->hw.version);

	if (data)
		idxd->user_submission_safe = data->user_submission_safe;

	return 0;
@@ -800,6 +817,11 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	return rc;
}

static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
	return idxd_pci_probe_alloc(NULL, pdev, id);
}

void idxd_wqs_quiesce(struct idxd_device *idxd)
{
	struct idxd_wq *wq;