1 // SPDX-License-Identifier: (GPL-2.0-only OR B 1 2 // 3 // This file is provided under a dual BSD/GPLv 4 // redistributing this file, you may do so und 5 // 6 // Copyright(c) 2018 Intel Corporation 7 // 8 // Author: Liam Girdwood <liam.r.girdwood@linu 9 // 10 11 #include <linux/pci.h> 12 #include "ops.h" 13 14 static 15 bool snd_sof_pci_update_bits_unlocked(struct s 16 u32 mask 17 { 18 struct pci_dev *pci = to_pci_dev(sdev- 19 unsigned int old, new; 20 u32 ret = 0; 21 22 pci_read_config_dword(pci, offset, &re 23 old = ret; 24 dev_dbg(sdev->dev, "Debug PCIR: %8.8x 25 26 new = (old & ~mask) | (value & mask); 27 28 if (old == new) 29 return false; 30 31 pci_write_config_dword(pci, offset, ne 32 dev_dbg(sdev->dev, "Debug PCIW: %8.8x 33 offset); 34 35 return true; 36 } 37 38 bool snd_sof_pci_update_bits(struct snd_sof_de 39 u32 mask, u32 val 40 { 41 unsigned long flags; 42 bool change; 43 44 spin_lock_irqsave(&sdev->hw_lock, flag 45 change = snd_sof_pci_update_bits_unloc 46 spin_unlock_irqrestore(&sdev->hw_lock, 47 return change; 48 } 49 EXPORT_SYMBOL(snd_sof_pci_update_bits); 50 51 bool snd_sof_dsp_update_bits_unlocked(struct s 52 u32 offs 53 { 54 unsigned int old, new; 55 u32 ret; 56 57 ret = snd_sof_dsp_read(sdev, bar, offs 58 59 old = ret; 60 new = (old & ~mask) | (value & mask); 61 62 if (old == new) 63 return false; 64 65 snd_sof_dsp_write(sdev, bar, offset, n 66 67 return true; 68 } 69 EXPORT_SYMBOL(snd_sof_dsp_update_bits_unlocked 70 71 bool snd_sof_dsp_update_bits64_unlocked(struct 72 u32 of 73 { 74 u64 old, new; 75 76 old = snd_sof_dsp_read64(sdev, bar, of 77 78 new = (old & ~mask) | (value & mask); 79 80 if (old == new) 81 return false; 82 83 snd_sof_dsp_write64(sdev, bar, offset, 84 85 return true; 86 } 87 EXPORT_SYMBOL(snd_sof_dsp_update_bits64_unlock 88 89 /* This is for registers bits with attribute R 90 bool snd_sof_dsp_update_bits(struct snd_sof_de 91 u32 mask, u32 val 92 { 93 unsigned long flags; 94 bool change; 95 96 spin_lock_irqsave(&sdev->hw_lock, flag 97 change = snd_sof_dsp_update_bits_unloc 98 99 spin_unlock_irqrestore(&sdev->hw_lock, 100 return change; 101 } 102 EXPORT_SYMBOL(snd_sof_dsp_update_bits); 103 104 bool snd_sof_dsp_update_bits64(struct snd_sof_ 105 u64 mask, u64 v 106 { 107 unsigned long flags; 108 bool change; 109 110 spin_lock_irqsave(&sdev->hw_lock, flag 111 change = snd_sof_dsp_update_bits64_unl 112 113 spin_unlock_irqrestore(&sdev->hw_lock, 114 return change; 115 } 116 EXPORT_SYMBOL(snd_sof_dsp_update_bits64); 117 118 static 119 void snd_sof_dsp_update_bits_forced_unlocked(s 120 u 121 { 122 unsigned int old, new; 123 u32 ret; 124 125 ret = snd_sof_dsp_read(sdev, bar, offs 126 127 old = ret; 128 new = (old & ~mask) | (value & mask); 129 130 snd_sof_dsp_write(sdev, bar, offset, n 131 } 132 133 /* This is for registers bits with attribute R 134 void snd_sof_dsp_update_bits_forced(struct snd 135 u32 offset 136 { 137 unsigned long flags; 138 139 spin_lock_irqsave(&sdev->hw_lock, flag 140 snd_sof_dsp_update_bits_forced_unlocke 141 spin_unlock_irqrestore(&sdev->hw_lock, 142 } 143 EXPORT_SYMBOL(snd_sof_dsp_update_bits_forced); 144 145 /** 146 * snd_sof_dsp_panic - handle a received DSP p 147 * @sdev: Pointer to the device's sdev 148 * @offset: offset of panic information 149 * @non_recoverable: the panic is fatal, no re 150 */ 151 void snd_sof_dsp_panic(struct snd_sof_dev *sde 152 { 153 /* 154 * if DSP is not ready and the dsp_oop 155 * offset from the panic message. 156 */ 157 if (!sdev->dsp_oops_offset) 158 sdev->dsp_oops_offset = offset 159 160 /* 161 * Print warning if the offset from th 162 * dsp_oops_offset 163 */ 164 if (sdev->dsp_oops_offset != offset) 165 dev_warn(sdev->dev, 166 "%s: dsp_oops_offset 167 __func__, sdev->dsp_o 168 169 /* 170 * Set the fw_state to crashed only in 171 * event. 172 * Use different message within the sn 173 * the non_recoverable flag. 174 */ 175 sdev->dbg_dump_printed = false; 176 if (non_recoverable) { 177 snd_sof_dsp_dbg_dump(sdev, "DS 178 SOF_DBG_D 179 sof_set_fw_state(sdev, SOF_FW_ 180 sof_fw_trace_fw_crashed(sdev); 181 } else { 182 snd_sof_dsp_dbg_dump(sdev, 183 "DSP pani 184 SOF_DBG_D 185 } 186 } 187 EXPORT_SYMBOL(snd_sof_dsp_panic); 188
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.