gpu: nvgpu: add conversion function for gpu alarm events

In order to enable the movement of clk arbitrator to common
code, we need to remove the NVGPU_GPU_EVENT_* defines (which
are present in uapi) and instead use the common code defines.
Add a conversion function for the same.
With this the uapi header is no longer required to be included
inside clk_arb.c

Jira VQRM-3741

Change-Id: If01614b01733876046f98b97e70285c52bc33e45
Signed-off-by: Sourab Gupta <sourabg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1699241
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sourab Gupta
2018-04-20 10:25:16 +05:30
committed by mobile promotions
parent c92afad630
commit 0ad40e83db
3 changed files with 68 additions and 4 deletions

View File

@@ -24,7 +24,6 @@
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
#endif
#include <uapi/linux/nvgpu.h>
#include <nvgpu/bitops.h>
#include <nvgpu/lock.h>
@@ -1184,7 +1183,7 @@ mutex_fail:
void nvgpu_clk_arb_send_thermal_alarm(struct gk20a *g)
{
nvgpu_clk_arb_schedule_alarm(g,
(0x1UL << NVGPU_GPU_EVENT_ALARM_THERMAL_ABOVE_THRESHOLD));
(0x1UL << NVGPU_EVENT_ALARM_THERMAL_ABOVE_THRESHOLD));
}
void nvgpu_clk_arb_schedule_alarm(struct gk20a *g, u32 alarm)

View File

@@ -97,6 +97,43 @@ static int nvgpu_clk_arb_release_event_dev(struct inode *inode,
return 0;
}
static inline u32 nvgpu_convert_gpu_event(u32 nvgpu_event)
{
u32 nvgpu_gpu_event;
switch (nvgpu_event) {
case NVGPU_EVENT_VF_UPDATE:
nvgpu_gpu_event = NVGPU_GPU_EVENT_VF_UPDATE;
break;
case NVGPU_EVENT_ALARM_TARGET_VF_NOT_POSSIBLE:
nvgpu_gpu_event = NVGPU_GPU_EVENT_ALARM_TARGET_VF_NOT_POSSIBLE;
break;
case NVGPU_EVENT_ALARM_LOCAL_TARGET_VF_NOT_POSSIBLE:
nvgpu_gpu_event = NVGPU_GPU_EVENT_ALARM_LOCAL_TARGET_VF_NOT_POSSIBLE;
break;
case NVGPU_EVENT_ALARM_CLOCK_ARBITER_FAILED:
nvgpu_gpu_event = NVGPU_GPU_EVENT_ALARM_CLOCK_ARBITER_FAILED;
break;
case NVGPU_EVENT_ALARM_VF_TABLE_UPDATE_FAILED:
nvgpu_gpu_event = NVGPU_GPU_EVENT_ALARM_VF_TABLE_UPDATE_FAILED;
break;
case NVGPU_EVENT_ALARM_THERMAL_ABOVE_THRESHOLD:
nvgpu_gpu_event = NVGPU_GPU_EVENT_ALARM_THERMAL_ABOVE_THRESHOLD;
break;
case NVGPU_EVENT_ALARM_POWER_ABOVE_THRESHOLD:
nvgpu_gpu_event = NVGPU_GPU_EVENT_ALARM_POWER_ABOVE_THRESHOLD;
break;
case NVGPU_EVENT_ALARM_GPU_LOST:
nvgpu_gpu_event = NVGPU_GPU_EVENT_ALARM_GPU_LOST;
break;
default:
/* Control shouldn't come here */
nvgpu_gpu_event = NVGPU_GPU_EVENT_ALARM_GPU_LOST + 1;
break;
}
return nvgpu_gpu_event;
}
static inline u32 __pending_event(struct nvgpu_clk_dev *dev,
struct nvgpu_gpu_event_info *info) {
@@ -112,7 +149,7 @@ static inline u32 __pending_event(struct nvgpu_clk_dev *dev,
if (_WRAPGTEQ(tail, head) && info) {
head++;
p_notif = &dev->queue.notifications[head % dev->queue.size];
events |= p_notif->notification;
events |= nvgpu_convert_gpu_event(p_notif->notification);
info->event_id = ffs(events) - 1;
info->timestamp = p_notif->timestamp;
nvgpu_atomic_set(&dev->queue.head, head);

View File

@@ -57,8 +57,36 @@ struct nvgpu_clk_session;
__fls((a)->pstates & (b)->pstates) :\
VF_POINT_INVALID_PSTATE)
/*
* These events, defined in common code are the counterparts of the uapi
* events. There should be a conversion function to take care to convert
* these to the uapi events.
*/
/* Event associated to a VF update */
#define NVGPU_EVENT_VF_UPDATE 0
/* Recoverable alarms (POLLPRI) */
/* Alarm when target frequency on any session is not possible */
#define NVGPU_EVENT_ALARM_TARGET_VF_NOT_POSSIBLE 1
/* Alarm when target frequency on current session is not possible */
#define NVGPU_EVENT_ALARM_LOCAL_TARGET_VF_NOT_POSSIBLE 2
/* Alarm when Clock Arbiter failed */
#define NVGPU_EVENT_ALARM_CLOCK_ARBITER_FAILED 3
/* Alarm when VF table update failed */
#define NVGPU_EVENT_ALARM_VF_TABLE_UPDATE_FAILED 4
/* Alarm on thermal condition */
#define NVGPU_EVENT_ALARM_THERMAL_ABOVE_THRESHOLD 5
/* Alarm on power condition */
#define NVGPU_EVENT_ALARM_POWER_ABOVE_THRESHOLD 6
/* Non recoverable alarm (POLLHUP) */
/* Alarm on GPU shutdown/fall from bus */
#define NVGPU_EVENT_ALARM_GPU_LOST 7
#define NVGPU_EVENT_LAST NVGPU_EVENT_ALARM_GPU_LOST
/* Local Alarms */
#define EVENT(alarm) (0x1UL << NVGPU_GPU_EVENT_##alarm)
#define EVENT(alarm) (0x1UL << NVGPU_EVENT_##alarm)
#define LOCAL_ALARM_MASK (EVENT(ALARM_LOCAL_TARGET_VF_NOT_POSSIBLE) | \
EVENT(VF_UPDATE))