dmub_hw_lock_mgr.c (2459B)
1/* 2 * Copyright 2019 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * Authors: AMD 23 * 24 */ 25 26#include "dmub_hw_lock_mgr.h" 27#include "dc_dmub_srv.h" 28#include "dc_types.h" 29#include "core_types.h" 30 31void dmub_hw_lock_mgr_cmd(struct dc_dmub_srv *dmub_srv, 32 bool lock, 33 union dmub_hw_lock_flags *hw_locks, 34 struct dmub_hw_lock_inst_flags *inst_flags) 35{ 36 union dmub_rb_cmd cmd; 37 38 memset(&cmd, 0, sizeof(cmd)); 39 cmd.lock_hw.header.type = DMUB_CMD__HW_LOCK; 40 cmd.lock_hw.header.sub_type = 0; 41 cmd.lock_hw.header.payload_bytes = sizeof(struct dmub_cmd_lock_hw_data); 42 cmd.lock_hw.lock_hw_data.client = HW_LOCK_CLIENT_DRIVER; 43 cmd.lock_hw.lock_hw_data.lock = lock; 44 cmd.lock_hw.lock_hw_data.hw_locks.u8All = hw_locks->u8All; 45 memcpy(&cmd.lock_hw.lock_hw_data.inst_flags, inst_flags, sizeof(struct dmub_hw_lock_inst_flags)); 46 47 if (!lock) 48 cmd.lock_hw.lock_hw_data.should_release = 1; 49 50 dc_dmub_srv_cmd_queue(dmub_srv, &cmd); 51 dc_dmub_srv_cmd_execute(dmub_srv); 52 dc_dmub_srv_wait_idle(dmub_srv); 53} 54 55void dmub_hw_lock_mgr_inbox0_cmd(struct dc_dmub_srv *dmub_srv, 56 union dmub_inbox0_cmd_lock_hw hw_lock_cmd) 57{ 58 union dmub_inbox0_data_register data = { 0 }; 59 60 data.inbox0_cmd_lock_hw = hw_lock_cmd; 61 dc_dmub_srv_clear_inbox0_ack(dmub_srv); 62 dc_dmub_srv_send_inbox0_cmd(dmub_srv, data); 63 dc_dmub_srv_wait_for_inbox0_ack(dmub_srv); 64} 65 66bool should_use_dmub_lock(struct dc_link *link) 67{ 68 return false; 69}