mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-28 00:19:36 +00:00

The s390x ISM device data sheet clearly states that only one
request-response sequence is allowable per ISM function at any point in
time. Unfortunately as of today the s390/ism driver in Linux does not
honor that requirement. This patch aims to rectify that.
This problem was discovered based on Aliaksei's bug report which states
that for certain workloads the ISM functions end up entering error state
(with PEC 2 as seen from the logs) after a while and as a consequence
connections handled by the respective function break, and for future
connection requests the ISM device is not considered -- given it is in a
dysfunctional state. During further debugging PEC 3A was observed as
well.
A kernel message like
[ 1211.244319] zpci: 061a:00:00.0: Event 0x2 reports an error for PCI function 0x61a
is a reliable indicator of the stated function entering error state
with PEC 2. Let me also point out that a kernel message like
[ 1211.244325] zpci: 061a:00:00.0: The ism driver bound to the device does not support error recovery
is a reliable indicator that the ISM function won't be auto-recovered
because the ISM driver currently lacks support for it.
On a technical level, without this synchronization, commands (inputs to
the FW) may be partially or fully overwritten (corrupted) by another CPU
trying to issue commands on the same function. There is hard evidence that
this can lead to DMB token values being used as DMB IOVAs, leading to
PEC 2 PCI events indicating invalid DMA. But this is only one of the
failure modes imaginable. In theory even completely losing one command
and executing another one twice and then trying to interpret the outputs
as if the command we intended to execute was actually executed and not
the other one is also possible. Frankly, I don't feel confident about
providing an exhaustive list of possible consequences.
Fixes: 684b89bc39
("s390/ism: add device driver for internal shared memory")
Reported-by: Aliaksei Makarau <Aliaksei.Makarau@ibm.com>
Tested-by: Mahanta Jambigi <mjambigi@linux.ibm.com>
Tested-by: Aliaksei Makarau <Aliaksei.Makarau@ibm.com>
Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250722161817.1298473-1-wintera@linux.ibm.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
94 lines
2.2 KiB
C
94 lines
2.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Internal Shared Memory
|
|
*
|
|
* Definitions for the ISM module
|
|
*
|
|
* Copyright IBM Corp. 2022
|
|
*/
|
|
#ifndef _ISM_H
|
|
#define _ISM_H
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
struct ism_dmb {
|
|
u64 dmb_tok;
|
|
u64 rgid;
|
|
u32 dmb_len;
|
|
u32 sba_idx;
|
|
u32 vlan_valid;
|
|
u32 vlan_id;
|
|
void *cpu_addr;
|
|
dma_addr_t dma_addr;
|
|
};
|
|
|
|
/* Unless we gain unexpected popularity, this limit should hold for a while */
|
|
#define MAX_CLIENTS 8
|
|
#define ISM_NR_DMBS 1920
|
|
|
|
struct ism_dev {
|
|
spinlock_t lock; /* protects the ism device */
|
|
spinlock_t cmd_lock; /* serializes cmds */
|
|
struct list_head list;
|
|
struct pci_dev *pdev;
|
|
|
|
struct ism_sba *sba;
|
|
dma_addr_t sba_dma_addr;
|
|
DECLARE_BITMAP(sba_bitmap, ISM_NR_DMBS);
|
|
u8 *sba_client_arr; /* entries are indices into 'clients' array */
|
|
void *priv[MAX_CLIENTS];
|
|
|
|
struct ism_eq *ieq;
|
|
dma_addr_t ieq_dma_addr;
|
|
|
|
struct device dev;
|
|
u64 local_gid;
|
|
int ieq_idx;
|
|
|
|
struct ism_client *subs[MAX_CLIENTS];
|
|
};
|
|
|
|
struct ism_event {
|
|
u32 type;
|
|
u32 code;
|
|
u64 tok;
|
|
u64 time;
|
|
u64 info;
|
|
};
|
|
|
|
struct ism_client {
|
|
const char *name;
|
|
void (*add)(struct ism_dev *dev);
|
|
void (*remove)(struct ism_dev *dev);
|
|
void (*handle_event)(struct ism_dev *dev, struct ism_event *event);
|
|
/* Parameter dmbemask contains a bit vector with updated DMBEs, if sent
|
|
* via ism_move_data(). Callback function must handle all active bits
|
|
* indicated by dmbemask.
|
|
*/
|
|
void (*handle_irq)(struct ism_dev *dev, unsigned int bit, u16 dmbemask);
|
|
/* Private area - don't touch! */
|
|
u8 id;
|
|
};
|
|
|
|
int ism_register_client(struct ism_client *client);
|
|
int ism_unregister_client(struct ism_client *client);
|
|
static inline void *ism_get_priv(struct ism_dev *dev,
|
|
struct ism_client *client) {
|
|
return dev->priv[client->id];
|
|
}
|
|
|
|
static inline void ism_set_priv(struct ism_dev *dev, struct ism_client *client,
|
|
void *priv) {
|
|
dev->priv[client->id] = priv;
|
|
}
|
|
|
|
int ism_register_dmb(struct ism_dev *dev, struct ism_dmb *dmb,
|
|
struct ism_client *client);
|
|
int ism_unregister_dmb(struct ism_dev *dev, struct ism_dmb *dmb);
|
|
int ism_move(struct ism_dev *dev, u64 dmb_tok, unsigned int idx, bool sf,
|
|
unsigned int offset, void *data, unsigned int size);
|
|
|
|
const struct smcd_ops *ism_get_smcd_ops(void);
|
|
|
|
#endif /* _ISM_H */
|