Skip to content

Commit

Permalink
Merge tag 'qcom-drivers-fixes-for-6.11' of https://git.kernel.org/pub…
Browse files Browse the repository at this point in the history
…/scm/linux/kernel/git/qcom/linux into arm/fixes

Qualcomm driver fixes for v6.11

This corrects the tzmem virt-to-phys conversion, which caused issues for
the uefisecapp implementation of EFI variable access. SDM670 is excluded
from tzmem usage due to reported issues.

The SCM get wait queue context call is corrected to be marked ATOMIC and
some dead code in qseecom, following the tzmem conversion, is removed.

The memory backing command DB is remapped writecombined, to avoid XPU
violations when Linux runs without the Qualcomm hypervisor.

Two compile fixes are added for pd-mapper, and the broken reference
count is corrected, to make pd-mapper deal with remoteprocs going away.

In pmic_glink a race condition where the client callbacks might be
called before we returned the client handle is corrected. The broken conditions
for when to signal that the firmware is going down is also corrected.

In the pmic_glink UCSI driver, the ucsi_unregister() is moved out of the
pdr callback, as this is being invoked in atomic context.

Konrad's email address is updated in MAINTAINERS, and related mailmap
entries are added.

* tag 'qcom-drivers-fixes-for-6.11' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux:
  soc: qcom: pd-mapper: Fix singleton refcount
  firmware: qcom: tzmem: disable sdm670 platform
  soc: qcom: pmic_glink: Actually communicate when remote goes down
  usb: typec: ucsi: Move unregister out of atomic section
  soc: qcom: pmic_glink: Fix race during initialization
  firmware: qcom: qseecom: remove unused functions
  firmware: qcom: tzmem: fix virtual-to-physical address conversion
  firmware: qcom: scm: Mark get_wq_ctx() as atomic call
  MAINTAINERS: Update Konrad Dybcio's email address
  mailmap: Add an entry for Konrad Dybcio
  soc: qcom: pd-mapper: mark qcom_pdm_domains as __maybe_unused
  soc: qcom: cmd-db: Map shared memory as WC, not WB
  soc: qcom: pd-mapper: Depend on ARCH_QCOM || COMPILE_TEST

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnd Bergmann <[email protected]>
  • Loading branch information
arndb committed Aug 28, 2024
2 parents 27795c5 + c158ceb commit d8f2638
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 103 deletions.
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ Kenneth Westfield <[email protected]> <[email protected]>
Kiran Gunda <[email protected]> <[email protected]>
Kirill Tkhai <[email protected]> <[email protected]>
Kishon Vijay Abraham I <[email protected]> <[email protected]>
Konrad Dybcio <[email protected]> <[email protected]>
Konrad Dybcio <[email protected]> <[email protected]>
Konstantin Khlebnikov <[email protected]> <[email protected]>
Konstantin Khlebnikov <[email protected]> <[email protected]>
Koushik <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2745,7 +2745,7 @@ F: include/linux/soc/qcom/

ARM/QUALCOMM SUPPORT
M: Bjorn Andersson <[email protected]>
M: Konrad Dybcio <konrad.dybcio@linaro.org>
M: Konrad Dybcio <konradybcio@kernel.org>
L: [email protected]
S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git
Expand Down Expand Up @@ -7106,7 +7106,7 @@ F: drivers/gpu/drm/tiny/panel-mipi-dbi.c
DRM DRIVER for Qualcomm Adreno GPUs
M: Rob Clark <[email protected]>
R: Sean Paul <[email protected]>
R: Konrad Dybcio <konrad.dybcio@linaro.org>
R: Konrad Dybcio <konradybcio@kernel.org>
L: [email protected]
L: [email protected]
L: [email protected]
Expand Down Expand Up @@ -18774,7 +18774,7 @@ F: include/uapi/drm/qaic_accel.h

QUALCOMM CORE POWER REDUCTION (CPR) AVS DRIVER
M: Bjorn Andersson <[email protected]>
M: Konrad Dybcio <konrad.dybcio@linaro.org>
M: Konrad Dybcio <konradybcio@kernel.org>
L: [email protected]
L: [email protected]
S: Maintained
Expand Down
2 changes: 1 addition & 1 deletion drivers/firmware/qcom/qcom_scm-smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int scm_get_wq_ctx(u32 *wq_ctx, u32 *flags, u32 *more_pending)
struct arm_smccc_res get_wq_res;
struct arm_smccc_args get_wq_ctx = {0};

get_wq_ctx.args[0] = ARM_SMCCC_CALL_VAL(ARM_SMCCC_STD_CALL,
get_wq_ctx.args[0] = ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,
ARM_SMCCC_SMC_64, ARM_SMCCC_OWNER_SIP,
SCM_SMC_FNID(QCOM_SCM_SVC_WAITQ, QCOM_SCM_WAITQ_GET_WQ_CTX));

Expand Down
33 changes: 22 additions & 11 deletions drivers/firmware/qcom/qcom_tzmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ struct qcom_tzmem_pool {
};

struct qcom_tzmem_chunk {
phys_addr_t paddr;
size_t size;
struct qcom_tzmem_pool *owner;
};
Expand Down Expand Up @@ -78,6 +77,7 @@ static bool qcom_tzmem_using_shm_bridge;
/* List of machines that are known to not support SHM bridge correctly. */
static const char *const qcom_tzmem_blacklist[] = {
"qcom,sc8180x",
"qcom,sdm670", /* failure in GPU firmware loading */
"qcom,sdm845", /* reset in rmtfs memory assignment */
"qcom,sm8150", /* reset in rmtfs memory assignment */
NULL
Expand Down Expand Up @@ -385,7 +385,6 @@ void *qcom_tzmem_alloc(struct qcom_tzmem_pool *pool, size_t size, gfp_t gfp)
return NULL;
}

chunk->paddr = gen_pool_virt_to_phys(pool->genpool, vaddr);
chunk->size = size;
chunk->owner = pool;

Expand Down Expand Up @@ -431,25 +430,37 @@ void qcom_tzmem_free(void *vaddr)
EXPORT_SYMBOL_GPL(qcom_tzmem_free);

/**
* qcom_tzmem_to_phys() - Map the virtual address of a TZ buffer to physical.
* @vaddr: Virtual address of the buffer allocated from a TZ memory pool.
* qcom_tzmem_to_phys() - Map the virtual address of TZ memory to physical.
* @vaddr: Virtual address of memory allocated from a TZ memory pool.
*
* Can be used in any context. The address must have been returned by a call
* to qcom_tzmem_alloc().
* Can be used in any context. The address must point to memory allocated
* using qcom_tzmem_alloc().
*
* Returns: Physical address of the buffer.
* Returns:
* Physical address mapped from the virtual or 0 if the mapping failed.
*/
phys_addr_t qcom_tzmem_to_phys(void *vaddr)
{
struct qcom_tzmem_chunk *chunk;
struct radix_tree_iter iter;
void __rcu **slot;
phys_addr_t ret;

guard(spinlock_irqsave)(&qcom_tzmem_chunks_lock);

chunk = radix_tree_lookup(&qcom_tzmem_chunks, (unsigned long)vaddr);
if (!chunk)
return 0;
radix_tree_for_each_slot(slot, &qcom_tzmem_chunks, &iter, 0) {
chunk = radix_tree_deref_slot_protected(slot,
&qcom_tzmem_chunks_lock);

return chunk->paddr;
ret = gen_pool_virt_to_phys(chunk->owner->genpool,
(unsigned long)vaddr);
if (ret == -1)
continue;

return ret;
}

return 0;
}
EXPORT_SYMBOL_GPL(qcom_tzmem_to_phys);

Expand Down
16 changes: 10 additions & 6 deletions drivers/power/supply/qcom_battmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1387,12 +1387,16 @@ static int qcom_battmgr_probe(struct auxiliary_device *adev,
"failed to register wireless charing power supply\n");
}

battmgr->client = devm_pmic_glink_register_client(dev,
PMIC_GLINK_OWNER_BATTMGR,
qcom_battmgr_callback,
qcom_battmgr_pdr_notify,
battmgr);
return PTR_ERR_OR_ZERO(battmgr->client);
battmgr->client = devm_pmic_glink_client_alloc(dev, PMIC_GLINK_OWNER_BATTMGR,
qcom_battmgr_callback,
qcom_battmgr_pdr_notify,
battmgr);
if (IS_ERR(battmgr->client))
return PTR_ERR(battmgr->client);

pmic_glink_client_register(battmgr->client);

return 0;
}

static const struct auxiliary_device_id qcom_battmgr_id_table[] = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/soc/qcom/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ config QCOM_PD_MAPPER
select QCOM_QMI_HELPERS
select QCOM_PDR_MSG
select AUXILIARY_BUS
depends on NET && QRTR
depends on NET && QRTR && (ARCH_QCOM || COMPILE_TEST)
default QCOM_RPROC_COMMON
help
The Protection Domain Mapper maps registered services to the domains
Expand Down
2 changes: 1 addition & 1 deletion drivers/soc/qcom/cmd-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ static int cmd_db_dev_probe(struct platform_device *pdev)
return -EINVAL;
}

cmd_db_header = memremap(rmem->base, rmem->size, MEMREMAP_WB);
cmd_db_header = memremap(rmem->base, rmem->size, MEMREMAP_WC);
if (!cmd_db_header) {
ret = -ENOMEM;
cmd_db_header = NULL;
Expand Down
40 changes: 28 additions & 12 deletions drivers/soc/qcom/pmic_glink.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ static void _devm_pmic_glink_release_client(struct device *dev, void *res)
spin_unlock_irqrestore(&pg->client_lock, flags);
}

struct pmic_glink_client *devm_pmic_glink_register_client(struct device *dev,
unsigned int id,
void (*cb)(const void *, size_t, void *),
void (*pdr)(void *, int),
void *priv)
struct pmic_glink_client *devm_pmic_glink_client_alloc(struct device *dev,
unsigned int id,
void (*cb)(const void *, size_t, void *),
void (*pdr)(void *, int),
void *priv)
{
struct pmic_glink_client *client;
struct pmic_glink *pg = dev_get_drvdata(dev->parent);
unsigned long flags;

client = devres_alloc(_devm_pmic_glink_release_client, sizeof(*client), GFP_KERNEL);
if (!client)
Expand All @@ -85,6 +84,18 @@ struct pmic_glink_client *devm_pmic_glink_register_client(struct device *dev,
client->cb = cb;
client->pdr_notify = pdr;
client->priv = priv;
INIT_LIST_HEAD(&client->node);

devres_add(dev, client);

return client;
}
EXPORT_SYMBOL_GPL(devm_pmic_glink_client_alloc);

void pmic_glink_client_register(struct pmic_glink_client *client)
{
struct pmic_glink *pg = client->pg;
unsigned long flags;

mutex_lock(&pg->state_lock);
spin_lock_irqsave(&pg->client_lock, flags);
Expand All @@ -95,17 +106,22 @@ struct pmic_glink_client *devm_pmic_glink_register_client(struct device *dev,
spin_unlock_irqrestore(&pg->client_lock, flags);
mutex_unlock(&pg->state_lock);

devres_add(dev, client);

return client;
}
EXPORT_SYMBOL_GPL(devm_pmic_glink_register_client);
EXPORT_SYMBOL_GPL(pmic_glink_client_register);

int pmic_glink_send(struct pmic_glink_client *client, void *data, size_t len)
{
struct pmic_glink *pg = client->pg;
int ret;

return rpmsg_send(pg->ept, data, len);
mutex_lock(&pg->state_lock);
if (!pg->ept)
ret = -ECONNRESET;
else
ret = rpmsg_send(pg->ept, data, len);
mutex_unlock(&pg->state_lock);

return ret;
}
EXPORT_SYMBOL_GPL(pmic_glink_send);

Expand Down Expand Up @@ -175,7 +191,7 @@ static void pmic_glink_state_notify_clients(struct pmic_glink *pg)
if (pg->pdr_state == SERVREG_SERVICE_STATE_UP && pg->ept)
new_state = SERVREG_SERVICE_STATE_UP;
} else {
if (pg->pdr_state == SERVREG_SERVICE_STATE_UP && pg->ept)
if (pg->pdr_state == SERVREG_SERVICE_STATE_DOWN || !pg->ept)
new_state = SERVREG_SERVICE_STATE_DOWN;
}

Expand Down
17 changes: 11 additions & 6 deletions drivers/soc/qcom/pmic_glink_altmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,17 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
return ret;
}

altmode->client = devm_pmic_glink_register_client(dev,
altmode->owner_id,
pmic_glink_altmode_callback,
pmic_glink_altmode_pdr_notify,
altmode);
return PTR_ERR_OR_ZERO(altmode->client);
altmode->client = devm_pmic_glink_client_alloc(dev,
altmode->owner_id,
pmic_glink_altmode_callback,
pmic_glink_altmode_pdr_notify,
altmode);
if (IS_ERR(altmode->client))
return PTR_ERR(altmode->client);

pmic_glink_client_register(altmode->client);

return 0;
}

static const struct auxiliary_device_id pmic_glink_altmode_id_table[] = {
Expand Down
4 changes: 3 additions & 1 deletion drivers/soc/qcom/qcom_pd_mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ static const struct qcom_pdm_domain_data *sm8550_domains[] = {
NULL,
};

static const struct of_device_id qcom_pdm_domains[] = {
static const struct of_device_id qcom_pdm_domains[] __maybe_unused = {
{ .compatible = "qcom,apq8064", .data = NULL, },
{ .compatible = "qcom,apq8074", .data = NULL, },
{ .compatible = "qcom,apq8084", .data = NULL, },
Expand Down Expand Up @@ -635,6 +635,8 @@ static int qcom_pdm_probe(struct auxiliary_device *auxdev,
ret = PTR_ERR(data);
else
__qcom_pdm_data = data;
} else {
refcount_inc(&__qcom_pdm_data->refcnt);
}

auxiliary_set_drvdata(auxdev, __qcom_pdm_data);
Expand Down
43 changes: 32 additions & 11 deletions drivers/usb/typec/ucsi/ucsi_glink.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ struct pmic_glink_ucsi {

struct work_struct notify_work;
struct work_struct register_work;
spinlock_t state_lock;
bool ucsi_registered;
bool pd_running;

u8 read_buf[UCSI_BUF_SIZE];
};
Expand Down Expand Up @@ -244,8 +247,20 @@ static void pmic_glink_ucsi_notify(struct work_struct *work)
static void pmic_glink_ucsi_register(struct work_struct *work)
{
struct pmic_glink_ucsi *ucsi = container_of(work, struct pmic_glink_ucsi, register_work);
unsigned long flags;
bool pd_running;

ucsi_register(ucsi->ucsi);
spin_lock_irqsave(&ucsi->state_lock, flags);
pd_running = ucsi->pd_running;
spin_unlock_irqrestore(&ucsi->state_lock, flags);

if (!ucsi->ucsi_registered && pd_running) {
ucsi_register(ucsi->ucsi);
ucsi->ucsi_registered = true;
} else if (ucsi->ucsi_registered && !pd_running) {
ucsi_unregister(ucsi->ucsi);
ucsi->ucsi_registered = false;
}
}

static void pmic_glink_ucsi_callback(const void *data, size_t len, void *priv)
Expand All @@ -269,11 +284,12 @@ static void pmic_glink_ucsi_callback(const void *data, size_t len, void *priv)
static void pmic_glink_ucsi_pdr_notify(void *priv, int state)
{
struct pmic_glink_ucsi *ucsi = priv;
unsigned long flags;

if (state == SERVREG_SERVICE_STATE_UP)
schedule_work(&ucsi->register_work);
else if (state == SERVREG_SERVICE_STATE_DOWN)
ucsi_unregister(ucsi->ucsi);
spin_lock_irqsave(&ucsi->state_lock, flags);
ucsi->pd_running = (state == SERVREG_SERVICE_STATE_UP);
spin_unlock_irqrestore(&ucsi->state_lock, flags);
schedule_work(&ucsi->register_work);
}

static void pmic_glink_ucsi_destroy(void *data)
Expand Down Expand Up @@ -320,6 +336,7 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
INIT_WORK(&ucsi->register_work, pmic_glink_ucsi_register);
init_completion(&ucsi->read_ack);
init_completion(&ucsi->write_ack);
spin_lock_init(&ucsi->state_lock);
mutex_init(&ucsi->lock);

ucsi->ucsi = ucsi_create(dev, &pmic_glink_ucsi_ops);
Expand Down Expand Up @@ -367,12 +384,16 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
ucsi->port_orientation[port] = desc;
}

ucsi->client = devm_pmic_glink_register_client(dev,
PMIC_GLINK_OWNER_USBC,
pmic_glink_ucsi_callback,
pmic_glink_ucsi_pdr_notify,
ucsi);
return PTR_ERR_OR_ZERO(ucsi->client);
ucsi->client = devm_pmic_glink_client_alloc(dev, PMIC_GLINK_OWNER_USBC,
pmic_glink_ucsi_callback,
pmic_glink_ucsi_pdr_notify,
ucsi);
if (IS_ERR(ucsi->client))
return PTR_ERR(ucsi->client);

pmic_glink_client_register(ucsi->client);

return 0;
}

static void pmic_glink_ucsi_remove(struct auxiliary_device *adev)
Expand Down
Loading

0 comments on commit d8f2638

Please sign in to comment.