@@ -272,6 +272,30 @@ static int setup_command_metadata(struct ocxlpmem *ocxlpmem)
return 0;
}
+/**
+ * heartbeat() - Issue a heartbeat command to the controller
+ * @ocxlpmem: the device metadata
+ * Return: 0 if the controller responded correctly, negative on error
+ */
+static int heartbeat(struct ocxlpmem *ocxlpmem)
+{
+ int rc;
+
+ mutex_lock(&ocxlpmem->admin_command.lock);
+
+ rc = admin_command_execute(ocxlpmem, ADMIN_COMMAND_HEARTBEAT);
+ if (rc < 0)
+ goto out;
+ if (rc != STATUS_SUCCESS)
+ warn_status(ocxlpmem, "Unexpected status from heartbeat", rc);
+
+ (void)admin_response_handled(ocxlpmem);
+
+out:
+ mutex_unlock(&ocxlpmem->admin_command.lock);
+ return rc;
+}
+
/**
* allocate_minor() - Allocate a minor number to use for an OpenCAPI pmem device
* @ocxlpmem: the device metadata
@@ -1460,6 +1484,12 @@ static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err;
}
+ rc = heartbeat(ocxlpmem);
+ if (rc) {
+ dev_err(&pdev->dev, "Heartbeat failed\n");
+ goto err;
+ }
+
elapsed = 0;
timeout = ocxlpmem->readiness_timeout +
ocxlpmem->memory_available_timeout;