1
0
mirror of https://github.com/systemd/systemd synced 2026-03-27 17:24:51 +01:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Yao Wei (魏銘廷)
ed938716cd Add additional Dell models that require ACCEL_LOCATION=base
This is a related commit to the bug reported in Ubuntu:
  https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1938259

This adds additional 4 models that without this param, the screen rotates
when the clamshell laptop rotates, which is an unwanted behavior.

This commit also merges entries that needs the same param.

Signed-off-by: Yao Wei (魏銘廷) <yao.wei@canonical.com>
2021-09-14 09:42:31 +02:00
Lennart Poettering
b83bbbac87
Merge pull request #20713 from yuwata/udev-watch-retry
udev-watch: retry to save watch handle on error
2021-09-14 09:40:23 +02:00
Yu Watanabe
2d3af41f0e udev-watch: retry to save watch handle with random delay
Also, remove the watch handle if we cannot save it.
2021-09-13 18:53:00 +09:00
Yu Watanabe
20ec7d9ed5 sd-device: do not recreate the same symlinks which store watch handle 2021-09-13 11:54:56 +09:00
3 changed files with 46 additions and 9 deletions

View File

@ -291,12 +291,12 @@ sensor:modalias:acpi:*KIOX000A*:dmi:*svn*CytrixTechnology:*pn*Complex11t:*
# Dell
#########################################
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:pnVostro5581:*
ACCEL_LOCATION=base
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:sku0A36:*
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:sku0A3E:*
ACCEL_LOCATION=base
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:sku0B09:*
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:sku0B0B:*
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:sku0B0D:*
sensor:modalias:platform:HID-SENSOR-200073:dmi:*svnDell*:sku0B11:*
ACCEL_LOCATION=base
# Dell Venue 8 Pro 3845

View File

@ -680,7 +680,7 @@ int device_set_watch_handle(sd_device *device, int wd) {
assert(device);
if (wd >= 0 && wd == device->watch_handle)
if (wd >= 0 && wd == device_get_watch_handle(device))
return 0;
device_remove_watch_handle(device);

View File

@ -12,8 +12,13 @@
#include "dirent-util.h"
#include "fs-util.h"
#include "parse-util.h"
#include "random-util.h"
#include "udev-watch.h"
#define SAVE_WATCH_HANDLE_MAX_RETRIES 128
#define MAX_RANDOM_DELAY (100 * USEC_PER_MSEC)
#define MIN_RANDOM_DELAY ( 10 * USEC_PER_MSEC)
int udev_watch_restore(int inotify_fd) {
struct dirent *ent;
DIR *dir;
@ -93,11 +98,43 @@ int udev_watch_begin(int inotify_fd, sd_device *dev) {
return ignore ? 0 : r;
}
r = device_set_watch_handle(dev, wd);
if (r < 0)
return log_device_warning_errno(dev, r, "Failed to save watch handle in /run/udev/watch: %m");
for (unsigned i = 0; i < SAVE_WATCH_HANDLE_MAX_RETRIES; i++) {
if (i > 0) {
usec_t delay = MIN_RANDOM_DELAY + random_u64_range(MAX_RANDOM_DELAY - MIN_RANDOM_DELAY);
return 0;
/* When the same handle is reused for different device node, we may fail to
* save the watch handle with -EEXIST. Let's consider the case of two workers A
* and B do the following:
*
* 1. A calls inotify_rm_watch()
* 2. B calls inotify_add_watch()
* 3. B calls device_set_watch_handle()
* 4. A calls device_set_watch_handle(-1)
*
* At step 3, the old symlinks to save the watch handle still exist. So,
* device_set_watch_handle() fails with -EEXIST. */
log_device_debug_errno(dev, r,
"Failed to save watch handle '%i' for %s in "
"/run/udev/watch, retrying in after %s: %m",
wd, devnode, FORMAT_TIMESPAN(delay, USEC_PER_MSEC));
(void) usleep(delay);
}
r = device_set_watch_handle(dev, wd);
if (r >= 0)
return 0;
if (r != -EEXIST)
break;
}
log_device_warning_errno(dev, r,
"Failed to save watch handle '%i' for %s in /run/udev/watch: %m",
wd, devnode);
(void) inotify_rm_watch(inotify_fd, wd);
return r;
}
int udev_watch_end(int inotify_fd, sd_device *dev) {