Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/panthor: Support 64-bit endpoint_req register for Mali-G1

Add support for the 64-bit endpoint_req register introduced in CSF v4.0+
GPUs. Unlike a simple register widening, the 64-bit variant occupies the
next 64 bits after the original 32-bit field, requiring
version-dependent access.

This change introduces helper functions to read, write, and update the
endpoint_req register, ensuring correct handling on both pre-v4.0 and
v4.0+ firmwares.

Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Karunika Choo <karunika.choo@arm.com>
Link: https://patch.msgid.link/20251125125548.3282320-8-karunika.choo@arm.com
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

authored by

Karunika Choo and committed by
Boris Brezillon
2008f49a 51407254

+72 -10
+36
drivers/gpu/drm/panthor/panthor_fw.c
··· 326 326 return glb_iface->control->version >= CSF_IFACE_VERSION(4, 1, 0); 327 327 } 328 328 329 + static bool panthor_fw_has_64bit_ep_req(struct panthor_device *ptdev) 330 + { 331 + struct panthor_fw_global_iface *glb_iface = panthor_fw_get_glb_iface(ptdev); 332 + 333 + return glb_iface->control->version >= CSF_IFACE_VERSION(4, 0, 0); 334 + } 335 + 336 + u64 panthor_fw_csg_endpoint_req_get(struct panthor_device *ptdev, 337 + struct panthor_fw_csg_iface *csg_iface) 338 + { 339 + if (panthor_fw_has_64bit_ep_req(ptdev)) 340 + return csg_iface->input->endpoint_req2; 341 + else 342 + return csg_iface->input->endpoint_req; 343 + } 344 + 345 + void panthor_fw_csg_endpoint_req_set(struct panthor_device *ptdev, 346 + struct panthor_fw_csg_iface *csg_iface, u64 value) 347 + { 348 + if (panthor_fw_has_64bit_ep_req(ptdev)) 349 + csg_iface->input->endpoint_req2 = value; 350 + else 351 + csg_iface->input->endpoint_req = lower_32_bits(value); 352 + } 353 + 354 + void panthor_fw_csg_endpoint_req_update(struct panthor_device *ptdev, 355 + struct panthor_fw_csg_iface *csg_iface, u64 value, 356 + u64 mask) 357 + { 358 + if (panthor_fw_has_64bit_ep_req(ptdev)) 359 + panthor_fw_update_reqs64(csg_iface, endpoint_req2, value, mask); 360 + else 361 + panthor_fw_update_reqs(csg_iface, endpoint_req, lower_32_bits(value), 362 + lower_32_bits(mask)); 363 + } 364 + 329 365 /** 330 366 * panthor_fw_conv_timeout() - Convert a timeout into a cycle-count 331 367 * @ptdev: Device.
+23 -2
drivers/gpu/drm/panthor/panthor_fw.h
··· 167 167 #define CSG_EP_REQ_TILER(x) (((x) << 16) & GENMASK(19, 16)) 168 168 #define CSG_EP_REQ_EXCL_COMPUTE BIT(20) 169 169 #define CSG_EP_REQ_EXCL_FRAGMENT BIT(21) 170 - #define CSG_EP_REQ_PRIORITY(x) (((x) << 28) & GENMASK(31, 28)) 171 170 #define CSG_EP_REQ_PRIORITY_MASK GENMASK(31, 28) 171 + #define CSG_EP_REQ_PRIORITY(x) (((x) << 28) & CSG_EP_REQ_PRIORITY_MASK) 172 + #define CSG_EP_REQ_PRIORITY_GET(x) (((x) & CSG_EP_REQ_PRIORITY_MASK) >> 28) 172 173 u32 endpoint_req; 173 - u32 reserved2[2]; 174 + u64 endpoint_req2; 174 175 u64 suspend_buf; 175 176 u64 protm_suspend_buf; 176 177 u32 config; ··· 465 464 spin_unlock(&(__iface)->lock); \ 466 465 } while (0) 467 466 467 + #define panthor_fw_update_reqs64(__iface, __in_reg, __val, __mask) \ 468 + do { \ 469 + u64 __cur_val, __new_val; \ 470 + spin_lock(&(__iface)->lock); \ 471 + __cur_val = READ_ONCE((__iface)->input->__in_reg); \ 472 + __new_val = (__cur_val & ~(__mask)) | ((__val) & (__mask)); \ 473 + WRITE_ONCE((__iface)->input->__in_reg, __new_val); \ 474 + spin_unlock(&(__iface)->lock); \ 475 + } while (0) 476 + 468 477 struct panthor_fw_global_iface * 469 478 panthor_fw_get_glb_iface(struct panthor_device *ptdev); 470 479 ··· 483 472 484 473 struct panthor_fw_cs_iface * 485 474 panthor_fw_get_cs_iface(struct panthor_device *ptdev, u32 csg_slot, u32 cs_slot); 475 + 476 + u64 panthor_fw_csg_endpoint_req_get(struct panthor_device *ptdev, 477 + struct panthor_fw_csg_iface *csg_iface); 478 + 479 + void panthor_fw_csg_endpoint_req_set(struct panthor_device *ptdev, 480 + struct panthor_fw_csg_iface *csg_iface, u64 value); 481 + 482 + void panthor_fw_csg_endpoint_req_update(struct panthor_device *ptdev, 483 + struct panthor_fw_csg_iface *csg_iface, u64 value, 484 + u64 mask); 486 485 487 486 int panthor_fw_csg_wait_acks(struct panthor_device *ptdev, u32 csg_id, u32 req_mask, 488 487 u32 *acked, u32 timeout_ms);
+13 -8
drivers/gpu/drm/panthor/panthor_sched.c
··· 1140 1140 { 1141 1141 struct panthor_csg_slot *csg_slot = &ptdev->scheduler->csg_slots[csg_id]; 1142 1142 struct panthor_fw_csg_iface *csg_iface; 1143 + u64 endpoint_req; 1143 1144 1144 1145 lockdep_assert_held(&ptdev->scheduler->lock); 1145 1146 1146 1147 csg_iface = panthor_fw_get_csg_iface(ptdev, csg_id); 1147 - csg_slot->priority = (csg_iface->input->endpoint_req & CSG_EP_REQ_PRIORITY_MASK) >> 28; 1148 + endpoint_req = panthor_fw_csg_endpoint_req_get(ptdev, csg_iface); 1149 + csg_slot->priority = CSG_EP_REQ_PRIORITY_GET(endpoint_req); 1148 1150 } 1149 1151 1150 1152 /** ··· 1306 1304 struct panthor_csg_slot *csg_slot; 1307 1305 struct panthor_group *group; 1308 1306 u32 queue_mask = 0, i; 1307 + u64 endpoint_req; 1309 1308 1310 1309 lockdep_assert_held(&ptdev->scheduler->lock); 1311 1310 ··· 1333 1330 csg_iface->input->allow_compute = group->compute_core_mask; 1334 1331 csg_iface->input->allow_fragment = group->fragment_core_mask; 1335 1332 csg_iface->input->allow_other = group->tiler_core_mask; 1336 - csg_iface->input->endpoint_req = CSG_EP_REQ_COMPUTE(group->max_compute_cores) | 1337 - CSG_EP_REQ_FRAGMENT(group->max_fragment_cores) | 1338 - CSG_EP_REQ_TILER(group->max_tiler_cores) | 1339 - CSG_EP_REQ_PRIORITY(priority); 1333 + endpoint_req = CSG_EP_REQ_COMPUTE(group->max_compute_cores) | 1334 + CSG_EP_REQ_FRAGMENT(group->max_fragment_cores) | 1335 + CSG_EP_REQ_TILER(group->max_tiler_cores) | 1336 + CSG_EP_REQ_PRIORITY(priority); 1337 + panthor_fw_csg_endpoint_req_set(ptdev, csg_iface, endpoint_req); 1338 + 1340 1339 csg_iface->input->config = panthor_vm_as(group->vm); 1341 1340 1342 1341 if (group->suspend_buf) ··· 2236 2231 continue; 2237 2232 } 2238 2233 2239 - panthor_fw_update_reqs(csg_iface, endpoint_req, 2240 - CSG_EP_REQ_PRIORITY(new_csg_prio), 2241 - CSG_EP_REQ_PRIORITY_MASK); 2234 + panthor_fw_csg_endpoint_req_update(ptdev, csg_iface, 2235 + CSG_EP_REQ_PRIORITY(new_csg_prio), 2236 + CSG_EP_REQ_PRIORITY_MASK); 2242 2237 csgs_upd_ctx_queue_reqs(ptdev, &upd_ctx, csg_id, 2243 2238 csg_iface->output->ack ^ CSG_ENDPOINT_CONFIG, 2244 2239 CSG_ENDPOINT_CONFIG);