Skip to content

Commit 036b353

Browse files
author
Rob Clark
committed
drm/msm/registers: Fix encoding fields in 64b registers
Based on mesa commit 3f70b0578402 ("freedreno/registers: Fix encoding fields in 64b registers"), but with some fixes to not skip emitting interrupt enum values. v2: Don't append "ull" to 32b reg MASK defines, to avoid printf format conversion warnings all over the place Co-developed-by: Connor Abbott <cwabbott0@gmail.com> Signed-off-by: Connor Abbott <cwabbott0@gmail.com> Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com> Patchwork: https://patchwork.freedesktop.org/patch/689141/ Message-ID: <20251118152952.226510-1-robin.clark@oss.qualcomm.com>
1 parent 50a0b12 commit 036b353

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

drivers/gpu/drm/msm/registers/gen_header.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,13 @@ def dump_regpair_builder(self, reg):
189189
print(" return (struct fd_reg_pair) {")
190190
print(" .reg = (uint32_t)%s," % reg.reg_offset())
191191
print(" .value =")
192+
cast = "(uint64_t)" if reg.bit_size == 64 else ""
192193
for f in self.fields:
193194
if f.type in [ "address", "waddress" ]:
194195
continue
195196
else:
196197
type, val = f.ctype("fields.%s" % field_name(reg, f))
197-
print(" (%-40s << %2d) |" % (val, f.low))
198+
print(" (%s%-40s << %2d) |" % (cast, val, f.low))
198199
value_name = "dword"
199200
if reg.bit_size == 64:
200201
value_name = "qword"
@@ -264,10 +265,11 @@ def dump_pack_struct(self, is_deprecated, reg=None):
264265
(prefix, prefix, prefix, skip))
265266

266267

267-
def dump(self, is_deprecated, prefix=None):
268+
def dump(self, is_deprecated, prefix=None, reg=None):
268269
if prefix is None:
269270
prefix = self.name
270-
if self.reg and self.reg.bit_size == 64:
271+
reg64 = reg and self.reg and self.reg.bit_size == 64
272+
if reg64:
271273
print("static inline uint32_t %s_LO(uint32_t val)\n{" % prefix)
272274
print("\treturn val;\n}")
273275
print("static inline uint32_t %s_HI(uint32_t val)\n{" % prefix)
@@ -283,14 +285,17 @@ def dump(self, is_deprecated, prefix=None):
283285
elif f.type == "boolean" or (f.type is None and f.low == f.high):
284286
tab_to("#define %s" % name, "0x%08x" % (1 << f.low))
285287
else:
286-
tab_to("#define %s__MASK" % name, "0x%08x" % mask(f.low, f.high))
288+
typespec = "ull" if reg64 else "u"
289+
tab_to("#define %s__MASK" % name, "0x%08x%s" % (mask(f.low, f.high), typespec))
287290
tab_to("#define %s__SHIFT" % name, "%d" % f.low)
288291
type, val = f.ctype("val")
292+
ret_type = "uint64_t" if reg64 else "uint32_t"
293+
cast = "(uint64_t)" if reg64 else ""
289294

290-
print("static inline uint32_t %s(%s val)\n{" % (name, type))
295+
print("static inline %s %s(%s val)\n{" % (ret_type, name, type))
291296
if f.shr > 0:
292297
print("\tassert(!(val & 0x%x));" % mask(0, f.shr - 1))
293-
print("\treturn ((%s) << %s__SHIFT) & %s__MASK;\n}" % (val, name, name))
298+
print("\treturn (%s(%s) << %s__SHIFT) & %s__MASK;\n}" % (cast, val, name, name))
294299
print()
295300

296301
class Array(object):
@@ -437,7 +442,7 @@ def dump(self, is_deprecated):
437442
print("static inline%s uint32_t REG_%s(%s) { return 0x%08x + %s; }" % (depcrstr, self.full_name, proto, offset, strides))
438443

439444
if self.bitset.inline:
440-
self.bitset.dump(is_deprecated, self.full_name)
445+
self.bitset.dump(is_deprecated, self.full_name, self)
441446
print("")
442447

443448
def dump_pack_struct(self, is_deprecated):

0 commit comments

Comments
 (0)