Skip to content

Commit

Permalink
Fully implement the nvdrv Host1xChannel::Submit operation
Browse files Browse the repository at this point in the history
This pushes a set of command buffers into the Host1x command FIFO allocated for the channel, returning fence thresholds that can be waited on for completion,
  • Loading branch information
bylaws authored and PixelyIon committed Nov 10, 2021
1 parent baefb0f commit dbfb1cf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace skyline::service::nvdrv::device::nvhost {
const SessionContext &ctx,
core::ChannelType channelType)
: NvDevice(state, driver, core, ctx),
channelType(channelType) {}
channelType(channelType) {
state.soc->host1x.channels[static_cast<size_t>(channelType)].Start();
}

PosixResult Host1XChannel::SetNvmapFd(In<FileDescriptor> fd) {
state.logger->Debug("fd: {}", fd);
Expand All @@ -25,6 +27,34 @@ namespace skyline::service::nvdrv::device::nvhost {
state.logger->Debug("numCmdBufs: {}, numRelocs: {}, numSyncpointIncrs: {}, numFenceThresholds: {}",
cmdBufs.size(), relocs.size(), syncpointIncrs.size(), fenceThresholds.size());

if (fenceThresholds.size() > syncpointIncrs.size())
return PosixResult::InvalidArgument;

if (!relocs.empty())
throw exception("Relocations are unimplemented!");

std::scoped_lock lock(channelMutex);

for (size_t i{}; i < syncpointIncrs.size(); i++) {
const auto &incr{syncpointIncrs[i]};

u32 max{core.syncpointManager.IncrementSyncpointMaxExt(incr.syncpointId, incr.numIncrs)};
if (i < fenceThresholds.size())
fenceThresholds[i] = max;
}

for (const auto &cmdBuf : cmdBufs) {
auto handleDesc{core.nvMap.GetHandle(cmdBuf.mem)};
if (!handleDesc)
throw exception("Invalid handle passed for a command buffer!");

u64 gatherAddress{handleDesc->address + cmdBuf.offset};
state.logger->Debug("Submit gather, CPU address: 0x{:X}, words: 0x{:X}", gatherAddress, cmdBuf.words);

span gather(reinterpret_cast<u32 *>(gatherAddress), cmdBuf.words);
state.soc->host1x.channels[static_cast<size_t>(channelType)].Push(gather);
}

return PosixResult::Success;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace skyline::service::nvdrv::device::nvhost {
*/
struct SubmitCmdBuf {
core::NvMap::Handle::Id mem;
u32 offset; //!< Offset from the handle of where the gather should start
u32 offset; //!< Offset in bytes from the handle of where the gather should start
u32 words; //!< Size for the gather in 4 byte words
};

Expand Down

0 comments on commit dbfb1cf

Please sign in to comment.