Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+45 -9
+1 -2
drivers/firmware/arm_scmi/bus.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/slab.h> 16 16 #include <linux/device.h> 17 - #include <linux/of.h> 18 17 19 18 #include "common.h" 20 19 ··· 435 436 /* Nothing to do. */ 436 437 if (!phead) { 437 438 mutex_unlock(&scmi_requested_devices_mtx); 438 - return scmi_dev; 439 + return NULL; 439 440 } 440 441 441 442 /* Walk the list of requested devices for protocol and create them */
+7 -7
drivers/firmware/arm_scmi/driver.c
··· 2221 2221 hash_init(info->pending_xfers); 2222 2222 2223 2223 /* Allocate a bitmask sized to hold MSG_TOKEN_MAX tokens */ 2224 - info->xfer_alloc_table = devm_kcalloc(dev, BITS_TO_LONGS(MSG_TOKEN_MAX), 2225 - sizeof(long), GFP_KERNEL); 2224 + info->xfer_alloc_table = devm_bitmap_zalloc(dev, MSG_TOKEN_MAX, 2225 + GFP_KERNEL); 2226 2226 if (!info->xfer_alloc_table) 2227 2227 return -ENOMEM; 2228 2228 ··· 2657 2657 struct scmi_handle *handle; 2658 2658 const struct scmi_desc *desc; 2659 2659 struct scmi_info *info; 2660 + bool coex = IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT_COEX); 2660 2661 struct device *dev = &pdev->dev; 2661 2662 struct device_node *child, *np = dev->of_node; 2662 2663 ··· 2732 2731 dev_warn(dev, "Failed to setup SCMI debugfs.\n"); 2733 2732 2734 2733 if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT)) { 2735 - bool coex = 2736 - IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT_COEX); 2737 - 2738 2734 ret = scmi_debugfs_raw_mode_setup(info); 2739 2735 if (!coex) { 2740 2736 if (ret) 2741 2737 goto clear_dev_req_notifier; 2742 2738 2743 - /* Bail out anyway when coex enabled */ 2744 - return ret; 2739 + /* Bail out anyway when coex disabled. */ 2740 + return 0; 2745 2741 } 2746 2742 2747 2743 /* Coex enabled, carry on in any case. */ ··· 2762 2764 ret = scmi_protocol_acquire(handle, SCMI_PROTOCOL_BASE); 2763 2765 if (ret) { 2764 2766 dev_err(dev, "unable to communicate with SCMI\n"); 2767 + if (coex) 2768 + return 0; 2765 2769 goto notification_exit; 2766 2770 } 2767 2771
+37
drivers/firmware/arm_scmi/mailbox.c
··· 52 52 "#mbox-cells", idx, NULL); 53 53 } 54 54 55 + static int mailbox_chan_validate(struct device *cdev) 56 + { 57 + int num_mb, num_sh, ret = 0; 58 + struct device_node *np = cdev->of_node; 59 + 60 + num_mb = of_count_phandle_with_args(np, "mboxes", "#mbox-cells"); 61 + num_sh = of_count_phandle_with_args(np, "shmem", NULL); 62 + /* Bail out if mboxes and shmem descriptors are inconsistent */ 63 + if (num_mb <= 0 || num_sh > 2 || num_mb != num_sh) { 64 + dev_warn(cdev, "Invalid channel descriptor for '%s'\n", 65 + of_node_full_name(np)); 66 + return -EINVAL; 67 + } 68 + 69 + if (num_sh > 1) { 70 + struct device_node *np_tx, *np_rx; 71 + 72 + np_tx = of_parse_phandle(np, "shmem", 0); 73 + np_rx = of_parse_phandle(np, "shmem", 1); 74 + /* SCMI Tx and Rx shared mem areas have to be distinct */ 75 + if (!np_tx || !np_rx || np_tx == np_rx) { 76 + dev_warn(cdev, "Invalid shmem descriptor for '%s'\n", 77 + of_node_full_name(np)); 78 + ret = -EINVAL; 79 + } 80 + 81 + of_node_put(np_tx); 82 + of_node_put(np_rx); 83 + } 84 + 85 + return ret; 86 + } 87 + 55 88 static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, 56 89 bool tx) 57 90 { ··· 96 63 struct mbox_client *cl; 97 64 resource_size_t size; 98 65 struct resource res; 66 + 67 + ret = mailbox_chan_validate(cdev); 68 + if (ret) 69 + return ret; 99 70 100 71 smbox = devm_kzalloc(dev, sizeof(*smbox), GFP_KERNEL); 101 72 if (!smbox)