Skip to content

Commit

Permalink
npu2: Allow ATSD for LPAR other than 0
Browse files Browse the repository at this point in the history
Each XTS MMIO ATSD# register is accompanied by another register -
XTS MMIO ATSD0 LPARID# - which controls LPID filtering for ATSD
transactions.

When a host system passes a GPU through to a guest, we need to enable
some ATSD for an LPAR. At the moment the host assigns one ATSD to
a NVLink bridge and this maps it to an LPAR when GPU is assigned to
the LPAR. The link number is used for an ATSD index.

ATSD6&7 stay mapped to the host (LPAR=0) all the time which seems to be
acceptable price for the simplicity.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
aik authored and stewartsmith committed Feb 26, 2019
1 parent ba1d95a commit c0f17ca
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 21 additions & 1 deletion hw/npu2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2219,9 +2219,15 @@ static int opal_npu_map_lpar(uint64_t phb_id, uint64_t bdf, uint64_t lparid,
struct phb *phb = pci_get_phb(phb_id);
struct npu2 *p;
struct npu2_dev *ndev = NULL;
uint64_t xts_bdf_lpar, rc = OPAL_SUCCESS;
uint64_t xts_bdf_lpar, atsd_lpar, rc = OPAL_SUCCESS;
int i;
int id;
static uint64_t atsd_lpar_regs[] = {
NPU2_XTS_MMIO_ATSD0_LPARID, NPU2_XTS_MMIO_ATSD1_LPARID,
NPU2_XTS_MMIO_ATSD2_LPARID, NPU2_XTS_MMIO_ATSD3_LPARID,
NPU2_XTS_MMIO_ATSD4_LPARID, NPU2_XTS_MMIO_ATSD5_LPARID,
NPU2_XTS_MMIO_ATSD6_LPARID, NPU2_XTS_MMIO_ATSD7_LPARID
};

if (!phb || phb->phb_type != phb_type_npu_v2)
return OPAL_PARAMETER;
Expand Down Expand Up @@ -2275,6 +2281,20 @@ static int opal_npu_map_lpar(uint64_t phb_id, uint64_t bdf, uint64_t lparid,
goto out;
}

/*
* We need to allocate an ATSD per NVLink bridge if possible,
* use the ibm,npu-link-index property for that.
*/
atsd_lpar = SETFIELD(NPU2_XTS_MMIO_ATSD_LPARID, 0, lparid);
if (!lparid)
atsd_lpar = SETFIELD(NPU2_XTS_MMIO_ATSD_MSR_HV, atsd_lpar, 1);

if (ndev->link_index < ARRAY_SIZE(atsd_lpar_regs))
npu2_write(p, atsd_lpar_regs[ndev->link_index], atsd_lpar);
else
NPU2ERR(p, "Unable to assign ATSD for link index %u\n",
ndev->link_index);

xts_bdf_lpar = SETFIELD(NPU2_XTS_BDF_MAP_STACK, xts_bdf_lpar,
0x4 >> (ndev->brick_index / 2));
xts_bdf_lpar = SETFIELD(NPU2_XTS_BDF_MAP_BRICK, xts_bdf_lpar,
Expand Down
2 changes: 2 additions & 0 deletions include/npu2-regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@ void npu2_scom_write(uint64_t gcid, uint64_t scom_base,
#define NPU2_XTS_MMIO_ATSD5_LPARID NPU2_REG_OFFSET(NPU2_STACK_MISC, NPU2_BLOCK_XTS, 0x128)
#define NPU2_XTS_MMIO_ATSD6_LPARID NPU2_REG_OFFSET(NPU2_STACK_MISC, NPU2_BLOCK_XTS, 0x130)
#define NPU2_XTS_MMIO_ATSD7_LPARID NPU2_REG_OFFSET(NPU2_STACK_MISC, NPU2_BLOCK_XTS, 0x138)
#define NPU2_XTS_MMIO_ATSD_MSR_HV PPC_BIT(51)
#define NPU2_XTS_MMIO_ATSD_LPARID PPC_BITMASK(52, 63)
#define NPU2_XTS_BDF_MAP NPU2_REG_OFFSET(NPU2_STACK_MISC, NPU2_BLOCK_XTS, 0x4000)
#define NPU2_XTS_BDF_MAP_VALID PPC_BIT(0)
#define NPU2_XTS_BDF_MAP_UNFILT PPC_BIT(1)
Expand Down

0 comments on commit c0f17ca

Please sign in to comment.