summaryrefslogtreecommitdiff
path: root/include/linux/pci_liveupdate.h
blob: bb79348769b722072f04a51efbc765b28aab833d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * PCI Live Update support (Public/Driver API)
 *
 * Copyright (c) 2026, Google LLC.
 * David Matlack <dmatlack@google.com>
 */
#ifndef LINUX_PCI_LIVEUPDATE_H
#define LINUX_PCI_LIVEUPDATE_H

#include <linux/kho/abi/pci.h>
#include <linux/liveupdate.h>
#include <linux/spinlock_types.h>
#include <linux/types.h>

/**
 * struct pci_liveupdate - PCI Live Update state for a struct pci_dev
 * @outgoing: State preserved for the next kernel.
 * @incoming: State preserved by the previous kernel.
 * @was_incoming: True if this struct pci_dev was incoming-preserved when it was
 *                set up, i.e. it was matched to state preserved by the previous
 *                kernel. Unlike @incoming, this is never cleared, so it stays
 *                true after the device finishes participating in Live Update.
 * @frozen: True if the outgoing preservation status of this device is frozen
 *          and thus cannot be changed.
 */
struct pci_liveupdate {
	struct pci_dev_ser *outgoing;
	struct pci_dev_ser *incoming;
	bool was_incoming;
	bool frozen;
};

struct pci_dev;

#ifdef CONFIG_PCI_LIVEUPDATE
int pci_liveupdate_register_flb(struct liveupdate_file_handler *fh);
void pci_liveupdate_unregister_flb(struct liveupdate_file_handler *fh);
int pci_liveupdate_preserve(struct pci_dev *dev);
void pci_liveupdate_unpreserve(struct pci_dev *dev);
void pci_liveupdate_finish(struct pci_dev *dev);
bool pci_liveupdate_is_incoming(struct pci_dev *dev);
#else
static inline int pci_liveupdate_register_flb(struct liveupdate_file_handler *fh)
{
	return -EOPNOTSUPP;
}

static inline void pci_liveupdate_unregister_flb(struct liveupdate_file_handler *fh)
{
}

static inline int pci_liveupdate_preserve(struct pci_dev *dev)
{
	return -EOPNOTSUPP;
}

static inline void pci_liveupdate_unpreserve(struct pci_dev *dev)
{
}

static inline void pci_liveupdate_finish(struct pci_dev *dev)
{
}

static inline bool pci_liveupdate_is_incoming(struct pci_dev *dev)
{
	return false;
}
#endif

#endif /* LINUX_PCI_LIVEUPDATE_H */