1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2018 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef _NV_RSYNC_H_
25 #define _NV_RSYNC_H_
26 
27 #include "nv-linux.h"
28 
29 typedef struct nv_rsync_info
30 {
31     struct semaphore lock;
32     uint32_t usage_count;
33     NvBool relaxed_ordering_mode;
34     int (*get_relaxed_ordering_mode)(int *mode, void *data);
35     void (*put_relaxed_ordering_mode)(int mode, void *data);
36     void (*wait_for_rsync)(struct pci_dev *gpu, void *data);
37     void *data;
38 } nv_rsync_info_t;
39 
40 void nv_init_rsync_info(void);
41 void nv_destroy_rsync_info(void);
42 int nv_get_rsync_info(void);
43 void nv_put_rsync_info(void);
44 int nv_register_rsync_driver(
45                         int (*get_relaxed_ordering_mode)(int *mode, void *data),
46                         void (*put_relaxed_ordering_mode)(int mode, void *data),
47                         void (*wait_for_rsync)(struct pci_dev *gpu, void *data),
48                         void *data);
49 void nv_unregister_rsync_driver(
50                         int (*get_relaxed_ordering_mode)(int *mode, void *data),
51                         void (*put_relaxed_ordering_mode)(int mode, void *data),
52                         void (*wait_for_rsync)(struct pci_dev *gpu, void *data),
53                         void *data);
54 NvBool nv_get_rsync_relaxed_ordering_mode(nv_state_t *nv);
55 void nv_wait_for_rsync(nv_state_t *nv);
56 
57 #endif
58