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

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.com


Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parents adbb411b 61832b35
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ menu "Firmware Drivers"
config ARM_SCMI_PROTOCOL
	tristate "ARM System Control and Management Interface (SCMI) Message Protocol"
	depends on ARM || ARM64 || COMPILE_TEST
	depends on MAILBOX
	depends on MAILBOX || HAVE_ARM_SMCCC_DISCOVERY
	help
	  ARM System Control and Management Interface (SCMI) protocol is a
	  set of operating system-independent software interfaces that are
+1 −1
Original line number Diff line number Diff line
@@ -331,7 +331,7 @@ struct scmi_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;
#endif

+15 −9
Original line number Diff line number Diff line
@@ -241,7 +241,6 @@ static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle,

	xfer = &minfo->xfer_block[xfer_id];
	xfer->hdr.seq = xfer_id;
	reinit_completion(&xfer->done);
	xfer->transfer_id = atomic_inc_return(&transfer_last_id);

	return xfer;
@@ -335,6 +334,10 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo,
		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);

	info->desc->ops->fetch_response(cinfo, xfer);
@@ -429,11 +432,12 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
	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
	 * the scmi_xfer structure.
	 * the scmi_xfer structure prior to this.
	 */
	xfer->hdr.protocol_id = pi->proto->id;
	reinit_completion(&xfer->done);

	cinfo = idr_find(&info->tx_idr, xfer->hdr.protocol_id);
	if (unlikely(!cinfo))
@@ -505,16 +509,17 @@ static int do_xfer_with_response(const struct scmi_protocol_handle *ph,
				 struct scmi_xfer *xfer)
{
	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);

	xfer->hdr.protocol_id = pi->proto->id;

	xfer->async_done = &async_response;

	ret = do_xfer(ph, xfer);
	if (!ret && !wait_for_completion_timeout(xfer->async_done, timeout))
	if (!ret) {
		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;
	return ret;
@@ -561,7 +566,6 @@ static int xfer_get_init(const struct scmi_protocol_handle *ph,
	xfer->tx.len = tx_size;
	xfer->rx.len = rx_size ? : info->desc->max_msg_size;
	xfer->hdr.id = msg_id;
	xfer->hdr.protocol_id = pi->proto->id;
	xfer->hdr.poll_completion = false;

	*p = xfer;
@@ -1567,7 +1571,9 @@ ATTRIBUTE_GROUPS(versions);

/* Each compatible listed below must have descriptor associated with it */
static const struct of_device_id scmi_of_match[] = {
#ifdef CONFIG_MAILBOX
	{ .compatible = "arm,scmi", .data = &scmi_mailbox_desc },
#endif
#ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
	{ .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
#endif
+3 −0
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
		return -ENOMEM;

	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);
	of_node_put(shmem);
	if (ret) {
+26 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include <linux/err.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/pm_clock.h>
#include <linux/pm_domain.h>
#include <linux/scmi_protocol.h>

@@ -52,6 +53,27 @@ static int scmi_pd_power_off(struct generic_pm_domain *domain)
	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)
{
	int num_domains, i;
@@ -102,6 +124,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
		scmi_pd->genpd.name = scmi_pd->name;
		scmi_pd->genpd.power_off = scmi_pd_power_off;
		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,
			      state == SCMI_POWER_STATE_GENERIC_OFF);
Loading