Skip to content

Commit

Permalink
Terrible, Horrible, No Good, Very Bad Hack
Browse files Browse the repository at this point in the history
This was less effort than writing a proper driver for the card in
question.

Long story short:
- GS/WH hugepage "sysmem" DMA don't act right under SiFive Premier P550
  dev board
- Want to test a different piece of hardware with similar driver code
  path
  • Loading branch information
joelsmithTT committed Nov 3, 2024
1 parent 715a5d7 commit 72895d1
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: GPL-2.0-only

obj-m += tenstorrent.o
tenstorrent-y := module.o chardev.o enumerate.o interrupt.o grayskull.o wormhole.o pcie.o hwmon.o sg_helpers.o memory.o
tenstorrent-y := module.o chardev.o enumerate.o interrupt.o grayskull.o wormhole.o pcie.o hwmon.o sg_helpers.o memory.o squirrel.o

KDIR := /lib/modules/$(shell uname -r)/build
KMAKE := $(MAKE) -C $(KDIR) M=$(CURDIR)
Expand Down
3 changes: 3 additions & 0 deletions enumerate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#define PCI_DEVICE_ID_GRAYSKULL 0xFACA
#define PCI_DEVICE_ID_WORMHOLE 0x401E

#define PCI_VENDOR_ID_XILINX 0x10ee
#define PCI_DEVICE_ID_SQUIRREL 0x0666

struct pci_dev;
struct cdev;

Expand Down
3 changes: 3 additions & 0 deletions module.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ MODULE_PARM_DESC(auto_reset_timeout, "Timeout duration in seconds for M3 auto re
struct tenstorrent_device_class;
extern struct tenstorrent_device_class grayskull_class;
extern struct tenstorrent_device_class wormhole_class;
extern struct tenstorrent_device_class squirrel_class;

const struct pci_device_id tenstorrent_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_TENSTORRENT, PCI_DEVICE_ID_GRAYSKULL),
.driver_data=(kernel_ulong_t)&grayskull_class },
{ PCI_DEVICE(PCI_VENDOR_ID_TENSTORRENT, PCI_DEVICE_ID_WORMHOLE),
.driver_data=(kernel_ulong_t)&wormhole_class },
{ PCI_DEVICE(PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_SQUIRREL),
.driver_data=(kernel_ulong_t)&squirrel_class },
{ 0 },
};

Expand Down
44 changes: 44 additions & 0 deletions squirrel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
// SPDX-License-Identifier: GPL-2.0-only

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/types.h>

#include "squirrel.h"
#include "pcie.h"
#include "module.h"
#include "hwmon.h"


static bool squirrel_init(struct tenstorrent_device *tt_dev) {
struct squirrel_device *wh_dev = tt_dev_to_sq_dev(tt_dev);

return true;
}


static bool squirrel_init_hardware(struct tenstorrent_device *tt_dev) {
return true;
}

static bool squirrel_post_hardware_init(struct tenstorrent_device *tt_dev) {
return true;
}

static void squirrel_cleanup_hardware(struct tenstorrent_device *tt_dev) {
}

static void squirrel_cleanup(struct tenstorrent_device *tt_dev) {
struct squirrel_device *sq_dev = tt_dev_to_sq_dev(tt_dev);
}

struct tenstorrent_device_class squirrel_class = {
.name = "Squirrel",
.instance_size = sizeof(struct squirrel_device),
.init_device = squirrel_init,
.init_hardware = squirrel_init_hardware,
.post_hardware_init = squirrel_post_hardware_init,
.cleanup_hardware = squirrel_cleanup_hardware,
.cleanup_device = squirrel_cleanup,
.reboot = squirrel_cleanup_hardware,
};
17 changes: 17 additions & 0 deletions squirrel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
// SPDX-License-Identifier: GPL-2.0-only

#ifndef TTDRIVER_WORMHOLE_H_INCLUDED
#define TTDRIVER_WORMHOLE_H_INCLUDED

#include <linux/types.h>
#include "device.h"

struct squirrel_device {
struct tenstorrent_device tt;
};

#define tt_dev_to_sq_dev(ttdev) \
container_of((tt_dev), struct squirrel_device, tt)

#endif

0 comments on commit 72895d1

Please sign in to comment.