2014-07-16 18:08:55 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Advanced Micro Devices, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KFD_PRIV_H_INCLUDED
|
|
|
|
#define KFD_PRIV_H_INCLUDED
|
|
|
|
|
|
|
|
#include <linux/hashtable.h>
|
|
|
|
#include <linux/mmu_notifier.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/atomic.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <kgd_kfd_interface.h>
|
|
|
|
|
2014-07-16 18:22:32 +00:00
|
|
|
#define KFD_SYSFS_FILE_MODE 0444
|
|
|
|
|
|
|
|
/* GPU ID hash width in bits */
|
|
|
|
#define KFD_GPU_ID_HASH_WIDTH 16
|
|
|
|
|
|
|
|
/* Macro for allocating structures */
|
|
|
|
#define kfd_alloc_struct(ptr_to_struct) \
|
|
|
|
((typeof(ptr_to_struct)) kzalloc(sizeof(*ptr_to_struct), GFP_KERNEL))
|
|
|
|
|
2014-07-16 18:08:55 +00:00
|
|
|
struct kfd_device_info {
|
|
|
|
unsigned int max_pasid_bits;
|
|
|
|
size_t ih_ring_entry_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct kfd_dev {
|
|
|
|
struct kgd_dev *kgd;
|
|
|
|
|
|
|
|
const struct kfd_device_info *device_info;
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
|
|
|
|
unsigned int id; /* topology stub index */
|
|
|
|
|
|
|
|
struct kgd2kfd_shared_resources shared_resources;
|
|
|
|
|
|
|
|
bool init_complete;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/* KGD2KFD callbacks */
|
|
|
|
void kgd2kfd_exit(void);
|
|
|
|
struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, struct pci_dev *pdev);
|
|
|
|
bool kgd2kfd_device_init(struct kfd_dev *kfd,
|
|
|
|
const struct kgd2kfd_shared_resources *gpu_resources);
|
|
|
|
void kgd2kfd_device_exit(struct kfd_dev *kfd);
|
|
|
|
|
|
|
|
extern const struct kfd2kgd_calls *kfd2kgd;
|
|
|
|
|
|
|
|
/* Character device interface */
|
|
|
|
int kfd_chardev_init(void);
|
|
|
|
void kfd_chardev_exit(void);
|
|
|
|
struct device *kfd_chardev(void);
|
|
|
|
|
|
|
|
/* Process data */
|
|
|
|
struct kfd_process {
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct device *kfd_device;
|
|
|
|
|
2014-07-16 18:22:32 +00:00
|
|
|
/* Topology */
|
|
|
|
int kfd_topology_init(void);
|
|
|
|
void kfd_topology_shutdown(void);
|
|
|
|
int kfd_topology_add_device(struct kfd_dev *gpu);
|
|
|
|
int kfd_topology_remove_device(struct kfd_dev *gpu);
|
|
|
|
struct kfd_dev *kfd_device_by_id(uint32_t gpu_id);
|
|
|
|
struct kfd_dev *kfd_device_by_pci_dev(const struct pci_dev *pdev);
|
|
|
|
struct kfd_dev *kfd_topology_enum_kfd_devices(uint8_t idx);
|
|
|
|
|
2014-07-16 18:08:55 +00:00
|
|
|
/* Interrupts */
|
|
|
|
void kgd2kfd_interrupt(struct kfd_dev *dev, const void *ih_ring_entry);
|
|
|
|
|
|
|
|
/* Power Management */
|
|
|
|
void kgd2kfd_suspend(struct kfd_dev *dev);
|
|
|
|
int kgd2kfd_resume(struct kfd_dev *dev);
|
|
|
|
|
|
|
|
#endif
|