drivers/hid/intel-ish-hid/ishtp/loader.c
Source file repositories/reference/linux-study-clean/drivers/hid/intel-ish-hid/ishtp/loader.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/intel-ish-hid/ishtp/loader.c- Extension
.c- Size
- 16801 bytes
- Lines
- 487
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cacheflush.hlinux/container_of.hlinux/crc32.hlinux/dev_printk.hlinux/dma-mapping.hlinux/dmi.hlinux/errno.hlinux/firmware.hlinux/gfp_types.hlinux/math.hlinux/module.hlinux/pfn.hlinux/sprintf.hlinux/string.hlinux/types.hlinux/wait.hhbm.hloader.h
Detected Declarations
function Copyrightfunction loader_xfer_cmdfunction release_dma_bufsfunction prepare_dma_bufsfunction _request_ish_firmwarefunction request_ish_firmwarefunction copy_manifestfunction copy_ish_versionfunction ishtp_loader_work
Annotated Snippet
if (dma_bufs[i]) {
dma_addr = le64_to_cpu(fragment->fragment_tbl[i].ddr_adrs);
dma_free_coherent(dev->devc, fragment_size, dma_bufs[i], dma_addr);
dma_bufs[i] = NULL;
}
}
}
/**
* prepare_dma_bufs() - Prepare the DMA buffer for transferring firmware fragments
* @dev: The ISHTP device
* @ish_fw: The ISH firmware
* @fragment: The ISHTP firmware fragment descriptor
* @dma_bufs: The array of DMA fragment buffers
* @fragment_size: The size of a single DMA fragment
* @fragment_count: Number of fragments
*
* Return: 0 on success, negative error code on failure
*/
static int prepare_dma_bufs(struct ishtp_device *dev,
const struct firmware *ish_fw,
struct loader_xfer_dma_fragment *fragment,
void **dma_bufs, u32 fragment_size, u32 fragment_count)
{
dma_addr_t dma_addr;
u32 offset = 0;
u32 length;
int i;
for (i = 0; i < fragment_count && offset < ish_fw->size; i++) {
dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size, &dma_addr, GFP_KERNEL);
if (!dma_bufs[i])
return -ENOMEM;
fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma_addr);
length = clamp(ish_fw->size - offset, 0, fragment_size);
fragment->fragment_tbl[i].length = cpu_to_le32(length);
fragment->fragment_tbl[i].fw_off = cpu_to_le32(offset);
memcpy(dma_bufs[i], ish_fw->data + offset, length);
clflush_cache_range(dma_bufs[i], fragment_size);
offset += length;
}
return 0;
}
/* Patterns with PRODUCT_FAMILY */
#define ISH_FW_FILE_VENDOR_FAMILY_NAME_SKU_FMT "intel/ish/ish_%s_%08x_%08x_%08x_%08x.bin"
#define ISH_FW_FILE_VENDOR_FAMILY_SKU_FMT "intel/ish/ish_%s_%08x_%08x_%08x.bin"
#define ISH_FW_FILE_VENDOR_FAMILY_NAME_FMT "intel/ish/ish_%s_%08x_%08x_%08x.bin"
#define ISH_FW_FILE_VENDOR_FAMILY_FMT "intel/ish/ish_%s_%08x_%08x.bin"
#define ISH_FW_FILE_VENDOR_NAME_SKU_FMT "intel/ish/ish_%s_%08x_%08x_%08x.bin"
#define ISH_FW_FILE_VENDOR_SKU_FMT "intel/ish/ish_%s_%08x_%08x.bin"
#define ISH_FW_FILE_VENDOR_NAME_FMT "intel/ish/ish_%s_%08x_%08x.bin"
#define ISH_FW_FILE_VENDOR_FMT "intel/ish/ish_%s_%08x.bin"
#define ISH_FW_FILE_DEFAULT_FMT "intel/ish/ish_%s.bin"
#define ISH_FW_FILENAME_LEN_MAX 72
#define ISH_CRC_INIT (~0u)
#define ISH_CRC_XOROUT (~0u)
static int _request_ish_firmware(const struct firmware **firmware_p,
const char *name, struct device *dev)
{
int ret;
dev_dbg(dev, "Try to load firmware: %s\n", name);
ret = firmware_request_nowarn(firmware_p, name, dev);
if (!ret)
dev_info(dev, "load firmware: %s\n", name);
return ret;
}
/**
* request_ish_firmware() - Request and load the ISH firmware.
* @firmware_p: Pointer to the firmware image.
* @dev: Device for which firmware is being requested.
*
* This function attempts to load the Integrated Sensor Hub (ISH) firmware
* for the given device in the following order, prioritizing custom firmware
* with more precise matching patterns:
*
* ish_${fw_generation}_${SYS_VENDOR_CRC32}_$(PRODUCT_FAMILY_CRC32)
* _$(PRODUCT_NAME_CRC32)_${PRODUCT_SKU_CRC32}.bin
*
* ish_${fw_generation}_${SYS_VENDOR_CRC32}_$(PRODUCT_FAMILY_CRC32)_${PRODUCT_SKU_CRC32}.bin
Annotation
- Immediate include surface: `linux/cacheflush.h`, `linux/container_of.h`, `linux/crc32.h`, `linux/dev_printk.h`, `linux/dma-mapping.h`, `linux/dmi.h`, `linux/errno.h`, `linux/firmware.h`.
- Detected declarations: `function Copyright`, `function loader_xfer_cmd`, `function release_dma_bufs`, `function prepare_dma_bufs`, `function _request_ish_firmware`, `function request_ish_firmware`, `function copy_manifest`, `function copy_ish_version`, `function ishtp_loader_work`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.