-
Notifications
You must be signed in to change notification settings - Fork 9
/
interrupt.c
46 lines (36 loc) · 1.1 KB
/
interrupt.c
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
// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
// SPDX-License-Identifier: GPL-2.0-only
#include "interrupt.h"
#include <linux/pci.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include "device.h"
#include "enumerate.h"
static irqreturn_t irq_handler(int irq, void *device)
{
struct tenstorrent_device *tt_dev = device;
(void)tt_dev; // to be used later
return IRQ_HANDLED;
}
bool tenstorrent_enable_interrupts(struct tenstorrent_device *tt_dev)
{
if (pci_alloc_irq_vectors(tt_dev->pdev, 1, 1, PCI_IRQ_ALL_TYPES) <= 0)
goto out_pci_alloc_irq_vectors_failed;
if (request_irq(pci_irq_vector(tt_dev->pdev, 0), irq_handler,
IRQF_SHARED, TENSTORRENT, tt_dev) != 0)
goto out_request_irq_failed;
tt_dev->interrupt_enabled = true;
return true;
out_request_irq_failed:
pci_free_irq_vectors(tt_dev->pdev);
out_pci_alloc_irq_vectors_failed:
return false;
}
void tenstorrent_disable_interrupts(struct tenstorrent_device *tt_dev)
{
if (tt_dev->interrupt_enabled) {
free_irq(pci_irq_vector(tt_dev->pdev, 0), tt_dev);
pci_free_irq_vectors(tt_dev->pdev);
tt_dev->interrupt_enabled = false;
}
}