<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/usb/host/xhci-trace.h, branch linux-6.9.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2024-04-04T12:54:54Z</updated>
<entry>
<title>xhci: Fix root hub port null pointer dereference in xhci tracepoints</title>
<updated>2024-04-04T12:54:54Z</updated>
<author>
<name>Mathias Nyman</name>
<email>mathias.nyman@linux.intel.com</email>
</author>
<published>2024-04-04T12:11:06Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=dda7e89e53d6ebf27c49df7d87a54e3e1614d332'/>
<id>urn:sha1:dda7e89e53d6ebf27c49df7d87a54e3e1614d332</id>
<content type='text'>
The pointer from a xhci usb virt device to its root hub port
(vdev-&gt;rhub_port) is set later when device is addressed, not while
vdev is allocated.

Tracepoints dereferenced this rhub_port pointer when freeing the virt
device, which causes null pointer dereference if tracing is enabled
and device is freed before addressed.

This can happen if tracing is enabled and xhci driver is unloaded before
a device is fully enumerated, or initial enumeration fails and device
is reset and freed before retry.

Don't dereference the rhub_port or show port numbers when tracing
xhci_free_virt_device(). This info is not very useful anyway.

Print the more useful slot id instead

Fixes: 06790c19086f ("xhci: replace real &amp; fake port with pointer to root hub port")
Reported-by: Thinh Nguyen &lt;Thinh.Nguyen@synopsys.com&gt;
Closes: https://lore.kernel.org/linux-usb/20240402005007.klv2ij727fkz7rpd@synopsys.com/
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Link: https://lore.kernel.org/r/20240404121106.2842417-3-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>xhci: replace real &amp; fake port with pointer to root hub port</title>
<updated>2024-03-02T19:25:27Z</updated>
<author>
<name>Niklas Neronin</name>
<email>niklas.neronin@intel.com</email>
</author>
<published>2024-02-29T14:14:31Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=06790c19086fe8f54afcd49184916132c7a8da4e'/>
<id>urn:sha1:06790c19086fe8f54afcd49184916132c7a8da4e</id>
<content type='text'>
Variables real &amp; fake port do not convey their purpose, thus they are
replaced with a pointer to the root hub port 'struct xhci_port *rhub_port'.
'rhub_port' contains real &amp; fake ports in zero-based format, which happens
to be more widely used inside the xHCI driver:
 - 'real_port' is ('rhub_port-&gt;hw_portnum' + 1)
 - 'fake_port' is ('rhub_port-&gt;hcd_portnum' + 1)

One reason for real port being one-based, is to signal other functions in
case struct 'xhci_virt_device' initialization failed, in this case the
value will remain 0. This is no longer needed, instead we check whether
or not 'rhub_port' is 'NULL'.

Signed-off-by: Niklas Neronin &lt;niklas.neronin@intel.com&gt;
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Link: https://lore.kernel.org/r/20240229141438.619372-3-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>xhci: Add busnumber to port tracing</title>
<updated>2023-10-21T10:38:53Z</updated>
<author>
<name>Mathias Nyman</name>
<email>mathias.nyman@linux.intel.com</email>
</author>
<published>2023-10-19T10:29:07Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=15626ba96559ed82bba1758da0ea1f260c5c55e6'/>
<id>urn:sha1:15626ba96559ed82bba1758da0ea1f260c5c55e6</id>
<content type='text'>
With several xhci controllers active at the same time its hard to
keep track of ports without knowing bus number

Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Link: https://lore.kernel.org/r/20231019102924.2797346-3-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>xhci: pass port structure to tracing instead of port number</title>
<updated>2023-10-21T10:38:53Z</updated>
<author>
<name>Mathias Nyman</name>
<email>mathias.nyman@linux.intel.com</email>
</author>
<published>2023-10-19T10:29:06Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=992848132e4a3eec9f7c8d3d4ff4bec189abddb1'/>
<id>urn:sha1:992848132e4a3eec9f7c8d3d4ff4bec189abddb1</id>
<content type='text'>
We want to trace other port structure members than just port number
so pass entire port structure as parameter instead of just port number.

Dig the port number from the port structure.

Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Link: https://lore.kernel.org/r/20231019102924.2797346-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>xhci: Stop unnecessary tracking of free trbs in a ring</title>
<updated>2023-06-13T09:34:50Z</updated>
<author>
<name>Mathias Nyman</name>
<email>mathias.nyman@linux.intel.com</email>
</author>
<published>2023-06-02T14:40:05Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2710f8186f889798f7d1b87b762461a07cac56c6'/>
<id>urn:sha1:2710f8186f889798f7d1b87b762461a07cac56c6</id>
<content type='text'>
Trying to keep track of free trbs in a ring by adding and subtracting
deltas each time a enqueue or dequeue is increased or moved has proven to
be buggy and complicated, especially over long periods of time.

Recently a bug in counting free trbs was fixed, now taking into account
cancelled URBs that were turned into no-ops, preventing free_trbs to
slowly wander off causing unnecessary ring expansion. See
commit fe82f16aafda ("xhci: Fix incorrect tracking of free space on
transfer rings")

Turns out its a lot easier to just calculate the numer of free TRB
based on ring size and the current enqueue and dequeue pointer values.
This is currently only needed for the command ring as multi segment
transfer rings already ensures there is enough room the ring during
the ring expansion check.

We could get rid of the ring-&gt;num_trbs_free entry completely, but as
the xhci DbC code also uses it we don't clean that up in this patch.

Reported-by: Miller Hunter &lt;MillerH@hearthnhome.com&gt;
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217242
Tested-by: Miller Hunter &lt;MillerH@hearthnhome.com&gt;
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Message-ID: &lt;20230602144009.1225632-8-mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: xhci: Remove unused udev from xhci_log_ctx trace event</title>
<updated>2023-06-13T09:34:49Z</updated>
<author>
<name>Udipto Goswami</name>
<email>quic_ugoswami@quicinc.com</email>
</author>
<published>2023-06-02T14:39:59Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=b47ad02ff283d60e55e3e59d0e2455e3ab1812c6'/>
<id>urn:sha1:b47ad02ff283d60e55e3e59d0e2455e3ab1812c6</id>
<content type='text'>
xhci_log_ctx event is not utilizing the extracted udev to
print out anything, hence removing it.

Fixes: 1d27fabec068 ("xhci: add xhci_address_ctx trace event")
Signed-off-by: Udipto Goswami &lt;quic_ugoswami@quicinc.com&gt;
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Message-ID: &lt;20230602144009.1225632-2-mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: xhci: change some trace event __dynamic_array() to __get_buf()</title>
<updated>2023-03-09T14:35:03Z</updated>
<author>
<name>Linyu Yuan</name>
<email>quic_linyyuan@quicinc.com</email>
</author>
<published>2023-02-27T02:44:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7d1a898f52288f068f163aa970f029872c21c031'/>
<id>urn:sha1:7d1a898f52288f068f163aa970f029872c21c031</id>
<content type='text'>
some __dynamic_array() buffer will only used at trace event output time,
change to __get_buf() which will allocate tempary trace seq buffer for
output purpose.

Signed-off-by: Linyu Yuan &lt;quic_linyyuan@quicinc.com&gt;
Link: https://lore.kernel.org/r/1677465850-1396-5-git-send-email-quic_linyyuan@quicinc.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>xhci: tracing: Use the new __vstring() helper</title>
<updated>2022-07-15T21:44:41Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2022-07-05T22:45:00Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=0ba4c9dede106c3e7ad2bb7e23eaa1393adc43a0'/>
<id>urn:sha1:0ba4c9dede106c3e7ad2bb7e23eaa1393adc43a0</id>
<content type='text'>
Instead of open coding a __dynamic_array() with a fixed length (which
defeats the purpose of the dynamic array in the first place). Use the new
__vstring() helper that will use a va_list and only write enough of the
string into the ring buffer that is needed.

Link: https://lkml.kernel.org/r/20220705224750.172301548@goodmis.org

Cc: Mathias Nyman &lt;mathias.nyman@intel.com&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: linux-usb@vger.kernel.org
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>xhci: fix even more unsafe memory usage in xhci tracing</title>
<updated>2021-08-26T11:06:02Z</updated>
<author>
<name>Mathias Nyman</name>
<email>mathias.nyman@linux.intel.com</email>
</author>
<published>2021-08-20T12:34:59Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=4843b4b5ec64b875a5e334f280508f1f75e7d3e4'/>
<id>urn:sha1:4843b4b5ec64b875a5e334f280508f1f75e7d3e4</id>
<content type='text'>
Removes static char buffer usage in the following decode functions:
	xhci_decode_ctrl_ctx()
	xhci_decode_slot_context()
	xhci_decode_usbsts()
	xhci_decode_doorbell()
	xhci_decode_ep_context()

Caller must provide a buffer to use.
In tracing use __get_str() as recommended to pass buffer.

Minor changes are needed in other xhci code as these functions are also
used elsewhere

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Link: https://lore.kernel.org/r/20210820123503.2605901-3-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>xhci: fix unsafe memory usage in xhci tracing</title>
<updated>2021-08-26T11:06:02Z</updated>
<author>
<name>Mathias Nyman</name>
<email>mathias.nyman@linux.intel.com</email>
</author>
<published>2021-08-20T12:34:58Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=cbf286e8ef8337308c259ff5b9ce2e74d403be5a'/>
<id>urn:sha1:cbf286e8ef8337308c259ff5b9ce2e74d403be5a</id>
<content type='text'>
Removes static char buffer usage in the following decode functions:
	xhci_decode_trb()
	xhci_decode_ptortsc()

Caller must provide a buffer to use.
In tracing use __get_str() as recommended to pass buffer.

Minor chanes are needed in xhci debugfs code as these functions are also
used there. Changes include moving XHCI_MSG_MAX definititon from
xhci-trace.h to xhci.h

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Link: https://lore.kernel.org/r/20210820123503.2605901-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
