Skip to content

Commit

Permalink
Add post_hardware_init device method
Browse files Browse the repository at this point in the history
This is called after hardware is initialized, but only when the device
is being added.
  • Loading branch information
alewycky-tenstorrent committed Aug 2, 2024
1 parent dbe43a4 commit a91276d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions device.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct tenstorrent_device_class {
u32 instance_size;
bool (*init_device)(struct tenstorrent_device *ttdev);
bool (*init_hardware)(struct tenstorrent_device *ttdev);
bool (*post_hardware_init)(struct tenstorrent_device *ttdev);
void (*cleanup_hardware)(struct tenstorrent_device *ttdev);
void (*cleanup_device)(struct tenstorrent_device *ttdev);
void (*first_open_cb)(struct tenstorrent_device *ttdev);
Expand Down
3 changes: 2 additions & 1 deletion enumerate.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ static int tenstorrent_pci_probe(struct pci_dev *dev, const struct pci_device_id
tt_dev->interrupt_enabled = tenstorrent_enable_interrupts(tt_dev);

if (device_class->init_device(tt_dev))
device_class->init_hardware(tt_dev);
if (device_class->init_hardware(tt_dev))
device_class->post_hardware_init(tt_dev);

pci_save_state(dev);

Expand Down
10 changes: 8 additions & 2 deletions grayskull.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ static void grayskull_hwmon_init(struct grayskull_device *gs_dev) {
if (IS_ERR(hwmon_device))
goto grayskull_hwmon_init_err;

tt_dev->attributes = gs_attributes;

return;

Expand Down Expand Up @@ -831,9 +832,13 @@ static bool grayskull_init_hardware(struct tenstorrent_device *tt_dev) {

grayskull_noc_init(gs_dev);

grayskull_hwmon_init(gs_dev);
return true;
}

tt_dev->attributes = gs_attributes;
static bool grayskull_post_hardware_init(struct tenstorrent_device *tt_dev) {
struct grayskull_device *gs_dev = tt_dev_to_gs_dev(tt_dev);

grayskull_hwmon_init(gs_dev);

return true;
}
Expand Down Expand Up @@ -872,6 +877,7 @@ struct tenstorrent_device_class grayskull_class = {
.instance_size = sizeof(struct grayskull_device),
.init_device = grayskull_init,
.init_hardware = grayskull_init_hardware,
.post_hardware_init = grayskull_post_hardware_init,
.cleanup_hardware = grayskull_cleanup_hardware,
.cleanup_device = grayskull_cleanup,
.last_release_cb = grayskull_last_release_handler,
Expand Down
11 changes: 9 additions & 2 deletions wormhole.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ static void wormhole_hwmon_init(struct wormhole_device *wh_dev) {
if (IS_ERR(hwmon_device))
goto wormhole_hwmon_init_err;

tt_dev->attributes = wh_attributes;

return;

wormhole_hwmon_init_err:
Expand All @@ -179,9 +181,13 @@ static bool wormhole_init_hardware(struct tenstorrent_device *tt_dev) {
grayskull_send_arc_fw_message_with_args(reset_unit_regs(wh_dev), WH_FW_MSG_UPDATE_M3_AUTO_RESET_TIMEOUT, auto_reset_timeout, 0, 10000, NULL);
}

wormhole_hwmon_init(wh_dev);
return true;
}

tt_dev->attributes = wh_attributes;
static bool wormhole_post_hardware_init(struct tenstorrent_device *tt_dev) {
struct wormhole_device *wh_dev = tt_dev_to_wh_dev(tt_dev);

wormhole_hwmon_init(wh_dev);

return true;
}
Expand Down Expand Up @@ -213,6 +219,7 @@ struct tenstorrent_device_class wormhole_class = {
.instance_size = sizeof(struct wormhole_device),
.init_device = wormhole_init,
.init_hardware = wormhole_init_hardware,
.post_hardware_init = wormhole_post_hardware_init,
.cleanup_hardware = wormhole_cleanup_hardware,
.cleanup_device = wormhole_cleanup,
.reboot = wormhole_reboot,
Expand Down

0 comments on commit a91276d

Please sign in to comment.