Lines Matching +full:offset +full:- +full:x

1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2010-2020 NVIDIA Corporation */
19 if (fw->pos == fw->end) in fw_next()
20 return -EINVAL; in fw_next()
22 *word = fw->data[fw->pos++]; in fw_next()
27 static bool fw_check_addr_valid(struct tegra_drm_firewall *fw, u32 offset) in fw_check_addr_valid() argument
31 for (i = 0; i < fw->submit->num_used_mappings; i++) { in fw_check_addr_valid()
32 struct tegra_drm_mapping *m = fw->submit->used_mappings[i].mapping; in fw_check_addr_valid()
34 if (offset >= m->iova && offset <= m->iova_end) in fw_check_addr_valid()
41 static int fw_check_reg(struct tegra_drm_firewall *fw, u32 offset) in fw_check_reg() argument
51 if (!fw->client->ops->is_addr_reg) in fw_check_reg()
54 is_addr = fw->client->ops->is_addr_reg(fw->client->base.dev, fw->class, in fw_check_reg()
55 offset); in fw_check_reg()
61 return -EINVAL; in fw_check_reg()
66 static int fw_check_regs_seq(struct tegra_drm_firewall *fw, u32 offset, in fw_check_regs_seq() argument
72 if (fw_check_reg(fw, offset)) in fw_check_regs_seq()
73 return -EINVAL; in fw_check_regs_seq()
76 offset++; in fw_check_regs_seq()
82 static int fw_check_regs_mask(struct tegra_drm_firewall *fw, u32 offset, in fw_check_regs_mask() argument
89 if (fw_check_reg(fw, offset+bit)) in fw_check_regs_mask()
90 return -EINVAL; in fw_check_regs_mask()
96 static int fw_check_regs_imm(struct tegra_drm_firewall *fw, u32 offset) in fw_check_regs_imm() argument
100 if (!fw->client->ops->is_addr_reg) in fw_check_regs_imm()
103 is_addr = fw->client->ops->is_addr_reg(fw->client->base.dev, fw->class, in fw_check_regs_imm()
104 offset); in fw_check_regs_imm()
106 return -EINVAL; in fw_check_regs_imm()
113 if (!fw->client->ops->is_valid_class) { in fw_check_class()
114 if (class == fw->client->base.class) in fw_check_class()
117 return -EINVAL; in fw_check_class()
120 if (!fw->client->ops->is_valid_class(class)) in fw_check_class()
121 return -EINVAL; in fw_check_class()
161 u32 word, opcode, offset, count, mask, class; in tegra_drm_fw_validate() local
171 offset = word >> 16 & 0xfff; in tegra_drm_fw_validate()
178 err = fw_check_regs_mask(&fw, offset, mask); in tegra_drm_fw_validate()
180 dev_warn(client->base.dev, in tegra_drm_fw_validate()
181 "illegal SETCLASS(offset=0x%x, mask=0x%x, class=0x%x) at word %u", in tegra_drm_fw_validate()
182 offset, mask, class, fw.pos-1); in tegra_drm_fw_validate()
185 offset = (word >> 16) & 0xfff; in tegra_drm_fw_validate()
187 err = fw_check_regs_seq(&fw, offset, count, true); in tegra_drm_fw_validate()
189 dev_warn(client->base.dev, in tegra_drm_fw_validate()
190 "illegal INCR(offset=0x%x, count=%u) in class 0x%x at word %u", in tegra_drm_fw_validate()
191 offset, count, fw.class, fw.pos-1); in tegra_drm_fw_validate()
194 offset = (word >> 16) & 0xfff; in tegra_drm_fw_validate()
196 err = fw_check_regs_seq(&fw, offset, count, false); in tegra_drm_fw_validate()
198 dev_warn(client->base.dev, in tegra_drm_fw_validate()
199 "illegal NONINCR(offset=0x%x, count=%u) in class 0x%x at word %u", in tegra_drm_fw_validate()
200 offset, count, fw.class, fw.pos-1); in tegra_drm_fw_validate()
203 offset = (word >> 16) & 0xfff; in tegra_drm_fw_validate()
205 err = fw_check_regs_mask(&fw, offset, mask); in tegra_drm_fw_validate()
207 dev_warn(client->base.dev, in tegra_drm_fw_validate()
208 "illegal MASK(offset=0x%x, mask=0x%x) in class 0x%x at word %u", in tegra_drm_fw_validate()
209 offset, mask, fw.class, fw.pos-1); in tegra_drm_fw_validate()
213 offset = (word >> 16) & 0xfff; in tegra_drm_fw_validate()
214 err = fw_check_regs_imm(&fw, offset); in tegra_drm_fw_validate()
216 dev_warn(client->base.dev, in tegra_drm_fw_validate()
217 "illegal IMM(offset=0x%x) in class 0x%x at word %u", in tegra_drm_fw_validate()
218 offset, fw.class, fw.pos-1); in tegra_drm_fw_validate()
226 return -EINVAL; in tegra_drm_fw_validate()
228 offset = word & 0x3fffff; in tegra_drm_fw_validate()
229 err = fw_check_regs_seq(&fw, offset, payload, true); in tegra_drm_fw_validate()
231 dev_warn(client->base.dev, in tegra_drm_fw_validate()
232 "illegal INCR_W(offset=0x%x) in class 0x%x at word %u", in tegra_drm_fw_validate()
233 offset, fw.class, fw.pos-1); in tegra_drm_fw_validate()
237 return -EINVAL; in tegra_drm_fw_validate()
239 offset = word & 0x3fffff; in tegra_drm_fw_validate()
240 err = fw_check_regs_seq(&fw, offset, payload, false); in tegra_drm_fw_validate()
242 dev_warn(client->base.dev, in tegra_drm_fw_validate()
243 "illegal NONINCR(offset=0x%x) in class 0x%x at word %u", in tegra_drm_fw_validate()
244 offset, fw.class, fw.pos-1); in tegra_drm_fw_validate()
247 dev_warn(client->base.dev, "illegal opcode at word %u", in tegra_drm_fw_validate()
248 fw.pos-1); in tegra_drm_fw_validate()
249 return -EINVAL; in tegra_drm_fw_validate()