Commit 959cd8f1 authored by Olof Johansson's avatar Olof Johansson

Merge tag 'scmi-updates-5.14' of...

Merge tag 'scmi-updates-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/drivers

ARM SCMI updates for v5.14

- Support for SCMI clocks from the SCMI power domains
- Addition of checks for correct compatibles for shmem devicetree nodes
  that were found missing in the process of YAML schema conversion
- Kconfig and associated build fix found when optee transport are being
  worked on
- Couple of fixes and cleanups found as with work-in-progress virtio
  transport support

The new transports(optee and virtio) themselves are still being worked on
with ongoing reviews, they are not part of this yet

* tag 'scmi-updates-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  firmware: arm_scmi: Avoid multiple initialisations of hdr->protocol_id
  firmware: arm_scmi: Move reinit_completion from scmi_xfer_get to do_xfer
  firmware: arm_scmi: Add delayed response status check
  firmware: arm_scmi: Add compatibility checks for shmem node
  firmware: arm_scpi: Add compatibility checks for shmem node
  firmware: arm_scmi: Fix the build when CONFIG_MAILBOX is not selected
  firmware: arm_scmi: Reset Rx buffer to max size during async commands
  firmware: arm_scmi: Add SMCCC discovery dependency in Kconfig
  firmware: arm_scmi: Add clock management to the SCMI power domain

Link: https://lore.kernel.org/r/20210611075722.2813550-1-sudeep.holla@arm.comSigned-off-by: default avatarOlof Johansson <olof@lixom.net>
parents adbb411b 61832b35
...@@ -9,7 +9,7 @@ menu "Firmware Drivers" ...@@ -9,7 +9,7 @@ menu "Firmware Drivers"
config ARM_SCMI_PROTOCOL config ARM_SCMI_PROTOCOL
tristate "ARM System Control and Management Interface (SCMI) Message Protocol" tristate "ARM System Control and Management Interface (SCMI) Message Protocol"
depends on ARM || ARM64 || COMPILE_TEST depends on ARM || ARM64 || COMPILE_TEST
depends on MAILBOX depends on MAILBOX || HAVE_ARM_SMCCC_DISCOVERY
help help
ARM System Control and Management Interface (SCMI) protocol is a ARM System Control and Management Interface (SCMI) protocol is a
set of operating system-independent software interfaces that are set of operating system-independent software interfaces that are
......
...@@ -331,7 +331,7 @@ struct scmi_desc { ...@@ -331,7 +331,7 @@ struct scmi_desc {
}; };
extern const struct scmi_desc scmi_mailbox_desc; extern const struct scmi_desc scmi_mailbox_desc;
#ifdef CONFIG_HAVE_ARM_SMCCC #ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
extern const struct scmi_desc scmi_smc_desc; extern const struct scmi_desc scmi_smc_desc;
#endif #endif
......
...@@ -241,7 +241,6 @@ static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle, ...@@ -241,7 +241,6 @@ static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle,
xfer = &minfo->xfer_block[xfer_id]; xfer = &minfo->xfer_block[xfer_id];
xfer->hdr.seq = xfer_id; xfer->hdr.seq = xfer_id;
reinit_completion(&xfer->done);
xfer->transfer_id = atomic_inc_return(&transfer_last_id); xfer->transfer_id = atomic_inc_return(&transfer_last_id);
return xfer; return xfer;
...@@ -335,6 +334,10 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo, ...@@ -335,6 +334,10 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo,
return; return;
} }
/* rx.len could be shrunk in the sync do_xfer, so reset to maxsz */
if (msg_type == MSG_TYPE_DELAYED_RESP)
xfer->rx.len = info->desc->max_msg_size;
scmi_dump_header_dbg(dev, &xfer->hdr); scmi_dump_header_dbg(dev, &xfer->hdr);
info->desc->ops->fetch_response(cinfo, xfer); info->desc->ops->fetch_response(cinfo, xfer);
...@@ -429,11 +432,12 @@ static int do_xfer(const struct scmi_protocol_handle *ph, ...@@ -429,11 +432,12 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
struct scmi_chan_info *cinfo; struct scmi_chan_info *cinfo;
/* /*
* Re-instate protocol id here from protocol handle so that cannot be * Initialise protocol id now from protocol handle to avoid it being
* overridden by mistake (or malice) by the protocol code mangling with * overridden by mistake (or malice) by the protocol code mangling with
* the scmi_xfer structure. * the scmi_xfer structure prior to this.
*/ */
xfer->hdr.protocol_id = pi->proto->id; xfer->hdr.protocol_id = pi->proto->id;
reinit_completion(&xfer->done);
cinfo = idr_find(&info->tx_idr, xfer->hdr.protocol_id); cinfo = idr_find(&info->tx_idr, xfer->hdr.protocol_id);
if (unlikely(!cinfo)) if (unlikely(!cinfo))
...@@ -505,16 +509,17 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph, ...@@ -505,16 +509,17 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph,
struct scmi_xfer *xfer) struct scmi_xfer *xfer)
{ {
int ret, timeout = msecs_to_jiffies(SCMI_MAX_RESPONSE_TIMEOUT); int ret, timeout = msecs_to_jiffies(SCMI_MAX_RESPONSE_TIMEOUT);
const struct scmi_protocol_instance *pi = ph_to_pi(ph);
DECLARE_COMPLETION_ONSTACK(async_response); DECLARE_COMPLETION_ONSTACK(async_response);
xfer->hdr.protocol_id = pi->proto->id;
xfer->async_done = &async_response; xfer->async_done = &async_response;
ret = do_xfer(ph, xfer); ret = do_xfer(ph, xfer);
if (!ret && !wait_for_completion_timeout(xfer->async_done, timeout)) if (!ret) {
ret = -ETIMEDOUT; if (!wait_for_completion_timeout(xfer->async_done, timeout))
ret = -ETIMEDOUT;
else if (xfer->hdr.status)
ret = scmi_to_linux_errno(xfer->hdr.status);
}
xfer->async_done = NULL; xfer->async_done = NULL;
return ret; return ret;
...@@ -561,7 +566,6 @@ static int xfer_get_init(const struct scmi_protocol_handle *ph, ...@@ -561,7 +566,6 @@ static int xfer_get_init(const struct scmi_protocol_handle *ph,
xfer->tx.len = tx_size; xfer->tx.len = tx_size;
xfer->rx.len = rx_size ? : info->desc->max_msg_size; xfer->rx.len = rx_size ? : info->desc->max_msg_size;
xfer->hdr.id = msg_id; xfer->hdr.id = msg_id;
xfer->hdr.protocol_id = pi->proto->id;
xfer->hdr.poll_completion = false; xfer->hdr.poll_completion = false;
*p = xfer; *p = xfer;
...@@ -1567,7 +1571,9 @@ ATTRIBUTE_GROUPS(versions); ...@@ -1567,7 +1571,9 @@ ATTRIBUTE_GROUPS(versions);
/* Each compatible listed below must have descriptor associated with it */ /* Each compatible listed below must have descriptor associated with it */
static const struct of_device_id scmi_of_match[] = { static const struct of_device_id scmi_of_match[] = {
#ifdef CONFIG_MAILBOX
{ .compatible = "arm,scmi", .data = &scmi_mailbox_desc }, { .compatible = "arm,scmi", .data = &scmi_mailbox_desc },
#endif
#ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY #ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
{ .compatible = "arm,scmi-smc", .data = &scmi_smc_desc}, { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
#endif #endif
......
...@@ -69,6 +69,9 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, ...@@ -69,6 +69,9 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
return -ENOMEM; return -ENOMEM;
shmem = of_parse_phandle(cdev->of_node, "shmem", idx); shmem = of_parse_phandle(cdev->of_node, "shmem", idx);
if (!of_device_is_compatible(shmem, "arm,scmi-shmem"))
return -ENXIO;
ret = of_address_to_resource(shmem, 0, &res); ret = of_address_to_resource(shmem, 0, &res);
of_node_put(shmem); of_node_put(shmem);
if (ret) { if (ret) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pm_clock.h>
#include <linux/pm_domain.h> #include <linux/pm_domain.h>
#include <linux/scmi_protocol.h> #include <linux/scmi_protocol.h>
...@@ -52,6 +53,27 @@ static int scmi_pd_power_off(struct generic_pm_domain *domain) ...@@ -52,6 +53,27 @@ static int scmi_pd_power_off(struct generic_pm_domain *domain)
return scmi_pd_power(domain, false); return scmi_pd_power(domain, false);
} }
static int scmi_pd_attach_dev(struct generic_pm_domain *pd, struct device *dev)
{
int ret;
ret = pm_clk_create(dev);
if (ret)
return ret;
ret = of_pm_clk_add_clks(dev);
if (ret >= 0)
return 0;
pm_clk_destroy(dev);
return ret;
}
static void scmi_pd_detach_dev(struct generic_pm_domain *pd, struct device *dev)
{
pm_clk_destroy(dev);
}
static int scmi_pm_domain_probe(struct scmi_device *sdev) static int scmi_pm_domain_probe(struct scmi_device *sdev)
{ {
int num_domains, i; int num_domains, i;
...@@ -102,6 +124,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev) ...@@ -102,6 +124,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
scmi_pd->genpd.name = scmi_pd->name; scmi_pd->genpd.name = scmi_pd->name;
scmi_pd->genpd.power_off = scmi_pd_power_off; scmi_pd->genpd.power_off = scmi_pd_power_off;
scmi_pd->genpd.power_on = scmi_pd_power_on; scmi_pd->genpd.power_on = scmi_pd_power_on;
scmi_pd->genpd.attach_dev = scmi_pd_attach_dev;
scmi_pd->genpd.detach_dev = scmi_pd_detach_dev;
scmi_pd->genpd.flags = GENPD_FLAG_PM_CLK |
GENPD_FLAG_ACTIVE_WAKEUP;
pm_genpd_init(&scmi_pd->genpd, NULL, pm_genpd_init(&scmi_pd->genpd, NULL,
state == SCMI_POWER_STATE_GENERIC_OFF); state == SCMI_POWER_STATE_GENERIC_OFF);
......
...@@ -76,6 +76,9 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, ...@@ -76,6 +76,9 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
return -ENOMEM; return -ENOMEM;
np = of_parse_phandle(cdev->of_node, "shmem", 0); np = of_parse_phandle(cdev->of_node, "shmem", 0);
if (!of_device_is_compatible(np, "arm,scmi-shmem"))
return -ENXIO;
ret = of_address_to_resource(np, 0, &res); ret = of_address_to_resource(np, 0, &res);
of_node_put(np); of_node_put(np);
if (ret) { if (ret) {
......
...@@ -899,6 +899,14 @@ static const struct of_device_id legacy_scpi_of_match[] = { ...@@ -899,6 +899,14 @@ static const struct of_device_id legacy_scpi_of_match[] = {
{}, {},
}; };
static const struct of_device_id shmem_of_match[] __maybe_unused = {
{ .compatible = "amlogic,meson-gxbb-scp-shmem", },
{ .compatible = "amlogic,meson-axg-scp-shmem", },
{ .compatible = "arm,juno-scp-shmem", },
{ .compatible = "arm,scp-shmem", },
{ }
};
static int scpi_probe(struct platform_device *pdev) static int scpi_probe(struct platform_device *pdev)
{ {
int count, idx, ret; int count, idx, ret;
...@@ -935,6 +943,9 @@ static int scpi_probe(struct platform_device *pdev) ...@@ -935,6 +943,9 @@ static int scpi_probe(struct platform_device *pdev)
struct mbox_client *cl = &pchan->cl; struct mbox_client *cl = &pchan->cl;
struct device_node *shmem = of_parse_phandle(np, "shmem", idx); struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
if (!of_match_node(shmem_of_match, shmem))
return -ENXIO;
ret = of_address_to_resource(shmem, 0, &res); ret = of_address_to_resource(shmem, 0, &res);
of_node_put(shmem); of_node_put(shmem);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment