Commit 76b801aa authored by Jeffrey Hugo's avatar Jeffrey Hugo

accel/qaic: Add Sahara implementation for firmware loading

The AIC100 secondary bootloader uses the Sahara protocol for two
purposes - loading the runtime firmware images from the host, and
offloading crashdumps to the host. The crashdump functionality is only
invoked when the AIC100 device encounters a crash and dumps are enabled.
Also the collection of the dump is optional - the host can reject
collecting the dump.

The Sahara protocol contains many features and modes including firmware
upload, crashdump download, and client commands. For simplicity,
implement the parts of the protocol needed for loading firmware to the
device.

Fundamentally, the Sahara protocol is an embedded file transfer
protocol. Both sides negotiate a connection through a simple exchange of
hello messages. After handshaking through a hello message, the device
either sends a message requesting images, or a message advertising the
memory dump available for the host. For image transfer, the remote device
issues a read data request that provides an image (by ID), an offset, and
a length. The host has an internal mapping of image IDs to filenames. The
host is expected to access the image and transfer the requested chunk to
the device. The device can issue additional read requests, or signal that
it has consumed enough data from this image with an end of image message.
The host confirms the end of image, and the device can proceed with
another image by starting over with the hello exchange again.

Some images may be optional, and only provided as part of a provisioning
flow. The host is not aware of this information, and thus should report
an error to the device when an image is not available. The device will
evaluate if the image is required or not, and take the appropriate
action.
Signed-off-by: default avatarJeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: default avatarCarl Vanderlip <quic_carlv@quicinc.com>
Reviewed-by: default avatarPranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
Reviewed-by: default avatarBjorn Andersson <andersson@kernel.org>
Reviewed-by: default avatarJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240322034917.3522388-1-quic_jhugo@quicinc.com
parent a1f95aed
...@@ -10,6 +10,7 @@ qaic-y := \ ...@@ -10,6 +10,7 @@ qaic-y := \
qaic_control.o \ qaic_control.o \
qaic_data.o \ qaic_data.o \
qaic_drv.o \ qaic_drv.o \
qaic_timesync.o qaic_timesync.o \
sahara.o
qaic-$(CONFIG_DEBUG_FS) += qaic_debugfs.o qaic-$(CONFIG_DEBUG_FS) += qaic_debugfs.o
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "qaic.h" #include "qaic.h"
#include "qaic_debugfs.h" #include "qaic_debugfs.h"
#include "qaic_timesync.h" #include "qaic_timesync.h"
#include "sahara.h"
MODULE_IMPORT_NS(DMA_BUF); MODULE_IMPORT_NS(DMA_BUF);
...@@ -644,6 +645,12 @@ static int __init qaic_init(void) ...@@ -644,6 +645,12 @@ static int __init qaic_init(void)
goto free_pci; goto free_pci;
} }
ret = sahara_register();
if (ret) {
pr_debug("qaic: sahara_register failed %d\n", ret);
goto free_mhi;
}
ret = qaic_timesync_init(); ret = qaic_timesync_init();
if (ret) if (ret)
pr_debug("qaic: qaic_timesync_init failed %d\n", ret); pr_debug("qaic: qaic_timesync_init failed %d\n", ret);
...@@ -654,6 +661,8 @@ static int __init qaic_init(void) ...@@ -654,6 +661,8 @@ static int __init qaic_init(void)
return 0; return 0;
free_mhi:
mhi_driver_unregister(&qaic_mhi_driver);
free_pci: free_pci:
pci_unregister_driver(&qaic_pci_driver); pci_unregister_driver(&qaic_pci_driver);
return ret; return ret;
...@@ -679,6 +688,7 @@ static void __exit qaic_exit(void) ...@@ -679,6 +688,7 @@ static void __exit qaic_exit(void)
link_up = true; link_up = true;
qaic_bootlog_unregister(); qaic_bootlog_unregister();
qaic_timesync_deinit(); qaic_timesync_deinit();
sahara_unregister();
mhi_driver_unregister(&qaic_mhi_driver); mhi_driver_unregister(&qaic_mhi_driver);
pci_unregister_driver(&qaic_pci_driver); pci_unregister_driver(&qaic_pci_driver);
} }
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. */
#ifndef __SAHARA_H__
#define __SAHARA_H__
int sahara_register(void);
void sahara_unregister(void);
#endif /* __SAHARA_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment