Commit Graph

66349 Commits

Author SHA1 Message Date
Augustin Cavalier
7cb6c1c23f freebsd_network: Correct handling of dmamem allocation flags.
_prepare_bounce_buffer also calls _allocate_dmamem and needs to have
the passed BUS_* flags handled properly, so just move the handling
to _allocate_dmamem directly.
2024-08-07 21:03:16 -04:00
Augustin Cavalier
58137a628d multi_audio: Fix logging print.
The value is really "lateness" not "how_early".
2024-08-07 20:45:13 -04:00
Augustin Cavalier
1513e5484e mixer: Allow stopping the mixer before it's even been started. 2024-08-07 20:44:06 -04:00
Augustin Cavalier
1352dfe46a mixer: Don't stop the mixer in Disconnect().
The logic in the mixer will automatically stop the mix thread but
leave the "Started" flag set in this case.

While at it, clean up that logic.

This suffices to get the mixer to connect and disconnect from
the same output, at least, and have audio output still work.
2024-08-07 20:44:06 -04:00
Augustin Cavalier
424086eeef multi_audio: Tolerate played_real_time less than TimeComputer's RealTime.
See inline comment. As we initialize the TimeComputer with the current
system_time(), if the driver reports the played_real_time of its last
buffer exchange (which, if we're restarting media_server, could be
non-zero), we need to just ignore it.

Fixes assertion failures when using usb_audio. And now that we have
this check in here, we can remove the assert from TimeComputer.

Also add a cast in _GetControlName to appease GCC2 while at it.
2024-08-07 20:44:06 -04:00
Augustin Cavalier
940d017a2f mixer: Just use absolute timeouts rather than "scheduling" runs.
Also refactor the logic to not need goto.

The previous design (from 2016) generated an event and wrote to the
control port to queue it, and then the control thread woke up our
semaphore at the appointed time. Rather than have this inefficency,
just use a timeout to the acquire_sem (which is more similar to the
pre-2016 design.)

This should not affect mixer behavior (as we wait for buffers
inside this logic already), it should only reduce the latency
of actual mixer runs.
2024-08-07 20:44:06 -04:00
Augustin Cavalier
a21e32ecc5 mixer: Basic cleanup.
* Remove ERROR differences on DEBUG vs. non-DEBUG.

 * Cleanup checks.
2024-08-07 20:44:06 -04:00
John Scipione
de483e1765 Libpackage: Add HOST_LIBSUPC++ to libpackage and solver
(This is needed to cross-compile on macOS.)

Change-Id: I2b0186e2a9ac09fc332a43808d55fcb2d5ebc86b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7933
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-08-07 20:17:44 +00:00
Augustin Cavalier
9d694bc9eb multi_audio: Guard against overreads in _GetControlName.
May fix a crash X512 reported.
2024-08-07 14:52:07 -04:00
Augustin Cavalier
fe5fc031dd profile: Report dropped events from the system profiler.
Otherwise there is no indication how many were dropped.
2024-08-07 14:51:38 -04:00
Augustin Cavalier
37201dc1df sdhci_pci: Disable tracing.
Reduces syslog spam. It was already disabled for sdhci_acpi.
2024-08-07 14:50:19 -04:00
Augustin Cavalier
bd05c92198 kernel: Check != not < B_INFINITE_TIMEOUT.
As it's INT64_MAX, so anything "larger" is really overflowed into negative.
2024-08-07 14:49:48 -04:00
Augustin Cavalier
4d2ab928c6 OS.h: Define B_INFINITE_TIMEOUT in hexadecimal.
Makes it clearer that this is INT64_MAX at a glance.
No functional change.
2024-08-07 14:49:05 -04:00
Augustin Cavalier
424abd4d57 BClipboard: Don't wait forever for a clipboard download.
Time out after waiting at most for 10 seconds. After 81e50deece,
this should only happen when the registrar succeeds in sending the
message but we fail in receiving it for whatever reason, so really
this is just a guard against infinite hangs.
2024-08-07 14:45:48 -04:00
Augustin Cavalier
7c4915c1e6 ramfs: Also set type and flags in ramfs_get_vnode.
Necessary for proper functioning after the vnodes were purged
and then re-created on the VFS side.
2024-08-07 14:42:49 -04:00
Augustin Cavalier
b6d006ca91 kernel/fs: Initialize type/flags before invoking get_vnode.
Otherwise, if the filesystem doesn't set them, we will have garbage
values and act wrongly.

This fixes the second KDL and the underlying cause of #18838:
when the system gets into a low memory state, VFS purges unused vnodes.
But of course RAMFS keeps those nodes around. When the VFS went to
retrieve the nodes for reuse, the flags would sometimes randomly
have the "removed" flag set, and the VFS would then try to delete
the node. But of course it wasn't really removed, so we would hit
an assertion failure in RAMFS.
2024-08-07 14:42:15 -04:00
Augustin Cavalier
00908dbb0f ramfs: Minor code cleanup. 2024-08-07 14:38:27 -04:00
Augustin Cavalier
70f7a613af ramfs: Style cleanup in Node.
No functional change.
2024-08-07 11:45:40 -04:00
Augustin Cavalier
420c9a5a44 ramfs: Use check_access_permissions in Node.
This does check owning groups properly.
2024-08-07 11:45:22 -04:00
Augustin Cavalier
43feec0105 ramfs: Use VM_PRIORITY_USER not VM_PRIORITY_SYSTEM.
This way, allocation failures on ramfs have a chance of
not bringing down the whole system with them.
2024-08-06 18:42:22 -04:00
Augustin Cavalier
81e50deece registrar: Handle clipboard download messages failing to send.
The sender is waiting for a reply, so if the reply fails to send
the target will hang forever. Send back an error in that case.

Should fix hangs of Tracker and Deskbar under low memory conditions
with a very large clipboard.
2024-08-06 18:42:05 -04:00
Augustin Cavalier
ab262541db kernel/user_debugger: Check the debugged team ID properly.
If it's B_CURRENT_TEAM we need to fetch the real ID before doing
the check.
2024-08-06 18:14:10 -04:00
Augustin Cavalier
c4eef57349 mixer: Fix TRACE in delay starting of the mixer.
Thanks jmairboeck for the review!
2024-08-06 16:41:17 -04:00
Augustin Cavalier
104a4a7cfc packagefs: Improve errors and print a message when failing to add a package node...
... due to conflicts in the node type.

This allows for better diagnosing #18591.
2024-08-06 16:36:12 -04:00
Augustin Cavalier
9c8a78e8ca kernel/timer: Remove another volatile.
Previously missed.
2024-08-06 14:11:20 -04:00
Augustin Cavalier
eca25eef72 packagefs: Assert that the directory is locked when adding children. 2024-08-06 14:11:00 -04:00
Augustin Cavalier
39fc954151 packagefs: Ensure the root directory is locked when creating shine-throughs.
Found by the ASSERT added in the following commit.
2024-08-06 14:10:44 -04:00
Augustin Cavalier
8f4ba40520 tcp_shell: Fix following latest changes. 2024-08-05 23:55:20 -04:00
Augustin Cavalier
a51aed0242 Zydis: Handle OPERAND_TYPE_REGISTER in ZydisCalcAbsoluteAddressEx.
Fixes "Step over" in Debugger following the switch to Zydis.
2024-08-05 23:50:31 -04:00
Augustin Cavalier
517fca7da7 BTimeSource: Protect against values too large to fit in a float.
This can only happen if the real time or performance time values
specified are very large (more than 24 bits), which should only
happen if the time specified is system_time() and the "last" time
is 0. Under that circumstance, last_drift should be 1.0f,
so we can avoid using it at all. Otherwise, invoke debugger().

This would have caught some (but not all) of the problems fixed
in preceding commits.
2024-08-05 23:33:34 -04:00
Augustin Cavalier
eb3126cba7 mixer: Delay starting until we have a valid time source.
BTimeSource::Now() uses the current real time to compute the
performance time, so if the performance time and last real time
are 0 in the time source data, we get a positive value that is
the same as the system time. That means we wind up waiting
a while to start the mixer unnecessarily, often equal to the
current system_time() when the mixer was started.

So, rather than checking the computed Now(), we instead check the
raw performance and real time values from the time source, and
wait for those to be valid before starting.

Also remove a comment about the BeOS R5 multi_audio node. It seems
that ours generates valid time values more quickly, but still starts
off with performance and real times of 0 (which are the default in
the time source anyway.) The new code would still work under such
broken nodes regardless.

This seems to fix sound output taking a long time to start after boot
(or even longer after restarting media services.)
2024-08-05 23:29:20 -04:00
Augustin Cavalier
b5142f7645 multi_audio: Add assertion in TimeComputer that realTime didn't go backwards.
Would have caught the problem fixed in the previous commit.
2024-08-05 23:24:06 -04:00
Augustin Cavalier
a62032d8d5 multi_audio: Don't add/publish timestamps of 0.
Otherwise they will mess up the time computer and then the published
times, giving huge or miniscule drift values (since the time computer
already has a non-zero real-time by this point, so it will compute
a negative difference if passed 0 for the current real time.)
2024-08-05 23:23:34 -04:00
Augustin Cavalier
30e70f48c1 multi_audio: Disable some unneeded prints. 2024-08-05 23:21:53 -04:00
Augustin Cavalier
ddffecccca BTimeSource: Call debugger() if someone tries to Publish a drift of 0.
Would have caught the problems fixed in the last commit.
2024-08-05 16:49:01 -04:00
Augustin Cavalier
dc718d1a4e media-add-ons: Do not publish times with drifts of 0.
The "drift" value is the ratio between performance and real time,
so it must never be 0. Specifying it as such would mean that the
consumers of the time source would wind up with wait times that were
extremely large, due to doing a float divide-by-zero.
2024-08-05 16:46:39 -04:00
Augustin Cavalier
8cfa2d5f89 app_server: Fix timeout computation in DelayedMessageSender.
While working on the kernel timer fixes, I noticed some timer events
that had very large, but not quite infinite, timeouts; and this was
one of them.

Should not constitute a behavioral change (since the nearly-infinite
timeouts would never be hit.)
2024-08-05 16:44:09 -04:00
Augustin Cavalier
6d1478af8c kernel/timer: The list does not need to be volatile.
We only access and modify these fields with the spinlock held,
so there's no need for volatile here.
2024-08-05 16:42:00 -04:00
Augustin Cavalier
f9f6083f41 kernel/timer: Fix scheduling of absolute-real-time timers.
The logic in add_timer was scheduling the timer using "scheduleTime",
the originally passed value, not "event->schedule_time", which
is adjusted inside add_timer to be relative to the system_time.
This meant that if the event was the first added to the list,
we would set the hardware clock for a very long time in the future
rather than the correct duration.

Since until recently cancel_timer reset the hardware clock every run
even if the cancelled timer wasn't at the head of the list, this
problem was covered up by that one, as usually the scheduler would
cancel a timer relatively frequently, and thus the hardware timer
would usually get set to the correct value relatively frequently.

But after c5a499a74b, this was not
the case anymore as we skip updating the hardware timer if we cancelled
any timer other than the one at the head of the list, exposing this bug.

The fix is simple: don't bother storing a local "scheduleTime" variable
separate from the event->schedule_time. This makes things less confusing
anyway.

Fixes #18967.
2024-08-05 15:42:25 -04:00
Augustin Cavalier
352548d0a3 kernel/thread: Do not rely on B_TIMED_OUT to cancel the unblock timer.
As anything can specify it as an unblock error code, not just the
unblock timer code. Also check < B_INFINITE_TIMEOUT not !=.
2024-08-05 15:36:25 -04:00
Augustin Cavalier
8266f4d7aa HaikuDepot: Shift pkg data fetch into processes
HD currently fetches changelog and user ratings for packages using
a thread from the window. In this change, the fetching of this
data is instead performed using process coordinators in order to
make background processing behaviour consistent and to prep for
future changes.

Change-Id: I7fd0f33c4b9a63fa4b999e2909ce320296db59b9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7928
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-08-05 16:22:15 +00:00
Andrew Lindesay
4a52b9c7e3 HaikuDepot: Move Path Logic from Model
Change-Id: I575be693f6e1be5cf0a93184553535e3b7401372
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7927
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
2024-08-05 16:21:59 +00:00
PulkoMandy
b9ec4108cc PCI ECAM: fix boundary check
The previous code (introduced in hrev57034) was correct for most accesses, but
would reject access to the last word of the configuration space using 8 or 16 bit
access.

May help with #18536

Change-Id: I3eecbdb187eca0ec57e0ce65e4d1eb0d7c43d00a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7929
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-08-05 16:21:20 +00:00
Zardshard
3644b442fa Do not clear a BBitmap with B_BITMAP_ACCEPTS_VIEWS
Unless, of course, it has the B_BITMAP_CLEAR_TO_WHITE flag as well.

From my testing, not clearing the BBitmap matches BeOS's behaviour
more closely (if not exactly) compared to clearing the BBitmap.

My test program created the BBitmap and BView, drew a diagonal red line
across it, and saved the result to a file.

The results:
* BeOS - transparent background; red line with no anti-aliasing
* Haiku, current behaviour - white background; red line
* Haiku, new behaviour - transparent background; red line with
  black pixels as artifacts of the anti-aliasing process.

The anti-aliasing artifacts, as PulkoMandy pointed out, are simply a
result of not using the B_OP_ALPHA and an appropriate blending mode,
and would happen on BeOS as well if the line had some transparency,
such as through anti-aliasing.

Change-Id: I09ac054eb0ce79e697b78ea48d1db4a15041e600
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7899
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2024-08-05 16:19:41 +00:00
Niklas Poslovski
a713770a18 Debugger: Make text in SourceView readable with dark theme
Change-Id: Ia3baead6676fca1a3454b821c405592da29f715c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7936
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-08-05 11:38:05 +00:00
Augustin Cavalier
070b7ca96d TCP: Tolerate zero round-trip time.
TCP times are measured in milliseconds, and so on LAN (or on two
VMs on the same host) we can wind up with round trip times of
less than 1 ms, which thus come out to 0. Tolerate this appropriately
rather than taking 0 to be a magic value meaning "unknown".

Change-Id: Ica827ee4ea353208291cf4348e9da8af6214b507
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7926
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-08-05 04:29:58 +00:00
Augustin Cavalier
b60ddcdff1 TCP: Implement dynamic receive window sizing.
The basic idea: target a window size large enough to fit one
second's worth of data in it, using the round-trip time to
condition when we make the computations.

If we don't have SACK (to reduce retransmissions on packet loss)
or the user has specified a specific receive buffer size, then don't
scale at all.

Send window scaling isn't implemented yet, as that more-or-less
requires more careful management of congestion windows and SACK
processing which we do not currently implement.

Part of #15886.

Change-Id: Ia2480e6981324d2663e47cb17e8fc47ccc5f9aa0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6364
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-08-05 04:29:58 +00:00
Augustin Cavalier
c2f5d5c290 TCP: Only send a window update in ReadData() if there's less than half left.
This is more important when window scaling is enabled as otherwise
we will send large amounts of window-update ACKs needlessly.

Ideally we would just use fReceiveWindow here, but due to a
TODO it stays constant (or increases only) at present, so we
have to compute the window size remainder inline. Another
similar computation elsewhere failed to take the case when
the window is 0 into account, so fix that too while at it.

Change-Id: Ibcca258472940d7de2d1adc9f986ddb7245438be
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7924
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
2024-08-05 04:29:58 +00:00
Augustin Cavalier
e028d3f303 ethernet: Disable frame sizes larger than the ethernet maximum.
The network stack (TCP in particular) does not handle path MTU
discovery properly (or at all), so we should avoid trying to
send (or advertise support for) frames that large.

Now that we use net_buffers for receiving and sending directly,
this value really is only the "MTU"; it is entirely possible
to receive frames larger than this successfully. So this should
only fix things and not break anything at present.
2024-08-02 22:31:11 -04:00
Augustin Cavalier
7bdc5201fe ICMP: Remove an unused declaration.
This is already declared elsewhere as ICMP_CODE_FRAGMENTATION_NEEDED
and handled inline appropriately.
2024-08-02 22:28:25 -04:00