diff --git a/uadk-access-the-file-isolate-before-read-it.patch b/uadk-access-the-file-isolate-before-read-it.patch new file mode 100644 index 0000000..d5b462c --- /dev/null +++ b/uadk-access-the-file-isolate-before-read-it.patch @@ -0,0 +1,60 @@ +From 3b86295963c24a1dc0ec0da9e1e7f16aced8f3a4 Mon Sep 17 00:00:00 2001 +From: Yang Shen +Date: Tue, 24 Aug 2021 11:24:25 +0800 +Subject: [PATCH] uadk: 'access' the file 'isolate' before read it + +The feature 'isolate' isn't enabled for all 'uacce' versions. So need check +whether this feature is enabled before read it value. + +Signed-off-by: Yang Shen +--- + wd.c | 25 ++++++++++++++++++++++--- + 1 file changed, 22 insertions(+), 3 deletions(-) + +diff --git a/uadk/wd.c b/uadk/wd.c +index 2d7fc49..bc347e7 100644 +--- a/uadk/wd.c ++++ b/uadk/wd.c +@@ -104,17 +104,36 @@ static int get_str_attr(struct uacce_dev *dev, char *attr, char *buf, + return ret; + } + ++static int access_attr(char *dev_root, char *attr, int mode) ++{ ++ char attr_file[PATH_STR_SIZE]; ++ ssize_t size; ++ ++ if (!dev_root || !attr) ++ return -WD_EINVAL; ++ ++ size = snprintf(attr_file, PATH_STR_SIZE, "%s/%s", dev_root, attr); ++ if (size < 0) ++ return -WD_EINVAL; ++ ++ return access(attr_file, mode); ++} ++ + static int get_dev_info(struct uacce_dev *dev) + { + int value = 0; ++ int ret; + + get_int_attr(dev, "flags", &dev->flags); + get_str_attr(dev, "api", dev->api, WD_NAME_SIZE); + + /* hardware err isolate flag */ +- get_int_attr(dev, "isolate", &value); +- if (value == 1) +- return -ENODEV; ++ ret = access_attr(dev->dev_root, "isolate", F_OK); ++ if (!ret) { ++ get_int_attr(dev, "isolate", &value); ++ if (value == 1) ++ return -ENODEV; ++ } + + get_str_attr(dev, "algorithms", dev->algs, MAX_ATTR_STR_SIZE); + get_int_attr(dev, "region_mmio_size", &value); +-- +2.33.0 + diff --git a/warpdrive.spec b/warpdrive.spec index 79d29c5..868ed67 100644 --- a/warpdrive.spec +++ b/warpdrive.spec @@ -1,12 +1,12 @@ Name: libwd Summary: User Space Accelerator Development Kit Version: 2.3.11 -Release: 3 +Release: 4 License: Apache-2.0 Source: %{name}-%{version}.tar.gz Vendor: Huawei Corporation ExclusiveOS: linux -URL: https://support.huawei.com +URL: https://support.huawei.com BuildRoot: %{_tmppath}/%{name}-%{version}-root Conflicts: %{name} < %{version}-%{release} Provides: %{name} = %{version}-%{release} @@ -15,6 +15,7 @@ BuildRequires: automake, autoconf, libtool BuildRequires: gcc, make ExclusiveArch: aarch64 Patch0001: bugfix-of-gcc-10.patch +Patch0002: uadk-access-the-file-isolate-before-read-it.patch %description This package contains the User Space Accelerator Library @@ -155,6 +156,9 @@ fi /sbin/ldconfig %changelog +* Fri Sep 03 2021 Yang Shen 2.3.11-4 +- uadk-access-the-file-isolate-before-read-it.patch + * Fri Aug 06 2021 Pengju Jiang 2.3.11-3 - bugfix-of-gcc-10.patch