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: Avaneesh Kumar Dwivedi <akdwived@codeaurora.org>
This commit is contained in:
Avaneesh Kumar Dwivedi 2017-09-05 17:43:35 +05:30 committed by Naitik Bharadiya
parent a8e92fae3a
commit a19e5e98f4
4 changed files with 28 additions and 24 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2010-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -980,7 +980,9 @@ int pil_boot(struct pil_desc *desc)
trace_pil_event("before_init_image", 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, "Initializing image failed(rc:%d)\n", ret);
subsys_set_error(desc->subsys_dev, firmware_error_msg);
@ -997,20 +999,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
*/
trace_pil_event("before_assign_mem", desc);
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));

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2017, 2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -116,7 +116,7 @@ struct md_ssr_toc /* Shared IMEM ToC struct */
*/
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);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -685,7 +685,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;
@ -715,6 +715,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) {
@ -769,7 +782,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;
@ -777,7 +791,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,

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2017, 2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -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 {