[haiku-commits] haiku: hrev53256 - in src/add-ons/kernel: busses/usb drivers/audio/usb

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 14 Jul 2019 20:07:02 -0400 (EDT)

hrev53256 adds 5 changesets to branch 'master'
old head: 17c9e987431f0a838ea579b9b77a6ad3bf4d7a29
new head: d5aa7f00a261438644a53eb36379524f670a5ec3
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=d5aa7f00a261+%5E17c9e987431f

----------------------------------------------------------------------------

c8375b00177b: XHCI: Tweak priorities a bit more.
  
  Put the EventThread as URGENT_PRIORITY and the downstream FinishThread
  as URGENT - 1. Hopefully this will serve as a better hint to the
  scheduler as to what we want to occur here.

60f15f5aa22d: XHCI: Turn failure to stop the endpoint into a TRACE_ERROR.

9cd2907d6802: XHCI: Trace an error when we receive command events for unknown 
commands.
  
  This revealed that StopEndpoint commands on QEMU were returning ...
  after the semaphore timeout was already hit. Now to figure out
  why that is the case...

553ff67585d1: XHCI: Print errors when transfers have non-success completion 
codes.

d5aa7f00a261: usb_audio: Stop before reallocating buffers and add more error 
checks.
  
  Also print strerror() for SetGlobalFormat.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 33 insertions(+), 17 deletions(-)
src/add-ons/kernel/busses/usb/xhci.cpp          | 37 +++++++++++++--------
src/add-ons/kernel/drivers/audio/usb/Device.cpp |  5 ++-
src/add-ons/kernel/drivers/audio/usb/Stream.cpp |  8 +++--

############################################################################

Commit:      c8375b00177bbfa9f3741bcae2570e8ec1c85fc6
URL:         https://git.haiku-os.org/haiku/commit/?id=c8375b00177b
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sun Jul 14 18:27:30 2019 UTC

XHCI: Tweak priorities a bit more.

Put the EventThread as URGENT_PRIORITY and the downstream FinishThread
as URGENT - 1. Hopefully this will serve as a better hint to the
scheduler as to what we want to occur here.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp 
b/src/add-ons/kernel/busses/usb/xhci.cpp
index 079823dcdc..07ae2a6641 100644
--- a/src/add-ons/kernel/busses/usb/xhci.cpp
+++ b/src/add-ons/kernel/busses/usb/xhci.cpp
@@ -359,15 +359,15 @@ XHCI::XHCI(pci_info *info, Stack *stack)
                return;
        }
 
-       // create finisher service thread
-       fFinishThread = spawn_kernel_thread(FinishThread, "xhci finish thread",
+       // create event handler thread
+       fEventThread = spawn_kernel_thread(EventThread, "xhci event thread",
                B_URGENT_PRIORITY, (void *)this);
-       resume_thread(fFinishThread);
+       resume_thread(fEventThread);
 
        // create finisher service thread
-       fEventThread = spawn_kernel_thread(EventThread, "xhci event thread",
-               B_URGENT_DISPLAY_PRIORITY, (void *)this);
-       resume_thread(fEventThread);
+       fFinishThread = spawn_kernel_thread(FinishThread, "xhci finish thread",
+               B_URGENT_PRIORITY - 1, (void *)this);
+       resume_thread(fFinishThread);
 
        // Find the right interrupt vector, using MSIs if available.
        fIRQ = fPCIInfo->u.h0.interrupt_line;

############################################################################

Commit:      60f15f5aa22d181a0bf4fe6a80d44304e5e7b5dc
URL:         https://git.haiku-os.org/haiku/commit/?id=60f15f5aa22d
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sun Jul 14 18:28:24 2019 UTC

XHCI: Turn failure to stop the endpoint into a TRACE_ERROR.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp 
b/src/add-ons/kernel/busses/usb/xhci.cpp
index 07ae2a6641..834c9b5a7f 100644
--- a/src/add-ons/kernel/busses/usb/xhci.cpp
+++ b/src/add-ons/kernel/busses/usb/xhci.cpp
@@ -867,9 +867,6 @@ XHCI::SubmitNormalRequest(Transfer *transfer)
 status_t
 XHCI::CancelQueuedTransfers(Pipe *pipe, bool force)
 {
-       TRACE_ALWAYS("cancel queued transfers for pipe %p (%d)\n", pipe,
-               pipe->EndpointAddress());
-
        xhci_endpoint *endpoint = (xhci_endpoint *)pipe->ControllerCookie();
        if (endpoint == NULL || endpoint->trbs == NULL) {
                // Someone's de-allocated this pipe or endpoint in the meantime.
@@ -877,6 +874,9 @@ XHCI::CancelQueuedTransfers(Pipe *pipe, bool force)
                return B_NO_INIT;
        }
 
+       TRACE_ALWAYS("cancel queued transfers (%" B_PRId8 ") for pipe %p 
(%d)\n",
+               endpoint->used, pipe, pipe->EndpointAddress());
+
        MutexLocker endpointLocker(endpoint->lock);
 
        if (endpoint->td_head == NULL) {
@@ -890,7 +890,9 @@ XHCI::CancelQueuedTransfers(Pipe *pipe, bool force)
        xhci_td* td_head = endpoint->td_head;
        endpoint->td_head = NULL;
 
-       if (StopEndpoint(false, endpoint->id + 1, endpoint->device->slot) == 
B_OK) {
+       status_t status = StopEndpoint(false, endpoint->id + 1,
+               endpoint->device->slot);
+       if (status == B_OK) {
                // Clear the endpoint's TRBs.
                memset(endpoint->trbs, 0, sizeof(xhci_trb) * 
XHCI_ENDPOINT_RING_SIZE);
                endpoint->used = 0;
@@ -905,7 +907,8 @@ XHCI::CancelQueuedTransfers(Pipe *pipe, bool force)
        } else {
                // We couldn't stop the endpoint. Most likely the device has 
been
                // removed and the endpoint was stopped by the hardware.
-               TRACE("CancelQueuedTransfers: could not stop endpoint\n");
+               TRACE_ERROR("cancel queued transfers: could not stop endpoint: 
%s!\n",
+                       strerror(status));
        }
 
        endpointLocker.Unlock();

############################################################################

Commit:      9cd2907d6802007f24b051960d2b5257ec30e9e8
URL:         https://git.haiku-os.org/haiku/commit/?id=9cd2907d6802
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sun Jul 14 18:31:07 2019 UTC

XHCI: Trace an error when we receive command events for unknown commands.

This revealed that StopEndpoint commands on QEMU were returning ...
after the semaphore timeout was already hit. Now to figure out
why that is the case...

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp 
b/src/add-ons/kernel/busses/usb/xhci.cpp
index 834c9b5a7f..a14899a9e8 100644
--- a/src/add-ons/kernel/busses/usb/xhci.cpp
+++ b/src/add-ons/kernel/busses/usb/xhci.cpp
@@ -2332,7 +2332,8 @@ XHCI::HandleCmdComplete(xhci_trb* trb)
                fCmdResult[0] = trb->status;
                fCmdResult[1] = B_LENDIAN_TO_HOST_INT32(trb->flags);
                release_sem_etc(fCmdCompSem, 1, B_DO_NOT_RESCHEDULE);
-       }
+       } else
+               TRACE_ERROR("received command event for unknown command!\n")
 }
 
 
@@ -2459,6 +2460,7 @@ XHCI::DoCommand(xhci_trb* trb)
 
        if (acquire_sem_etc(fCmdCompSem, 1, B_RELATIVE_TIMEOUT, 1 * 1000 * 
1000) < B_OK) {
                TRACE("Unable to obtain fCmdCompSem!\n");
+               fCmdAddr = 0;
                Unlock();
                return B_TIMED_OUT;
        }
@@ -2483,6 +2485,7 @@ XHCI::DoCommand(xhci_trb* trb)
        TRACE("Storing trb 0x%08" B_PRIx32 " 0x%08" B_PRIx32 "\n", trb->status,
                trb->flags);
 
+       fCmdAddr = 0;
        Unlock();
        return status;
 }

############################################################################

Commit:      553ff67585d10035653805d0613d319aafe2e5dd
URL:         https://git.haiku-os.org/haiku/commit/?id=553ff67585d1
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sun Jul 14 18:37:00 2019 UTC

XHCI: Print errors when transfers have non-success completion codes.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp 
b/src/add-ons/kernel/busses/usb/xhci.cpp
index a14899a9e8..00e47813fa 100644
--- a/src/add-ons/kernel/busses/usb/xhci.cpp
+++ b/src/add-ons/kernel/busses/usb/xhci.cpp
@@ -2380,11 +2380,16 @@ XHCI::HandleTransferComplete(xhci_trb* trb)
                  (flags & TRB_3_EVENT_DATA_BIT), completionCode, transferred);
 
        if ((flags & TRB_3_EVENT_DATA_BIT) == 0) {
-               TRACE_ALWAYS("got an interrupt for a non-Event Data TRB!\n");
+               TRACE("got an interrupt for a non-Event Data TRB!\n");
                remainder = transferred;
                transferred = -1;
        }
 
+       if (completionCode != COMP_SUCCESS && completionCode != 
COMP_SHORT_PACKET) {
+               TRACE_ALWAYS("transfer error on slot %" B_PRId8 " endpoint %" 
B_PRId8
+                       ": %s\n", slot, endpointNumber, 
xhci_error_string(completionCode));
+       }
+
        const phys_addr_t source = B_LENDIAN_TO_HOST_INT64(trb->address);
        for (xhci_td *td = endpoint->td_head; td != NULL; td = td->next) {
                int64 offset = (source - td->trb_addr) / sizeof(xhci_trb);

############################################################################

Revision:    hrev53256
Commit:      d5aa7f00a261438644a53eb36379524f670a5ec3
URL:         https://git.haiku-os.org/haiku/commit/?id=d5aa7f00a261
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sun Jul 14 19:50:19 2019 UTC

usb_audio: Stop before reallocating buffers and add more error checks.

Also print strerror() for SetGlobalFormat.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/drivers/audio/usb/Device.cpp 
b/src/add-ons/kernel/drivers/audio/usb/Device.cpp
index 8ffd0a94ef..402323ff16 100644
--- a/src/add-ons/kernel/drivers/audio/usb/Device.cpp
+++ b/src/add-ons/kernel/drivers/audio/usb/Device.cpp
@@ -832,7 +832,10 @@ Device::_SetupEndpoints()
 
        if (fAudioControl.InitCheck() == B_OK && fStreams.Count() > 0) {
                TRACE(INF, "Found device %#06x:%#06x\n", fVendorID, fProductID);
-               gUSBModule->set_configuration(fDevice, config);
+
+               status_t status = gUSBModule->set_configuration(fDevice, 
config);
+               if (status != B_OK)
+                       return status;
 
                for (int i = 0; i < fStreams.Count(); i++)
                        fStreams[i]->OnSetConfiguration(fDevice, config);
diff --git a/src/add-ons/kernel/drivers/audio/usb/Stream.cpp 
b/src/add-ons/kernel/drivers/audio/usb/Stream.cpp
index 49a284c1f6..9e38503554 100644
--- a/src/add-ons/kernel/drivers/audio/usb/Stream.cpp
+++ b/src/add-ons/kernel/drivers/audio/usb/Stream.cpp
@@ -170,8 +170,10 @@ Stream::_SetupBuffers()
                return B_BAD_VALUE;
        }
 
-       if (fArea != -1)
+       if (fArea != -1) {
+               Stop();
                delete_area(fArea);
+       }
 
        fAreaSize = (sizeof(usb_iso_packet_descriptor) + fPacketSize)
                * sampleSize * 1024 / fPacketSize;
@@ -441,9 +443,9 @@ Stream::SetGlobalFormat(multi_format_info* Format)
                USB_AUDIO_SET_CUR, USB_AUDIO_SAMPLING_FREQ_CONTROL << 8,
                address, sizeof(freq), &freq, &actualLength);
 
-       TRACE(ERR, "set_speed %02x%02x%02x for ep %#x %d: %x\n",
+       TRACE(ERR, "set_speed %02x%02x%02x for ep %#x %d: %s\n",
                freq.bytes[0], freq.bytes[1], freq.bytes[2],
-               address, actualLength, status);
+               address, actualLength, strerror(status));
        return status;
 }
 


Other related posts:

  • » [haiku-commits] haiku: hrev53256 - in src/add-ons/kernel: busses/usb drivers/audio/usb - waddlesplash