Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11baa78e authored by Avaneesh Kumar Dwivedi's avatar Avaneesh Kumar Dwivedi Committed by Gerrit - the friendly Code Review server
Browse files

soc: qcom: Reorganize PIL code for reclaiming MSS mem during SSR



This change ask hypervisor to remove memory mapping for MSS
from IOMMU second stage table and assign the ownership back to
HLOS just after MBA is booted.

Presently this is being done only after MBA is booted and MDT is
authenticated.

Change-Id: I724c1bcc664827e666612dd34cd078f3f044498a
Signed-off-by: default avatarAvaneesh Kumar Dwivedi <akdwived@codeaurora.org>
parent 047ccea1
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -831,7 +831,9 @@ int pil_boot(struct pil_desc *desc)
	}

	if (desc->ops->init_image)
		ret = desc->ops->init_image(desc, fw->data, fw->size);
		ret = desc->ops->init_image(desc, fw->data, fw->size,
			priv->region_start,
			priv->region_end - priv->region_start);
	if (ret) {
		pil_err(desc, "Invalid firmware metadata\n");
		subsys_set_error(desc->subsys_dev, firmware_error_msg);
@@ -847,17 +849,6 @@ int pil_boot(struct pil_desc *desc)
	}

	if (desc->subsys_vmid > 0) {
		/* In case of modem ssr, we need to assign memory back to linux.
		 * This is not true after cold boot since linux already owns it.
		 * Also for secure boot devices, modem memory has to be released
		 * after MBA is booted. */
		if (desc->modem_ssr) {
			ret = pil_assign_mem_to_linux(desc, priv->region_start,
				(priv->region_end - priv->region_start));
			if (ret)
				pil_err(desc, "Failed to assign to linux, ret- %d\n",
								ret);
		}
		ret = pil_assign_mem_to_subsys_and_linux(desc,
				priv->region_start,
				(priv->region_end - priv->region_start));
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ struct pil_image_info {
 */
struct pil_reset_ops {
	int (*init_image)(struct pil_desc *pil, const u8 *metadata,
			  size_t size);
			  size_t size,  phys_addr_t addr, size_t sz);
	int (*mem_setup)(struct pil_desc *pil, phys_addr_t addr, size_t size);
	int (*verify_blob)(struct pil_desc *pil, phys_addr_t phy_addr,
			   size_t size);
+18 −3
Original line number Diff line number Diff line
@@ -652,7 +652,7 @@ err_invalid_fw:
}

static int pil_msa_auth_modem_mdt(struct pil_desc *pil, const u8 *metadata,
					size_t size)
		size_t size, phys_addr_t phy_addr, size_t phy_sz)
{
	struct modem_data *drv = dev_get_drvdata(pil->dev);
	void *mdata_virt;
@@ -681,6 +681,19 @@ static int pil_msa_auth_modem_mdt(struct pil_desc *pil, const u8 *metadata,
	wmb();

	if (pil->subsys_vmid > 0) {
		/**
		  * In case of modem ssr, we need to assign memory back to linux.
		  * This is not true after cold boot since linux already owns
		  * it. Also for secure boot devices, modem memory has to be
		  * released after MBA is booted
		  */
		if (pil->modem_ssr) {
			ret = pil_assign_mem_to_linux(pil, phy_addr, phy_sz);
			if (ret)
				dev_err(pil->dev,
					"Failed to assign to linux, ret- %d\n",
					ret);
		}
		ret = pil_assign_mem_to_subsys(pil, mdata_phys,
							ALIGN(size, SZ_4K));
		if (ret) {
@@ -733,7 +746,8 @@ fail:
}

static int pil_msa_mss_reset_mba_load_auth_mdt(struct pil_desc *pil,
				  const u8 *metadata, size_t size)
		const u8 *metadata, size_t size,
		phys_addr_t modem_reg, size_t sz_modem_reg)
{
	int ret;

@@ -741,7 +755,8 @@ static int pil_msa_mss_reset_mba_load_auth_mdt(struct pil_desc *pil,
	if (ret)
		return ret;

	return pil_msa_auth_modem_mdt(pil, metadata, size);
	return pil_msa_auth_modem_mdt(pil, metadata, size,
			modem_reg, sz_modem_reg);
}

static int pil_msa_mba_verify_blob(struct pil_desc *pil, phys_addr_t phy_addr,
+2 −1
Original line number Diff line number Diff line
@@ -303,7 +303,8 @@ static int bg_shutdown(const struct subsys_desc *subsys, bool force_stop)
 * Return: 0 on success. Error code on failure.
 */
static int bg_auth_metadata(struct pil_desc *pil,
	const u8 *metadata, size_t size)
	const u8 *metadata, size_t size,
	phys_addr_t addr, size_t sz)
{
	struct pil_bg_data *bg_data = desc_to_data(pil);
	struct tzapp_bg_req bg_tz_req;
+2 −1
Original line number Diff line number Diff line
@@ -582,7 +582,8 @@ static void pil_remove_proxy_vote(struct pil_desc *pil)
}

static int pil_init_image_trusted(struct pil_desc *pil,
		const u8 *metadata, size_t size)
		const u8 *metadata, size_t size,
		 phys_addr_t addr, size_t sz)
{
	struct pil_tz_data *d = desc_to_data(pil);
	struct pas_init_image_req {