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.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEunHlEgbzHrJD3ZPhAEG6vDF+4pgFAmQSHaAACgkQAEG6vDF+
 4pinVBAAxR+qjMHei+0h+0VwAwmEPWA50sYvrtVVZOYTd93jCuCzs5X13fx9Fqdf
 mLHA8E+qKxSblQLsA/2ZVgai0e+uW8hswh1LMvthyK7Le9yoKtwAxkq8dUG6u2xJ
 U6iOyC9du1E0UDQN2UUw5Xv63Oq5qKYPmxHwuSL980hC3eE5T2jIPX9H5vs1nC2q
 fOoodobYI68t8qZQ9XaZd0ch0MB+DgfGpum9UreZROCiOEFHY6hD1OvMhszLHuod
 vta8TSYFOsC8zb3XTzQj49Pd51MDKph6iVtkSi9sWMOwF2FT4Fhq0ykVPKr01UD+
 whkU6VJO3/VMpRXAuTy0IfUo4W4pB32+FULY7IjC/x4hHYfe9xUzeuwJiMoMuyoC
 YvG/emE3oFXLkcGfvGLlYu1rLZLUKHiCL78uyJ32/oufmENU5kAkJDG+Yf+a1a4D
 DeQO8wT7u0XhT/jtVIdlKnCAYW6m8FoyKLdCjp4kwidmiCLts0HHZYWhzKj1zzHQ
 XeYHsuI0r9VUFe7rjOcGTwa21JLy+PS53z79DnptXmM/mSHDsiPBBKXugLIC0AeE
 OytyaA5XRfCs4Gjej6Wz4F72q7qBIvCwGzzHzda9dKdjjooP/lNQtiCDhKQ3yJOP
 chU4HIeyQMmlqOhwYxdduklyc2I9K5Ep36L50uisnNW6/OQs8bY=
 =YVm6
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmQUkPsACgkQmmx57+YA
 GNm5mhAAsDUc4aBqqbo2aQjRd+5PJ7lOcv5lmpf9MurGPzeus517Yz8rpyUcsrzq
 o47oIGeWsIjDz7XkOjeO/ZGKynoLZqOwO6lhXIPHlJ6CrfJ7akS7ZuQubW85IkYz
 k+nt0TunkJ6RjktZfHpUG9o/El2ngL5bchRlCEpJgAh18uwVbw8SJG4vpcpyK2NX
 KJ4VLmzujEtiBkI+vttpoaJEcCTNdkYlcQLyXEwOqwnBDEauQzSrQA1OUjUn5KrQ
 CvjvNsPbUy21rvcfBXJ0nPbEjnPdEOHxdUfCUMsI78ptILQS8P2mYKBlI9oHcB3G
 lczdeBhOrEdr9fyZAcdk6eh5XysZs5Ihd/jLNhdyUqiJwrQjz1ti9Z8tNQGh0wH3
 C2KKcOm9Ih5bQ29iksnunkGOC5FsFdqzOW1xiNLfP3acmoxxLLvtJSd4jOBd2Hys
 9X/6IrHs4Tfhj4yzU8YDtd3ZFtlUUhtVUa1Ayalcy2UCrVrH0ePuio0+YDDY1avO
 aoRjkEuZnUCSeu4dco9euF6TXutSBHnL0wApTHlBIe+fdimPkA7czQ0MPGEUYwCO
 WKTrbfaYtV5ugyrfj/L1wbA6x/4E6LCzu/m8cf8RcpS8sgRTWuaosbhuE28eu6xl
 lXrrfhhWBz4DtdLa+mrwT8OwmYGfjMxisnBZVLaX5Kw8p0cHEnk=
 =OkOj
 -----END PGP SIGNATURE-----

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:
Arnd Bergmann 2023-03-17 17:10:30 +01:00
commit d2e53ceaf2
3 changed files with 45 additions and 9 deletions

View File

@ -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 */

View File

@ -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;
}

View File

@ -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;