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

firmware: ti_sci: Allow for device shared and exclusive requests

Sysfw provides an option for requesting exclusive access for a
device using the flags MSG_FLAG_DEVICE_EXCLUSIVE. If this flag is
not used, the device is meant to be shared across hosts. Once a device
is requested from a host with this flag set, any request to this
device from a different host will be nacked by sysfw. Current tisci
driver enables this flag for every device requests. But this may not
be true for all the devices. So provide a separate commands in driver
for exclusive and shared device requests.

Reviewed-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Lokesh Vutla and committed by
Arnd Bergmann
45b659ee 3b1261fb

+46 -2
+43 -2
drivers/firmware/ti_sci.c
··· 635 635 636 636 /** 637 637 * ti_sci_cmd_get_device() - command to request for device managed by TISCI 638 + * that can be shared with other hosts. 638 639 * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle 639 640 * @id: Device Identifier 640 641 * ··· 643 642 * usage count by balancing get_device with put_device. No refcounting is 644 643 * managed by driver for that purpose. 645 644 * 646 - * NOTE: The request is for exclusive access for the processor. 647 - * 648 645 * Return: 0 if all went fine, else return appropriate error. 649 646 */ 650 647 static int ti_sci_cmd_get_device(const struct ti_sci_handle *handle, u32 id) 648 + { 649 + return ti_sci_set_device_state(handle, id, 0, 650 + MSG_DEVICE_SW_STATE_ON); 651 + } 652 + 653 + /** 654 + * ti_sci_cmd_get_device_exclusive() - command to request for device managed by 655 + * TISCI that is exclusively owned by the 656 + * requesting host. 657 + * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle 658 + * @id: Device Identifier 659 + * 660 + * Request for the device - NOTE: the client MUST maintain integrity of 661 + * usage count by balancing get_device with put_device. No refcounting is 662 + * managed by driver for that purpose. 663 + * 664 + * Return: 0 if all went fine, else return appropriate error. 665 + */ 666 + static int ti_sci_cmd_get_device_exclusive(const struct ti_sci_handle *handle, 667 + u32 id) 651 668 { 652 669 return ti_sci_set_device_state(handle, id, 653 670 MSG_FLAG_DEVICE_EXCLUSIVE, ··· 684 665 * Return: 0 if all went fine, else return appropriate error. 685 666 */ 686 667 static int ti_sci_cmd_idle_device(const struct ti_sci_handle *handle, u32 id) 668 + { 669 + return ti_sci_set_device_state(handle, id, 0, 670 + MSG_DEVICE_SW_STATE_RETENTION); 671 + } 672 + 673 + /** 674 + * ti_sci_cmd_idle_device_exclusive() - Command to idle a device managed by 675 + * TISCI that is exclusively owned by 676 + * requesting host. 677 + * @handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle 678 + * @id: Device Identifier 679 + * 680 + * Request for the device - NOTE: the client MUST maintain integrity of 681 + * usage count by balancing get_device with put_device. No refcounting is 682 + * managed by driver for that purpose. 683 + * 684 + * Return: 0 if all went fine, else return appropriate error. 685 + */ 686 + static int ti_sci_cmd_idle_device_exclusive(const struct ti_sci_handle *handle, 687 + u32 id) 687 688 { 688 689 return ti_sci_set_device_state(handle, id, 689 690 MSG_FLAG_DEVICE_EXCLUSIVE, ··· 2933 2894 core_ops->reboot_device = ti_sci_cmd_core_reboot; 2934 2895 2935 2896 dops->get_device = ti_sci_cmd_get_device; 2897 + dops->get_device_exclusive = ti_sci_cmd_get_device_exclusive; 2936 2898 dops->idle_device = ti_sci_cmd_idle_device; 2899 + dops->idle_device_exclusive = ti_sci_cmd_idle_device_exclusive; 2937 2900 dops->put_device = ti_sci_cmd_put_device; 2938 2901 2939 2902 dops->is_valid = ti_sci_cmd_dev_is_valid;
+3
include/linux/soc/ti/ti_sci_protocol.h
··· 97 97 */ 98 98 struct ti_sci_dev_ops { 99 99 int (*get_device)(const struct ti_sci_handle *handle, u32 id); 100 + int (*get_device_exclusive)(const struct ti_sci_handle *handle, u32 id); 100 101 int (*idle_device)(const struct ti_sci_handle *handle, u32 id); 102 + int (*idle_device_exclusive)(const struct ti_sci_handle *handle, 103 + u32 id); 101 104 int (*put_device)(const struct ti_sci_handle *handle, u32 id); 102 105 int (*is_valid)(const struct ti_sci_handle *handle, u32 id); 103 106 int (*get_context_loss_count)(const struct ti_sci_handle *handle,