Skip to content

Commit

Permalink
NX: Add NX coprocessor init opal call
Browse files Browse the repository at this point in the history
The read offset (4:11) in Receive FIFO control register is incremented
by FIFO size whenever CRB read by NX. But the index in RxFIFO has to
match with the corresponding entry in FIFO maintained by VAS in kernel.
VAS entry is reset to 0 when opening the receive window during driver
initialization. So when NX842 is reloaded or in kexec boot, possibility
of mismatch between RxFIFO control register and VAS entries in kernel.
It could cause CRB failure / timeout from NX.

This patch adds nx_coproc_init opal call for kernel to initialize
readOffset (4:11) and Queued (15:23) in RxFIFO control register.

Fixes: 3b3c596 ("NX: Add P9 NX support for 842 compression engine")
CC: stable # v5.8+
Signed-off-by: Haren Myneni <haren@us.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
Haren Myneni authored and stewartsmith committed Jun 19, 2018
1 parent 94140db commit 56026a1
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 1 deletion.
36 changes: 36 additions & 0 deletions doc/opal-api/opal_nx_coproc_init-167.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _opal_nx_coproc_init:

OPAL_NX_COPROC_INIT
===================

This OPAL call resets read offset and queued entries in high and normal
priority receive FIFO control registers. The kernel initializes read
offset entry in RXFIFO that it maintains during initialization. So this
register reset is needed for NX module reload or in kexec boot to make sure
read offset value matches with kernel entries. Otherwise NX reads requests
with wrong offset in RxFIFO which could cause NX request failures.

The kernel initiates this call for each coprocessor type such as 842 and
GZIP per NX instance.

Arguments
---------
::

``uint32_t chip_id``
Contains value of the chip number identified at boot time.

``uint32_t pid``
Contains NX coprocessor type (pid from the device tree).

Returns
-------
OPAL_SUCCESS
The call to reset readOffset and queued entries for high and normal
FIFOs was successful.

OPAL_PARAMETER
Indicates invalid chip ID or NX coprocessor type.

OPAL_UNSUPPORTED
Not supported on P7 and P8.
65 changes: 65 additions & 0 deletions hw/nx-compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <cpu.h>
#include <nx.h>
#include <vas.h>
#include <opal.h>

static int nx_cfg_umac_tx_wc(u32 gcid, u64 xcfg)
{
Expand Down Expand Up @@ -206,14 +207,78 @@ int nx_cfg_rx_fifo(struct dt_node *node, const char *compat,
return 0;
}

static int nx_init_fifo_ctrl(u32 gcid, u64 fifo_ctrl)
{
u64 cfg;
int rc = 0;

rc = xscom_read(gcid, fifo_ctrl, &cfg);
if (rc)
return rc;

cfg = SETFIELD(NX_P9_RX_FIFO_CTRL_READ_OFFSET, cfg, 0);
cfg = SETFIELD(NX_P9_RX_FIFO_CTRL_QUEUED, cfg, 0);

rc = xscom_write(gcid, fifo_ctrl, cfg);

return rc;
}


static int opal_nx_coproc_init(u32 gcid, u32 ct)
{
struct proc_chip *chip;
u64 fifo, fifo_hi;
u32 nx_base;
int rc;

if (proc_gen < proc_gen_p9)
return OPAL_UNSUPPORTED;

chip = get_chip(gcid);
if (!chip)
return OPAL_PARAMETER;

nx_base = chip->nx_base;
if (!nx_base)
return OPAL_PARAMETER;

switch (ct) {
case NX_CT_842:
fifo_hi = nx_base + NX_P9_842_HIGH_PRI_RX_FIFO_CTRL;
fifo = nx_base + NX_P9_842_NORMAL_PRI_RX_FIFO_CTRL;
break;
case NX_CT_GZIP:
fifo_hi = nx_base + NX_P9_GZIP_HIGH_PRI_RX_FIFO_CTRL;
fifo = nx_base + NX_P9_GZIP_NORMAL_PRI_RX_FIFO_CTRL;
break;
default:
prlog(PR_EMERG, "OPAL: Unknown NX coprocessor type\n");
return OPAL_PARAMETER;
}

rc = nx_init_fifo_ctrl(gcid, fifo_hi);

if (!rc)
rc = nx_init_fifo_ctrl(gcid, fifo);

return rc;
}

opal_call(OPAL_NX_COPROC_INIT, opal_nx_coproc_init, 2);

void nx_create_compress_node(struct dt_node *node)
{
u32 gcid, pb_base;
struct proc_chip *chip;
int rc;

gcid = dt_get_chip_id(node);
pb_base = dt_get_address(node, 0, NULL);

chip = get_chip(gcid);
chip->nx_base = pb_base;

prlog(PR_INFO, "NX%d: 842 at 0x%x\n", gcid, pb_base);

if (dt_node_is_compatible(node, "ibm,power9-nx")) {
Expand Down
2 changes: 2 additions & 0 deletions include/chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ struct proc_chip {

struct vas *vas;

/* Used by hw/nx-compress.c */
uint64_t nx_base;
/* location code of this chip */
const uint8_t *loc_code;

Expand Down
1 change: 1 addition & 0 deletions include/nx.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
#define NX_P9_GZIP_HIGH_PRI_RX_FIFO_CTRL NX_P9_SAT(0x3, 0x05)
#define NX_P9_842_NORMAL_PRI_RX_FIFO_CTRL NX_P9_SAT(0x3, 0x0c)
#define NX_P9_GZIP_NORMAL_PRI_RX_FIFO_CTRL NX_P9_SAT(0x3, 0x0e)
#define NX_P9_RX_FIFO_CTRL_READ_OFFSET PPC_BITMASK(4, 11)
#define NX_P9_RX_FIFO_CTRL_QUEUED PPC_BITMASK(15, 23)
#define NX_P9_RX_FIFO_CTRL_HPRI_MAX_READ PPC_BITMASK(27, 35)

Expand Down
3 changes: 2 additions & 1 deletion include/opal-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@
#define OPAL_PCI_GET_PBCQ_TUNNEL_BAR 164
#define OPAL_PCI_SET_PBCQ_TUNNEL_BAR 165
#define OPAL_HANDLE_HMI2 166
#define OPAL_LAST 166
#define OPAL_NX_COPROC_INIT 167
#define OPAL_LAST 167

#define QUIESCE_HOLD 1 /* Spin all calls at entry */
#define QUIESCE_REJECT 2 /* Fail all calls with OPAL_BUSY */
Expand Down

0 comments on commit 56026a1

Please sign in to comment.