Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2019 Advanced Micro Devices, Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: AMD
0023  *
0024  */
0025 
0026 #include "dmub_hw_lock_mgr.h"
0027 #include "dc_dmub_srv.h"
0028 #include "dc_types.h"
0029 #include "core_types.h"
0030 
0031 void dmub_hw_lock_mgr_cmd(struct dc_dmub_srv *dmub_srv,
0032                 bool lock,
0033                 union dmub_hw_lock_flags *hw_locks,
0034                 struct dmub_hw_lock_inst_flags *inst_flags)
0035 {
0036     union dmub_rb_cmd cmd;
0037 
0038     memset(&cmd, 0, sizeof(cmd));
0039     cmd.lock_hw.header.type = DMUB_CMD__HW_LOCK;
0040     cmd.lock_hw.header.sub_type = 0;
0041     cmd.lock_hw.header.payload_bytes = sizeof(struct dmub_cmd_lock_hw_data);
0042     cmd.lock_hw.lock_hw_data.client = HW_LOCK_CLIENT_DRIVER;
0043     cmd.lock_hw.lock_hw_data.lock = lock;
0044     cmd.lock_hw.lock_hw_data.hw_locks.u8All = hw_locks->u8All;
0045     memcpy(&cmd.lock_hw.lock_hw_data.inst_flags, inst_flags, sizeof(struct dmub_hw_lock_inst_flags));
0046 
0047     if (!lock)
0048         cmd.lock_hw.lock_hw_data.should_release = 1;
0049 
0050     dc_dmub_srv_cmd_queue(dmub_srv, &cmd);
0051     dc_dmub_srv_cmd_execute(dmub_srv);
0052     dc_dmub_srv_wait_idle(dmub_srv);
0053 }
0054 
0055 void dmub_hw_lock_mgr_inbox0_cmd(struct dc_dmub_srv *dmub_srv,
0056         union dmub_inbox0_cmd_lock_hw hw_lock_cmd)
0057 {
0058     union dmub_inbox0_data_register data = { 0 };
0059 
0060     data.inbox0_cmd_lock_hw = hw_lock_cmd;
0061     dc_dmub_srv_clear_inbox0_ack(dmub_srv);
0062     dc_dmub_srv_send_inbox0_cmd(dmub_srv, data);
0063     dc_dmub_srv_wait_for_inbox0_ack(dmub_srv);
0064 }
0065 
0066 bool should_use_dmub_lock(struct dc_link *link)
0067 {
0068     if (link->psr_settings.psr_version == DC_PSR_VERSION_SU_1)
0069         return true;
0070     return false;
0071 }