Files
android/drivers/mmc/core/crypto.c
T
threeeye bc1d038eac REVVL 6 Pro kernel bring-up: full working tree snapshot (2026-09-12)
Squashed backup commit (no shallow-clone history issues) of
xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream
commit 9eece662e) plus all fixes applied to get everpal_defconfig building
clean against a modern (GCC 15.2.0) toolchain -- see the previous commit
message on the lineage-23.2 branch (also in this repo history is not
available here since this is a squashed snapshot; full incremental history
lives in the local DL380 checkout and the upstream GitHub remote).

Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
2026-09-12 13:36:46 +00:00

54 lines
1.2 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Copyright 2020 Google LLC
*/
#include <linux/blk-crypto.h>
#include <linux/blkdev.h>
#include <linux/keyslot-manager.h>
#include <linux/mmc/host.h>
#include "core.h"
#include "queue.h"
void mmc_crypto_setup_queue(struct mmc_host *host, struct request_queue *q)
{
if (host->caps2 & MMC_CAP2_CRYPTO)
q->ksm = host->ksm;
}
EXPORT_SYMBOL_GPL(mmc_crypto_setup_queue);
void mmc_crypto_free_host(struct mmc_host *host)
{
keyslot_manager_destroy(host->ksm);
}
void mmc_crypto_prepare_req(struct mmc_queue_req *mqrq)
{
#ifdef CONFIG_MTK_EMMC_HW_CQ
struct request *req = mqrq->req;
struct mmc_request *mrq = &(mqrq->cmdq_req.mrq);
#else /* let BUG() if SW-CQHCI run to here */
struct request *req = NULL;
struct mmc_request *mrq = NULL;
#endif
const struct bio_crypt_ctx *bc;
if (!bio_crypt_should_process(req))
return;
bc = req->bio->bi_crypt_context;
mrq->crypto_key_slot = bc->bc_keyslot;
/*
* OTA with ext4 (dun is 512 bytes) used LBA,
* with F2FS (dun is 512 bytes), the dun[0] had
* multiplied by 8.
*/
if (bc->hie_ext4)
mrq->data_unit_num = blk_rq_pos(req);
else
mrq->data_unit_num = lower_32_bits(bc->bc_dun[0]);
mrq->crypto_key = bc->bc_key;
}
EXPORT_SYMBOL_GPL(mmc_crypto_prepare_req);