Commit Graph

2304 Commits

Author SHA1 Message Date
Florian Pose fa96b8fcb0 Merge branch 'lock-fixes' into 'master'
Various locking fixes and improvements

See merge request etherlab.org/ethercat!58
2022-09-05 09:41:16 +00:00
Florian Pose e893051563 Merge branch 'deif/O_CLOEXEC' into 'master'
lib: use O_CLOEXEC flag when opening EtherCAT master device

See merge request etherlab.org/ethercat!56
2022-09-05 09:18:03 +00:00
Florian Pose 1437f8d409 Merge branch 'lock-abstraction-fixups' into 'master'
fix direct uses of up()/down()

See merge request etherlab.org/ethercat!55
2022-09-05 09:17:32 +00:00
Florian Pose 6af1d9a441 Merge branch 'ip-path' into 'master'
ethercatctl: fix hard-coded path to ip utility

See merge request etherlab.org/ethercat!54
2022-09-05 09:16:46 +00:00
Florian Pose 2aacdb810a Merge branch 'deif/tty-fixups' into 'master'
tty: fixups for kernels 5.14 and 5.15

See merge request etherlab.org/ethercat!53
2022-09-05 09:16:02 +00:00
Florian Pose 19be4c8da4 Merge branch 'fix-5.18' into 'master'
Fix for linux 5.18.0

See merge request etherlab.org/ethercat!52
2022-09-05 09:15:06 +00:00
Florian Pose 869a88a6c8 Merge branch 'build-update' into 'master'
Fix obsolete warnings on bootstrap

See merge request etherlab.org/ethercat!49
2022-09-05 09:14:33 +00:00
Florian Pose 82ce570c7e Merge branch 'fix-init-doc' into 'master'
doc: fix references to init scripts

See merge request etherlab.org/ethercat!48
2022-09-05 09:13:40 +00:00
Esben Haabendal 81758004fd Improve synchronization of master->domains list
Introduce a new lock for synchronization of the master->domains list, and use
that instead of the big master_sem lock, improving real-time performance of
fx. ecrt_domain_process() when EoE thread is being shut down (or other
use-cases where master_sem is held for extended periods).

The following locking order is used:

* master->master_sem
* master->domains_lock
* master->io_sem
* domain->datagram_pairs_lock

Meaning that it is allowed to take domains_lock while holding master_sem, and
it is allowed to hold domains_lock while locking io_sem and
datagram_pairs_lock.

[RV: For now, the lockdep_assert_held() annotations are commented out,
since they don't compile with CONFIG_PROVE_LOCKING and (the default)
--disable-rtmutex.]
2022-09-01 15:38:01 +02:00
Esben Haabendal 19b8ddea18 Add lock protection of domain->datagram_pairs
While domain->datagram_pairs was previously partly protected by the
master->master_sem lock (it was not done consistently though), the fix
to protection of master->datagram_queue made it even worse.

This change adds protection of domain->datagram_pairs using a new lock
dedicated to this.  The domain->datagram_pairs_lock is acquired in the actual
functions accessing the domain->datagram_pairs, and this currently means that
it is acquired both in situations where master->master_sem is held and in
situations where master->io_sem is held.
2022-09-01 15:37:58 +02:00
Esben Haabendal 2372382259 Acquire master->io_sem lock where needed
With this, we should have in place so that master->io_sem is always held when
accessing master->datagram_queue.

Note, the use of master->master_sem in ec_ioctl_send() and
ec_ioctl_receive() were wrong (introduced in commit cef602586c). The
only thing needing to be synchronized there is the access to
master->datagram_queue, which is protected by master->io_sem.

This corresponds roughly to the fixes for stable-1.5 that are seen in
https://gitlab.com/etherlab.org/ethercat/-/merge_requests/36 .
2022-09-01 15:37:54 +02:00
Esben Haabendal e243c6b7db Clarify purpose of master->io_sem
In order to ensure proper use of locking, the purpose of each mutex/semaphore
must be clear and documented.

This is my best guess.  The master->io_sem has a simple purpose, synchronizing
access to the master->datagram_queue list structure.
2022-09-01 15:37:50 +02:00
Rasmus Villemoes 624872fcdb fix direct uses of up()/down()
When converting to the ec_lock_t abstraction, these were missed,
making building with --enable-rtmutex broken.

Fixes: 9955855f7e (Applied 0016-If-enable-rtmutex-use-rtmutexes-instead-of-semaphore.patch)
2022-08-31 15:21:23 +02:00
Rasmus Villemoes a8fe799522 ethercatctl: fix hard-coded path to ip utility
- The unmodified upstream iproute2 package installs the ip utility in
  /sbin. That is also where it thus ends up with for example Yocto
  builds.

- Debian/Ubuntu installs it in /bin (and I assume that's how this came
  to be), but their packaging logic provides a symlink /sbin/ip ->
  /bin/ip .

- ArchLinux seems to install it in both places (as hardlinks).

- CentOS only has /sbin/ip.

- Fedora only has /sbin/ip.

So /sbin/ip should work everywhere, whereas /bin/ip does not.
2022-08-31 15:18:42 +02:00
Per Noergaard Christensen 38038f6a48 lib: use O_CLOEXEC flag when opening EtherCAT master device
This flag specifies that the file descriptor should be closed when an
exec function is invoked. When a file descriptor is allocated (as with
open or dup), O_CLOEXEC bit is initially cleared on the new file
descriptor, meaning that descriptor will survive into the new program
after exec. Setting O_CLOEXEC avoid this survival of the desciptor in
the new program. And setting it at open() time is the only race-free
way to avoid accidentally leaking the fd via other threads that
concurrently do fork()+exec() (or similar, e.g. posix_spawn).
2022-08-30 14:39:32 +02:00
Per Noergaard Christensen 96a045e36e tty: fixups for kernels 5.14 and 5.15
alloc_tty_driver was deprecated by tty_alloc_driver in commit 7f0bc6a68ed9
(TTY: pass flags to alloc_tty_driver) in 2012 but first in kernel
v5.15 it has been dropped (56ec5880a28e). Switch to tty_alloc_driver
when using kernels >= v5.15

As of v5.15, the put_tty_driver alias has been dropped in favor of
directly calling tty_driver_kref_put (9f90a4ddef4e).  Switch to
tty_driver_kref_put when using kernels >= v5.15

As from v5.14 the write_room (03b3b1a2405c) and
chars_in_buffer (fff4ef17a940) methods' return type changed from int
to unsigned int in struct tty_operations. This has impact on
ec_tty_write_room() and ec_tty_chars_in_buffer().
2022-08-30 13:57:23 +02:00
Nicola Fontana 4050913147 Fix for linux 5.18.0
In recent kernels, netif_rx_ni() is just a wrapper around netif_rx():

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9f9919f73c94ae00af4e6ad45179282122f24988
2022-07-18 11:21:29 +02:00
Florian Pose fa890a8b61 Applied 0021-Await-SDO-dictionary-to-be-fetched.patch 2022-06-23 12:43:34 +02:00
Florian Pose 8896d3b879 Applied 0020-eoe-ip.patch 2022-06-23 12:39:52 +02:00
Florian Pose 5f84d54890 Applied 0000-version-magic.patch and bumped to 1.6 2022-06-23 12:20:47 +02:00
Florian Pose 44c6c3d1da Merge branch 'master' of ../git 2022-06-23 11:55:13 +02:00
Florian Pose f943348d98 Applied 0019-Support-for-multiple-mailbox-protocols.patch 2022-06-23 11:54:10 +02:00
Florian Pose 429ba9356e Applied 0018-Use-call-back-functions.patch 2022-06-23 11:27:28 +02:00
Florian Pose cef602586c Applied 0017-Master-locks-to-avoid-corrupted-datagram-queue.patch 2022-06-23 11:26:20 +02:00
Florian Pose d1e3d2e0a3 Removed duplicate pre-commit rule. 2022-06-23 11:22:08 +02:00
Florian Pose 9955855f7e Applied 0016-If-enable-rtmutex-use-rtmutexes-instead-of-semaphore.patch 2022-06-23 11:21:51 +02:00
Florian Pose 667e93284d Applied 0015-Clear-configuration-on-deactivate-even-if-not-activa.patch 2022-06-23 11:00:45 +02:00
Florian Pose a3fa7cecaf Applied 0014-Fix-NOHZ-local_softirq_pending-08-warning.patch 2022-06-23 10:59:45 +02:00
Florian Pose d09daadfbb Applied 0013-Do-not-reuse-the-index-of-a-pending-datagram.patch 2022-06-23 10:58:57 +02:00
Florian Pose 8db3e5abf4 Applied 0012-Added-newline-to-syslog-message-MAC-address-derived.patch 2022-06-23 10:56:33 +02:00
Florian Pose 57342c99ca Applied 0011-Reduced-printing-to-avoid-syslog-spam.patch 2022-06-23 10:55:57 +02:00
Florian Pose d1dc6795f3 Applied 0010-Make-busy-logging-a-little-less-irritating.patch 2022-06-23 10:55:03 +02:00
Florian Pose 90f3f7e841 Applied 0009-Avoid-changing-running-slaves-DC-offset.patch 2022-06-23 10:53:56 +02:00
Florian Pose 225af9f787 Applied 0008-read-reference-slave-clock-64bit-time.patch 2022-06-23 10:45:16 +02:00
Florian Pose 6cac716122 Applied 0007-replace-fprintf-calls-with-EC_PRINT_ERR.patch 2022-06-23 10:31:41 +02:00
Florian Pose 234695fe44 Applied 0006-avoid-ssize_t.patch 2022-06-23 10:26:43 +02:00
Florian Pose 405c88f6d6 Applied 0005-disable-eoe.patch 2022-06-23 10:25:36 +02:00
Florian Pose efcd95ed9c Applied 0004-fix-eoe-clear.patch 2022-06-23 10:13:49 +02:00
Florian Pose d0d4535df0 Applied 0003-print-sync-signed.patch 2022-06-23 10:13:00 +02:00
Florian Pose 17eddce68d Applied 0002-Distributed-Clock-fixes-from-Jun-Yuan.patch 2022-06-23 10:12:12 +02:00
Florian Pose b4f8c0e750 Added 0001-Distributed-Clock-fixes-and-helpers.patch 2022-06-23 10:07:34 +02:00
Florian Pose c9c43ac439 Added pre-commit configuration. 2022-06-23 10:06:04 +02:00
Nicola Fontana b2f1a0b32f Fix obsolete warnings on bootstrap
Use AS_HELP_STRING instead of the obsolete AC_HELP_STRING and call
LT_INIT instead of AC_PROG_LIBTOOL (if available).
2022-06-09 22:36:13 +02:00
Nicola Fontana f0e544cad0 doc: fix references to init scripts
init.d support has been updated but the TeX files still reference some
old contents.

Fix all the `../script` folder references, avoid pointing to generated
files (that, depending on the configure options, may or may not exist)
and, while at it, refresh a bit the systemd/init.d documentations.
2022-06-06 17:06:16 +02:00
Florian Pose 89677140fa Minor: Fixed indent. 2022-05-17 14:09:00 +02:00
Bjarne von Horn 1f55565fbb Fix setting mac_address
eoe->dev->dev_addr is read_only in 5.17.0
using eth_hw_addr_set instead
2022-05-17 14:06:42 +02:00
Florian Pose 2628069c5a Fixed distribution of bash completions file. 2022-05-16 10:39:53 +02:00
Florian Pose 907a3633a2 Install bash completions. 2022-05-16 10:10:59 +02:00
Florian Pose 526370a5a5 Merge branch 'master' of gitlab.com:etherlab.org/ethercat 2022-05-16 09:50:44 +02:00
Florian Pose da0b5e1d73 Merge branch 'bash_completion' into 'master'
Bash completion for ethercat tool

See merge request etherlab.org/ethercat!47
2022-05-16 07:49:24 +00:00