Skip to content

Commit

Permalink
event/dlb2: fix disable PASID
Browse files Browse the repository at this point in the history
[ upstream commit 5a68783 ]

In vfio-pci driver when PASID is enabled by default DLB hardware puts
DLB in SIOV mode. This breaks DLB PF-PMD mode. For DLB PF-PMD mode to
function properly PASID needs to be disabled.

In this commit this issue is addressed and PASID is disabled by writing
a zero to PASID control register.

Fixes: 5433956 ("event/dlb2: add eventdev probe")

Signed-off-by: Abdullah Sevincer <[email protected]>
  • Loading branch information
asevince authored and bluca committed Nov 9, 2023
1 parent 8b1dba4 commit 4b65ab8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions drivers/event/dlb2/pf/dlb2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define DLB2_PCI_CAP_ID_MSIX 0x11
#define DLB2_PCI_EXT_CAP_ID_PRI 0x13
#define DLB2_PCI_EXT_CAP_ID_ACS 0xD
#define DLB2_PCI_EXT_CAP_ID_PASID 0x1B /* Process Address Space ID */

#define DLB2_PCI_PRI_CTRL_ENABLE 0x1
#define DLB2_PCI_PRI_ALLOC_REQ 0xC
Expand All @@ -63,6 +64,8 @@
#define DLB2_PCI_ACS_CR 0x8
#define DLB2_PCI_ACS_UF 0x10
#define DLB2_PCI_ACS_EC 0x20
#define DLB2_PCI_PASID_CTRL 0x06 /* PASID control register */
#define DLB2_PCI_PASID_CAP_OFFSET 0x148 /* PASID capability offset */

static int dlb2_pci_find_capability(struct rte_pci_device *pdev, uint32_t id)
{
Expand Down Expand Up @@ -239,12 +242,14 @@ dlb2_pf_reset(struct dlb2_dev *dlb2_dev)
uint16_t rt_ctl_word;
uint32_t pri_reqs_dword;
uint16_t pri_ctrl_word;
uint16_t pasid_ctrl;

int pcie_cap_offset;
int pri_cap_offset;
int msix_cap_offset;
int err_cap_offset;
int acs_cap_offset;
int pasid_cap_offset;
int wait_count;

uint16_t devsta_busy_word;
Expand Down Expand Up @@ -564,6 +569,28 @@ dlb2_pf_reset(struct dlb2_dev *dlb2_dev)
}
}

/* The current Linux kernel vfio driver does not expose PASID capability to
* users. It also enables PASID by default, which breaks DLB PF PMD. We have
* to use the hardcoded offset for now to disable PASID.
*/
pasid_cap_offset = DLB2_PCI_PASID_CAP_OFFSET;

off = pasid_cap_offset + DLB2_PCI_PASID_CTRL;
if (rte_pci_read_config(pdev, &pasid_ctrl, 2, off) != 2)
pasid_ctrl = 0;

if (pasid_ctrl) {
DLB2_INFO(dlb2_dev, "DLB2 disabling pasid...\n");

pasid_ctrl = 0;
ret = rte_pci_write_config(pdev, &pasid_ctrl, 2, off);
if (ret != 2) {
DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
__func__, (int)off);
return ret;
}
}

return 0;
}

Expand Down

0 comments on commit 4b65ab8

Please sign in to comment.