Skip to content

Commit

Permalink
Merge pull request #30 from maxzhen/sync
Browse files Browse the repository at this point in the history
Update source code
  • Loading branch information
maxzhen authored Apr 1, 2024
2 parents 758e848 + a06eafe commit 9fdd169
Show file tree
Hide file tree
Showing 59 changed files with 3,556 additions and 4,627 deletions.
7 changes: 0 additions & 7 deletions CMake/config/postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ udev_rules_d=/etc/udev/rules.d
amdxdna_rules_file=99-amdxdna.rules
export XILINX_XRT=$installdir

echo "Creating xclbin firmware symbolic link"
if [ "$build_type" = "Debug" ]; then
$installdir/amdxdna/setup_xclbin_firmware.sh -v
else
$installdir/amdxdna/setup_xclbin_firmware.sh
fi

echo "Installing new amdxdna Linux kernel module in dkms"
if [ "$build_type" = "Debug" ]; then
DKMS_DRIVER_VERBOSE=true $installdir/amdxdna/dkms_driver.sh --install
Expand Down
2 changes: 0 additions & 2 deletions CMake/config/prerm.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ fi

export XILINX_XRT=$installdir
if [ "$build_type" = "Debug" ]; then
$installdir/amdxdna/setup_xclbin_firmware.sh -v -clean
DKMS_DRIVER_VERBOSE=true $installdir/amdxdna/dkms_driver.sh --remove
else
$installdir/amdxdna/setup_xclbin_firmware.sh -clean
$installdir/amdxdna/dkms_driver.sh --remove
fi
unset XILINX_XRT
Expand Down
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,6 @@ TL;DR, run `sudo insmod amdxdna.ko dyndbg==p` to enable XDNA_DBG() globally.

A: Create a debug DEB package, see above question. Then install debug DEB package in your environment. This time, you will have more verbose log. Share this log with us.

### Q: I see "Failed to load xclbin firmware" error in dmesg. How to fix this?

A: In amdxdna driver, it will not directly use the xclbin passed from application. Instead, it loads verified xclbin from /lib/firmware/amdnpu/ directory.
The driver will check if the UUID of the xclbin from application and firmware directory matched. If this match process failed, you will see this error.

### Q: I need to test a unverified xclbin . I know what I'm doing. Can I get rid of the "Failed to load xclbin firmware" error?

A: Yes. Make sure you have root privilege of the system. Follow below steps,
``` bash
# Assume you already have xrt_plugin DEB package installed
# You need root privilege to install firmware
sudo bash

source /opt/xilinx/xrt/setup.sh

# List supported device(s)
/opt/xilinx/xrt/amdxdna/setup_xclbin_firmware.sh -list

# Assume adding an unsigned xclbin on Phoenix, run
/opt/xilinx/xrt/amdxdna/setup_xclbin_firmware.sh -dev Phoenix -xclbin <test>.xclbin

# When xrt_plugin package is removed, it will be automaticlly cleaned up.
# User is able to setup multiple xclbins. But if setup two xclbins with the same file name,
# the previous one will be overwritten.
```

## Contributor Guidelines
1. Read [Getting Started](#getting-started)
2. Read [System Requirements](#system-requirements)
Expand Down
32 changes: 31 additions & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,33 @@ build_example()
cd ..
}

download_xclbins()
{
#TODO: figure out the validate.xclbin location
local firmware_dir=${DOWNLOAD_BINS_DIR}/firmware

jq -c '.xclbins[]' "$INFO_JSON" |
while IFS= read -r line; do
local device=$(echo $line | jq -r '.device')
local pci_dev_id=$(echo $line | jq -r '.pci_device_id')
local pci_rev_id=$(echo $line | jq -r '.pci_revision_id')
local name=$(echo $line | jq -r '.name')
local url=$(echo $line | jq -r '.url')

if [[ -z "$url" ]]; then
echo "Empty URL for $device xclbin $name"
exit 1
fi

echo "Download $device XCLBIN $name :"
if [ ! -d "${firmware_dir}/${pci_dev_id}_${pci_rev_id}" ]; then
mkdir -p ${firmware_dir}/${pci_dev_id}_${pci_rev_id}
fi
wget -O ${firmware_dir}/${pci_dev_id}_${pci_rev_id}/$name $url

done
}

download_npufws()
{
local firmware_dir=${DOWNLOAD_BINS_DIR}/firmware
Expand Down Expand Up @@ -113,7 +140,7 @@ download_npufws()
# Config variables
clean=0
distclean=0
debug=0
debug=1
release=0
package=0
example=0
Expand All @@ -138,8 +165,10 @@ while [ $# -gt 0 ]; do
;;
-debug)
debug=1
release=0
;;
-release)
debug=0
release=1
;;
-example)
Expand Down Expand Up @@ -219,6 +248,7 @@ fi

if [[ $package == 1 ]]; then
download_npufws
download_xclbins
package_targets $DEBUG_BUILD_TYPE
package_targets $RELEASE_BUILD_TYPE
exit 0
Expand Down
9 changes: 6 additions & 3 deletions src/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ set(XDNA_DRV amdxdna)

set(XDNA_DRV_DIR amdxdna)
set(XDNA_DRV_TGT ${XDNA_DRV}.ko)
set(XDNA_DRV_PATH ${CMAKE_BINARY_DIR}/driver/${XDNA_DRV_TGT})
set(XDNA_DRV_BLD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${XDNA_DRV_DIR})
set(XDNA_DRV_BLD_TGT ${CMAKE_CURRENT_BINARY_DIR}/${XDNA_DRV_DIR})
add_custom_command(
OUTPUT ${XDNA_DRV_TGT}
COMMENT "Build ${XDNA_DRV_TGT}"
COMMAND $(MAKE) -f ${XDNA_DRV_BLD_SRC}/Makefile BUILD_DIR=${XDNA_DRV_BLD_TGT} SRC_DIR=${XDNA_DRV_BLD_SRC} ${KERNEL_VER}
COMMAND $(CMAKE_COMMAND) -E copy ${XDNA_DRV_BLD_TGT}/${XDNA_DRV_TGT} ${CMAKE_BINARY_DIR}/driver/${XDNA_DRV_TGT}
COMMAND $(CMAKE_COMMAND) -E copy ${XDNA_DRV_BLD_TGT}/${XDNA_DRV_TGT} ${XDNA_DRV_PATH}
)
add_custom_target(driver DEPENDS ${XDNA_DRV_TGT})
add_custom_target(driver ALL DEPENDS ${XDNA_DRV_TGT})

# Tar and install driver source code for packaging
set(XDNA_DRV_SRC_DIR
Expand Down Expand Up @@ -74,10 +75,12 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dkms.conf

set(amdxdna_drv_tools
${CMAKE_CURRENT_SOURCE_DIR}/tools/dkms_driver.sh
${CMAKE_CURRENT_SOURCE_DIR}/tools/setup_xclbin_firmware.sh
)
install(FILES ${amdxdna_drv_tools}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION xrt/${XDNA_COMPONENT}
COMPONENT ${XDNA_COMPONENT}
)

# install .ko for testing
install(FILES ${XDNA_DRV_PATH} DESTINATION ${XDNA_BIN_DIR}/driver)
20 changes: 10 additions & 10 deletions src/driver/amdxdna/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ ccflags-y += -g -Werror

obj-m += amdxdna.o
amdxdna-y := \
solver.o \
amdxdna_xclbin.o \
amdxdna_ctx.o \
amdxdna_gem.o \
amdxdna_util.o \
amdxdna_sysfs.o \
npu_smu.o \
npu_error.o \
npu_debugfs.o \
npu_pci.o \
npu_message.o \
npu_solver.o \
npu_mailbox.o \
npu_common.o \
npu1_smu.o \
npu1_psp.o \
npu1_ctx.o \
npu1_error.o \
npu1_debugfs.o \
npu1_message.o \
npu1_pci.o \
npu1_regs.o \
npu2_regs.o \
npu4_regs.o \
amdxdna_mailbox.o \
amdxdna_psp.o \
amdxdna_drv.o

# Helper functions for amdxdna development, but not for upstreaming
Expand Down
Loading

0 comments on commit 9fdd169

Please sign in to comment.