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

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe: Add LRC ctx timestamp support functions

LRC ctx timestamp support functions are used to determine how long a job
has run on the hardware.

v2:
- Don't use static inlines (Jani)
- Kernel doc
- s/ctx_timestamp_job/ctx_job_timestamp
v6:
- Add kernel doc for xe_lrc_update_timestamp (Lucas)
- Call xe_lrc_ctx_timestamp() in xe_lrc_update_timestamp (Lucas)

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240611144053.2805091-2-matthew.brost@intel.com

+82 -1
+77 -1
drivers/gpu/drm/xe/xe_lrc.c
··· 652 652 653 653 #define LRC_SEQNO_PPHWSP_OFFSET 512 654 654 #define LRC_START_SEQNO_PPHWSP_OFFSET (LRC_SEQNO_PPHWSP_OFFSET + 8) 655 + #define LRC_CTX_JOB_TIMESTAMP_OFFSET (LRC_START_SEQNO_PPHWSP_OFFSET + 8) 655 656 #define LRC_PARALLEL_PPHWSP_OFFSET 2048 656 657 #define LRC_PPHWSP_SIZE SZ_4K 657 658 ··· 681 680 return xe_lrc_pphwsp_offset(lrc) + LRC_START_SEQNO_PPHWSP_OFFSET; 682 681 } 683 682 683 + static u32 __xe_lrc_ctx_job_timestamp_offset(struct xe_lrc *lrc) 684 + { 685 + /* The start seqno is stored in the driver-defined portion of PPHWSP */ 686 + return xe_lrc_pphwsp_offset(lrc) + LRC_CTX_JOB_TIMESTAMP_OFFSET; 687 + } 688 + 684 689 static inline u32 __xe_lrc_parallel_offset(struct xe_lrc *lrc) 685 690 { 686 691 /* The parallel is stored in the driver-defined portion of PPHWSP */ ··· 696 689 static inline u32 __xe_lrc_regs_offset(struct xe_lrc *lrc) 697 690 { 698 691 return xe_lrc_pphwsp_offset(lrc) + LRC_PPHWSP_SIZE; 692 + } 693 + 694 + static u32 __xe_lrc_ctx_timestamp_offset(struct xe_lrc *lrc) 695 + { 696 + return __xe_lrc_regs_offset(lrc) + CTX_TIMESTAMP * sizeof(u32); 699 697 } 700 698 701 699 static inline u32 __xe_lrc_indirect_ring_offset(struct xe_lrc *lrc) ··· 728 716 DECL_MAP_ADDR_HELPERS(seqno) 729 717 DECL_MAP_ADDR_HELPERS(regs) 730 718 DECL_MAP_ADDR_HELPERS(start_seqno) 719 + DECL_MAP_ADDR_HELPERS(ctx_job_timestamp) 720 + DECL_MAP_ADDR_HELPERS(ctx_timestamp) 731 721 DECL_MAP_ADDR_HELPERS(parallel) 732 722 DECL_MAP_ADDR_HELPERS(indirect_ring) 733 723 734 724 #undef DECL_MAP_ADDR_HELPERS 725 + 726 + /** 727 + * xe_lrc_ctx_timestamp_ggtt_addr() - Get ctx timestamp GGTT address 728 + * @lrc: Pointer to the lrc. 729 + * 730 + * Returns: ctx timestamp GGTT address 731 + */ 732 + u32 xe_lrc_ctx_timestamp_ggtt_addr(struct xe_lrc *lrc) 733 + { 734 + return __xe_lrc_ctx_timestamp_ggtt_addr(lrc); 735 + } 736 + 737 + /** 738 + * xe_lrc_ctx_timestamp() - Read ctx timestamp value 739 + * @lrc: Pointer to the lrc. 740 + * 741 + * Returns: ctx timestamp value 742 + */ 743 + u32 xe_lrc_ctx_timestamp(struct xe_lrc *lrc) 744 + { 745 + struct xe_device *xe = lrc_to_xe(lrc); 746 + struct iosys_map map; 747 + 748 + map = __xe_lrc_ctx_timestamp_map(lrc); 749 + return xe_map_read32(xe, &map); 750 + } 751 + 752 + /** 753 + * xe_lrc_ctx_job_timestamp_ggtt_addr() - Get ctx job timestamp GGTT address 754 + * @lrc: Pointer to the lrc. 755 + * 756 + * Returns: ctx timestamp job GGTT address 757 + */ 758 + u32 xe_lrc_ctx_job_timestamp_ggtt_addr(struct xe_lrc *lrc) 759 + { 760 + return __xe_lrc_ctx_job_timestamp_ggtt_addr(lrc); 761 + } 762 + 763 + /** 764 + * xe_lrc_ctx_job_timestamp() - Read ctx job timestamp value 765 + * @lrc: Pointer to the lrc. 766 + * 767 + * Returns: ctx timestamp job value 768 + */ 769 + u32 xe_lrc_ctx_job_timestamp(struct xe_lrc *lrc) 770 + { 771 + struct xe_device *xe = lrc_to_xe(lrc); 772 + struct iosys_map map; 773 + 774 + map = __xe_lrc_ctx_job_timestamp_map(lrc); 775 + return xe_map_read32(xe, &map); 776 + } 735 777 736 778 u32 xe_lrc_ggtt_addr(struct xe_lrc *lrc) 737 779 { ··· 1725 1659 kfree(snapshot); 1726 1660 } 1727 1661 1662 + /** 1663 + * xe_lrc_update_timestamp() - Update ctx timestamp 1664 + * @lrc: Pointer to the lrc. 1665 + * @old_ts: Old timestamp value 1666 + * 1667 + * Populate @old_ts current saved ctx timestamp, read new ctx timestamp and 1668 + * update saved value. 1669 + * 1670 + * Returns: New ctx timestamp value 1671 + */ 1728 1672 u32 xe_lrc_update_timestamp(struct xe_lrc *lrc, u32 *old_ts) 1729 1673 { 1730 1674 *old_ts = lrc->ctx_timestamp; 1731 1675 1732 - lrc->ctx_timestamp = xe_lrc_read_ctx_reg(lrc, CTX_TIMESTAMP); 1676 + lrc->ctx_timestamp = xe_lrc_ctx_timestamp(lrc); 1733 1677 1734 1678 return lrc->ctx_timestamp; 1735 1679 }
+5
drivers/gpu/drm/xe/xe_lrc.h
··· 94 94 void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer *p); 95 95 void xe_lrc_snapshot_free(struct xe_lrc_snapshot *snapshot); 96 96 97 + u32 xe_lrc_ctx_timestamp_ggtt_addr(struct xe_lrc *lrc); 98 + u32 xe_lrc_ctx_timestamp(struct xe_lrc *lrc); 99 + u32 xe_lrc_ctx_job_timestamp_ggtt_addr(struct xe_lrc *lrc); 100 + u32 xe_lrc_ctx_job_timestamp(struct xe_lrc *lrc); 101 + 97 102 /** 98 103 * xe_lrc_update_timestamp - readout LRC timestamp and update cached value 99 104 * @lrc: logical ring context for this exec queue