Commit e84e31a9 authored by Rajaravi Krishna Katta's avatar Rajaravi Krishna Katta Committed by Oded Gabbay
Browse files

habanalabs: add dedicated message towards f/w to set power



CPUCP_PACKET_POWER_GET packet type was used for both
hl_get_power() and hl_set_power().

To align with other sensor functions hl_set_power()
should use CPUCP_PACKET_POWER_SET.

This packet will only be used with newer ASICs, so need to add
a compatibility flag to the asic properties to indicate whether to use
this packet or the GET packet.

Signed-off-by: default avatarRajaravi Krishna Katta <rkatta@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 13885822
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -546,6 +546,8 @@ struct hl_hints_range {
 * @dynamic_fw_load: is dynamic FW load is supported.
 * @gic_interrupts_enable: true if FW is not blocking GIC controller,
 *                         false otherwise.
 * @use_get_power_for_reset_history: To support backward compatibility for Goya
 *                                   and Gaudi
 */
struct asic_fixed_properties {
	struct hw_queue_properties	*hw_queues_props;
@@ -626,6 +628,7 @@ struct asic_fixed_properties {
	u8				iatu_done_by_fw;
	u8				dynamic_fw_load;
	u8				gic_interrupts_enable;
	u8				use_get_power_for_reset_history;
};

/**
+7 −1
Original line number Diff line number Diff line
@@ -677,12 +677,18 @@ int hl_set_power(struct hl_device *hdev,
			int sensor_index, u32 attr, long value)
{
	struct cpucp_packet pkt;
	struct asic_fixed_properties *prop = &hdev->asic_prop;
	int rc;

	memset(&pkt, 0, sizeof(pkt));

	if (prop->use_get_power_for_reset_history)
		pkt.ctl = cpu_to_le32(CPUCP_PACKET_POWER_GET <<
				CPUCP_PKT_CTL_OPCODE_SHIFT);
	else
		pkt.ctl = cpu_to_le32(CPUCP_PACKET_POWER_SET <<
				CPUCP_PKT_CTL_OPCODE_SHIFT);

	pkt.sensor_index = __cpu_to_le16(sensor_index);
	pkt.type = __cpu_to_le16(attr);
	pkt.value = __cpu_to_le64(value);
+2 −0
Original line number Diff line number Diff line
@@ -665,6 +665,8 @@ static int gaudi_set_fixed_properties(struct hl_device *hdev)
	prop->clk_pll_index = HL_GAUDI_MME_PLL;
	prop->max_freq_value = GAUDI_MAX_CLK_FREQ;

	prop->use_get_power_for_reset_history = true;

	return 0;
}

+2 −0
Original line number Diff line number Diff line
@@ -475,6 +475,8 @@ int goya_set_fixed_properties(struct hl_device *hdev)

	prop->clk_pll_index = HL_GOYA_MME_PLL;

	prop->use_get_power_for_reset_history = true;

	return 0;
}

+4 −0
Original line number Diff line number Diff line
@@ -376,6 +376,9 @@ enum pq_init_status {
 *       and QMANs. The f/w will return a bitmask where each bit represents
 *       a different engine or QMAN according to enum cpucp_idle_mask.
 *       The bit will be 1 if the engine is NOT idle.
 *
 * CPUCP_PACKET_POWER_SET -
 *       Resets power history of device to 0
 */

enum cpucp_packet_id {
@@ -421,6 +424,7 @@ enum cpucp_packet_id {
	CPUCP_PACKET_NIC_STAT_REGS_CLR,		/* internal */
	CPUCP_PACKET_NIC_STAT_REGS_ALL_GET,	/* internal */
	CPUCP_PACKET_IS_IDLE_CHECK,		/* internal */
	CPUCP_PACKET_POWER_SET,			/* internal */
};

#define CPUCP_PACKET_FENCE_VAL	0xFE8CE7A5