ibmvnic: Do partial reset on login failure
authorNick Child <nnac123@linux.ibm.com>
Wed, 9 Aug 2023 22:10:37 +0000 (17:10 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Aug 2023 16:27:29 +0000 (18:27 +0200)
commit206ccf4f0977a76da38c2c88ba354d7eea9bbf81
tree4df3fd2f72601b6c57556b52e8662999343b1f6e
parent31ccd1ba20d8007e13f0b3175b7c394d900759f2
ibmvnic: Do partial reset on login failure

commit 23cc5f667453ca7645a24c8d21bf84dbf61107b2 upstream.

Perform a partial reset before sending a login request if any of the
following are true:
 1. If a previous request times out. This can be dangerous because the
  VIOS could still receive the old login request at any point after
  the timeout. Therefore, it is best to re-register the CRQ's  and
  sub-CRQ's before retrying.
 2. If the previous request returns an error that is not described in
  PAPR. PAPR provides procedures if the login returns with partial
  success or aborted return codes (section L.5.1) but other values
do not have a defined procedure. Previously, these conditions
just returned error from the login function rather than trying
to resolve the issue.
  This can cause further issues since most callers of the login
  function are not prepared to handle an error when logging in. This
  improper cleanup can lead to the device being permanently DOWN'd.
  For example, if the VIOS believes that the device is already logged
  in then it will return INVALID_STATE (-7). If we never re-register
  CRQ's then it will always think that the device is already logged
  in. This leaves the device inoperable.

The partial reset involves freeing the sub-CRQs, freeing the CRQ then
registering and initializing a new CRQ and sub-CRQs. This essentially
restarts all communication with VIOS to allow for a fresh login attempt
that will be unhindered by any previous failed attempts.

Fixes: dff515a3e71d ("ibmvnic: Harden device login requests")
Signed-off-by: Nick Child <nnac123@linux.ibm.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230809221038.51296-4-nnac123@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/ibm/ibmvnic.c