mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-29 02:45:20 -05:00
Merge tag 'scmi-fixes-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into soc/fixes
Arm SCMI fixes for v6.3 Few fixes addressing issues around validation of device tree SCMI node, allowing raw SCMI access even on systems which fail to probe the normal driver stack, duplicate header inclusion, clean up return statement using literal values instead of variable to simplify and use of devm_bitmap_zalloc instead of devm_kcalloc to improve semantic. * tag 'scmi-fixes-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: firmware: arm_scmi: Use the bitmap API to allocate bitmaps firmware: arm_scmi: Fix device node validation for mailbox transport firmware: arm_scmi: Fix raw coexistence mode behaviour on failure path firmware: arm_scmi: Remove duplicate include header inclusion firmware: arm_scmi: Return a literal instead of a variable firmware: arm_scmi: Clean up a return statement in scmi_probe Link: https://lore.kernel.org/r/20230315193557.1709241-1-sudeep.holla@arm.com Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/of.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@@ -436,7 +435,7 @@ struct scmi_device *scmi_device_create(struct device_node *np,
|
||||
/* Nothing to do. */
|
||||
if (!phead) {
|
||||
mutex_unlock(&scmi_requested_devices_mtx);
|
||||
return scmi_dev;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Walk the list of requested devices for protocol and create them */
|
||||
|
||||
@@ -2221,8 +2221,8 @@ static int __scmi_xfer_info_init(struct scmi_info *sinfo,
|
||||
hash_init(info->pending_xfers);
|
||||
|
||||
/* Allocate a bitmask sized to hold MSG_TOKEN_MAX tokens */
|
||||
info->xfer_alloc_table = devm_kcalloc(dev, BITS_TO_LONGS(MSG_TOKEN_MAX),
|
||||
sizeof(long), GFP_KERNEL);
|
||||
info->xfer_alloc_table = devm_bitmap_zalloc(dev, MSG_TOKEN_MAX,
|
||||
GFP_KERNEL);
|
||||
if (!info->xfer_alloc_table)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2657,6 +2657,7 @@ static int scmi_probe(struct platform_device *pdev)
|
||||
struct scmi_handle *handle;
|
||||
const struct scmi_desc *desc;
|
||||
struct scmi_info *info;
|
||||
bool coex = IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT_COEX);
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *child, *np = dev->of_node;
|
||||
|
||||
@@ -2731,16 +2732,13 @@ static int scmi_probe(struct platform_device *pdev)
|
||||
dev_warn(dev, "Failed to setup SCMI debugfs.\n");
|
||||
|
||||
if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT)) {
|
||||
bool coex =
|
||||
IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT_COEX);
|
||||
|
||||
ret = scmi_debugfs_raw_mode_setup(info);
|
||||
if (!coex) {
|
||||
if (ret)
|
||||
goto clear_dev_req_notifier;
|
||||
|
||||
/* Bail out anyway when coex enabled */
|
||||
return ret;
|
||||
/* Bail out anyway when coex disabled. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Coex enabled, carry on in any case. */
|
||||
@@ -2764,6 +2762,8 @@ static int scmi_probe(struct platform_device *pdev)
|
||||
ret = scmi_protocol_acquire(handle, SCMI_PROTOCOL_BASE);
|
||||
if (ret) {
|
||||
dev_err(dev, "unable to communicate with SCMI\n");
|
||||
if (coex)
|
||||
return 0;
|
||||
goto notification_exit;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,39 @@ static bool mailbox_chan_available(struct device_node *of_node, int idx)
|
||||
"#mbox-cells", idx, NULL);
|
||||
}
|
||||
|
||||
static int mailbox_chan_validate(struct device *cdev)
|
||||
{
|
||||
int num_mb, num_sh, ret = 0;
|
||||
struct device_node *np = cdev->of_node;
|
||||
|
||||
num_mb = of_count_phandle_with_args(np, "mboxes", "#mbox-cells");
|
||||
num_sh = of_count_phandle_with_args(np, "shmem", NULL);
|
||||
/* Bail out if mboxes and shmem descriptors are inconsistent */
|
||||
if (num_mb <= 0 || num_sh > 2 || num_mb != num_sh) {
|
||||
dev_warn(cdev, "Invalid channel descriptor for '%s'\n",
|
||||
of_node_full_name(np));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (num_sh > 1) {
|
||||
struct device_node *np_tx, *np_rx;
|
||||
|
||||
np_tx = of_parse_phandle(np, "shmem", 0);
|
||||
np_rx = of_parse_phandle(np, "shmem", 1);
|
||||
/* SCMI Tx and Rx shared mem areas have to be distinct */
|
||||
if (!np_tx || !np_rx || np_tx == np_rx) {
|
||||
dev_warn(cdev, "Invalid shmem descriptor for '%s'\n",
|
||||
of_node_full_name(np));
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
||||
of_node_put(np_tx);
|
||||
of_node_put(np_rx);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
|
||||
bool tx)
|
||||
{
|
||||
@@ -64,6 +97,10 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
|
||||
resource_size_t size;
|
||||
struct resource res;
|
||||
|
||||
ret = mailbox_chan_validate(cdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
smbox = devm_kzalloc(dev, sizeof(*smbox), GFP_KERNEL);
|
||||
if (!smbox)
|
||||
return -ENOMEM;
|
||||
|
||||
Reference in New Issue
Block a user