2 * Copyright (c) 2014-2016 ARM Limited
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * Authors: Andreas Sandberg
25 #include "jobcontrol.hh"
27 #include "regutils.hh"
31 static const Status
STATUS_IDLE(Status::CLASS_NOFAULT
, 0, 0);
32 static const Status
STATUS_DONE(Status::CLASS_NOFAULT
, 0, 1);
33 static const Status
STATUS_ACTIVE(Status::CLASS_NOFAULT
, 1, 0);
35 const std::vector
<JobSlot::cmd_t
> JobSlot::cmds
{
36 &JobSlot::cmdNop
, // JSn_COMMAND_NOP
37 &JobSlot::cmdStart
, // JSn_COMMAND_START
38 &JobSlot::cmdSoftStop
, // JSn_COMMAND_SOFT_STOP
39 &JobSlot::cmdHardStop
, // JSn_COMMAND_HARD_STOP
40 &JobSlot::cmdSoftStop0
, // JSn_COMMAND_SOFT_STOP_0
41 &JobSlot::cmdHardStop0
, // JSn_COMMAND_HARD_STOP_0
42 &JobSlot::cmdSoftStop1
, // JSn_COMMAND_SOFT_STOP_1
43 &JobSlot::cmdHardStop1
, // JSn_COMMAND_HARD_STOP_1
46 JobSlot::JobSlot(GPU
&_gpu
, JobControl
&_jc
, uint8_t _id
)
47 : GPUBlock(_gpu
, JSn_NO_REGS
),
53 JobSlot::JobSlot(JobSlot
&&rhs
)
54 : GPUBlock(std::move(rhs
)),
55 id(std::move(rhs
.id
)),
65 JobSlot::writeReg(RegAddr addr
, uint32_t value
)
72 case JSn_COMMAND_NEXT
:
77 case JSn_HEAD_NEXT_LO
:
78 case JSn_HEAD_NEXT_HI
:
79 case JSn_AFFINITY_NEXT_LO
:
80 case JSn_AFFINITY_NEXT_HI
:
82 GPUBlock::writeReg(addr
, value
);
86 // Ignore writes by default
92 JobSlot::active() const
98 JobSlot::activeNext() const
100 return regs
[RegAddr(JSn_COMMAND_NEXT
)] == JSn_COMMAND_START
;
106 // Only actually start something if the next command is start
107 if (regs
[RegAddr(JSn_COMMAND_NEXT
)] != JSn_COMMAND_START
)
110 // Reset the status register
111 regs
[RegAddr(JSn_STATUS
)] = STATUS_ACTIVE
.value
;
113 // Transfer the next job configuration to the active job
115 regs
.set64(RegAddr(JSn_HEAD_LO
), regs
.get64(RegAddr(JSn_HEAD_NEXT_LO
)));
116 regs
.set64(RegAddr(JSn_TAIL_LO
), regs
.get64(RegAddr(JSn_HEAD_NEXT_LO
)));
117 regs
.set64(RegAddr(JSn_AFFINITY_LO
),
118 regs
.get64(RegAddr(JSn_AFFINITY_NEXT_LO
)));
119 regs
[RegAddr(JSn_CONFIG
)] = regs
[RegAddr(JSn_CONFIG_NEXT
)];
121 // Reset the next job configuration
122 regs
.set64(RegAddr(JSn_HEAD_NEXT_LO
), 0);
123 regs
[RegAddr(JSn_COMMAND_NEXT
)] = 0;
132 0); // Time stamp counter value
136 JobSlot::exitJob(Status status
, uint64_t fault_address
)
138 assert(status
.statusClass() == Status::CLASS_NOFAULT
||
139 status
.statusClass() == Status::CLASS_JOB
);
141 regs
[RegAddr(JSn_STATUS
)] = status
.value
;
143 if (status
.statusClass() == Status::CLASS_NOFAULT
) {
151 JobSlot::jobCommand(uint32_t cmd
)
153 if (cmd
< cmds
.size())
154 (this->*cmds
[cmd
])(cmd
);
158 JobSlot::cmdNop(uint32_t cmd
)
160 assert(cmd
== JSn_COMMAND_NOP
);
164 JobSlot::cmdStart(uint32_t cmd
)
166 assert(cmd
== JSn_COMMAND_START
);
167 // The JSn_COMMAND_START should never be issued through the
168 // JSn_COMMAND register. It should use the JSn_COMMAND_NEXT
174 JobSlot::cmdSoftStop(uint32_t cmd
)
176 assert(cmd
== JSn_COMMAND_SOFT_STOP
||
177 cmd
== JSn_COMMAND_SOFT_STOP_0
||
178 cmd
== JSn_COMMAND_SOFT_STOP_1
);
182 JobSlot::cmdHardStop(uint32_t cmd
)
184 assert(cmd
== JSn_COMMAND_HARD_STOP
||
185 cmd
== JSn_COMMAND_HARD_STOP_0
||
186 cmd
== JSn_COMMAND_HARD_STOP_1
);
190 JobSlot::cmdSoftStop0(uint32_t cmd
)
192 if (!(regs
[RegAddr(JSn_CONFIG
)] & JSn_CONFIG_JOB_CHAIN_FLAG
))
197 JobSlot::cmdHardStop0(uint32_t cmd
)
199 if (!(regs
[RegAddr(JSn_CONFIG
)] & JSn_CONFIG_JOB_CHAIN_FLAG
))
204 JobSlot::cmdSoftStop1(uint32_t cmd
)
206 if (regs
[RegAddr(JSn_CONFIG
)] & JSn_CONFIG_JOB_CHAIN_FLAG
)
211 JobSlot::cmdHardStop1(uint32_t cmd
)
213 if (regs
[RegAddr(JSn_CONFIG
)] & JSn_CONFIG_JOB_CHAIN_FLAG
)