Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright IBM Corp. 2020
4 *
5 * Author(s):
6 * Pierre Morel <pmorel@linux.ibm.com>
7 *
8 */
9#ifndef __S390_PCI_BUS_H
10#define __S390_PCI_BUS_H
11
12#include <linux/pci.h>
13
14int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops);
15void zpci_bus_device_unregister(struct zpci_dev *zdev);
16
17int zpci_bus_scan_bus(struct zpci_bus *zbus);
18void zpci_bus_scan_busses(void);
19
20int zpci_bus_scan_device(struct zpci_dev *zdev);
21void zpci_bus_remove_device(struct zpci_dev *zdev, bool set_error);
22
23void zpci_release_device(struct kref *kref);
24static inline void zpci_zdev_put(struct zpci_dev *zdev)
25{
26 if (zdev)
27 kref_put(&zdev->kref, zpci_release_device);
28}
29
30static inline void zpci_zdev_get(struct zpci_dev *zdev)
31{
32 kref_get(&zdev->kref);
33}
34
35int zpci_alloc_domain(int domain);
36void zpci_free_domain(int domain);
37int zpci_setup_bus_resources(struct zpci_dev *zdev);
38
39static inline struct zpci_dev *zdev_from_bus(struct pci_bus *bus,
40 unsigned int devfn)
41{
42 struct zpci_bus *zbus = bus->sysdata;
43
44 return (devfn >= ZPCI_FUNCTIONS_PER_BUS) ? NULL : zbus->function[devfn];
45}
46
47#endif /* __S390_PCI_BUS_H */
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright IBM Corp. 2020
4 *
5 * Author(s):
6 * Pierre Morel <pmorel@linux.ibm.com>
7 *
8 */
9
10int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops);
11void zpci_bus_device_unregister(struct zpci_dev *zdev);
12int zpci_bus_init(void);
13
14void zpci_release_device(struct kref *kref);
15static inline void zpci_zdev_put(struct zpci_dev *zdev)
16{
17 kref_put(&zdev->kref, zpci_release_device);
18}
19
20int zpci_alloc_domain(int domain);
21void zpci_free_domain(int domain);
22int zpci_setup_bus_resources(struct zpci_dev *zdev,
23 struct list_head *resources);
24
25static inline struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus,
26 unsigned int devfn)
27{
28 struct zpci_bus *zbus = bus->sysdata;
29
30 return (devfn >= ZPCI_FUNCTIONS_PER_BUS) ? NULL : zbus->function[devfn];
31}
32
33#ifdef CONFIG_PCI_IOV
34static inline void zpci_remove_virtfn(struct pci_dev *pdev, int vfn)
35{
36
37 pci_lock_rescan_remove();
38 /* Linux' vfid's start at 0 vfn at 1 */
39 pci_iov_remove_virtfn(pdev->physfn, vfn - 1);
40 pci_unlock_rescan_remove();
41}
42#else /* CONFIG_PCI_IOV */
43static inline void zpci_remove_virtfn(struct pci_dev *pdev, int vfn) {}
44#endif /* CONFIG_PCI_IOV */