Skip to content

Commit 5abbe6e

Browse files
Guan-Yu Lingregkh
authored andcommitted
usb: host: xhci-sideband: delegate offload_usage tracking to class drivers
Remove usb_offload_get() and usb_offload_put() from the xHCI sideband interrupter creation and removal paths. The responsibility of manipulating offload_usage now lies entirely with the USB class drivers. They have the precise context of when an offload data stream actually starts and stops, ensuring a much more accurate representation of offload activity for power management. Cc: stable <stable@kernel.org> Fixes: ef82a48 ("xhci: sideband: add api to trace sideband usage") Signed-off-by: Guan-Yu Lin <guanyulin@google.com> Tested-by: Hailong Liu <hailong.liu@oppo.com> Tested-by: hailong.liu@oppo.com Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20260401123238.3790062-3-guanyulin@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bd3d245 commit 5abbe6e

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

drivers/usb/host/xhci-sideband.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,13 @@ __xhci_sideband_remove_endpoint(struct xhci_sideband *sb, struct xhci_virt_ep *e
9393
static void
9494
__xhci_sideband_remove_interrupter(struct xhci_sideband *sb)
9595
{
96-
struct usb_device *udev;
97-
9896
lockdep_assert_held(&sb->mutex);
9997

10098
if (!sb->ir)
10199
return;
102100

103101
xhci_remove_secondary_interrupter(xhci_to_hcd(sb->xhci), sb->ir);
104102
sb->ir = NULL;
105-
udev = sb->vdev->udev;
106-
107-
if (udev->state != USB_STATE_NOTATTACHED)
108-
usb_offload_put(udev);
109103
}
110104

111105
/* sideband api functions */
@@ -328,9 +322,6 @@ int
328322
xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg,
329323
bool ip_autoclear, u32 imod_interval, int intr_num)
330324
{
331-
int ret = 0;
332-
struct usb_device *udev;
333-
334325
if (!sb || !sb->xhci)
335326
return -ENODEV;
336327

@@ -348,12 +339,9 @@ xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg,
348339
if (!sb->ir)
349340
return -ENOMEM;
350341

351-
udev = sb->vdev->udev;
352-
ret = usb_offload_get(udev);
353-
354342
sb->ir->ip_autoclear = ip_autoclear;
355343

356-
return ret;
344+
return 0;
357345
}
358346
EXPORT_SYMBOL_GPL(xhci_sideband_create_interrupter);
359347

sound/usb/qcom/qc_audio_offload.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ static void uaudio_event_ring_cleanup_free(struct uaudio_dev *dev)
699699
uaudio_iommu_unmap(MEM_EVENT_RING, IOVA_BASE, PAGE_SIZE,
700700
PAGE_SIZE);
701701
xhci_sideband_remove_interrupter(uadev[dev->chip->card->number].sb);
702+
usb_offload_put(dev->udev);
702703
}
703704
}
704705

@@ -1182,12 +1183,16 @@ static int uaudio_event_ring_setup(struct snd_usb_substream *subs,
11821183
dma_coherent = dev_is_dma_coherent(subs->dev->bus->sysdev);
11831184
er_pa = 0;
11841185

1186+
ret = usb_offload_get(subs->dev);
1187+
if (ret < 0)
1188+
goto exit;
1189+
11851190
/* event ring */
11861191
ret = xhci_sideband_create_interrupter(uadev[card_num].sb, 1, false,
11871192
0, uaudio_qdev->data->intr_num);
11881193
if (ret < 0) {
11891194
dev_err(&subs->dev->dev, "failed to fetch interrupter\n");
1190-
goto exit;
1195+
goto put_offload;
11911196
}
11921197

11931198
sgt = xhci_sideband_get_event_buffer(uadev[card_num].sb);
@@ -1219,6 +1224,8 @@ static int uaudio_event_ring_setup(struct snd_usb_substream *subs,
12191224
mem_info->dma = 0;
12201225
remove_interrupter:
12211226
xhci_sideband_remove_interrupter(uadev[card_num].sb);
1227+
put_offload:
1228+
usb_offload_put(subs->dev);
12221229
exit:
12231230
return ret;
12241231
}
@@ -1482,6 +1489,7 @@ static int prepare_qmi_response(struct snd_usb_substream *subs,
14821489
uaudio_iommu_unmap(MEM_EVENT_RING, IOVA_BASE, PAGE_SIZE, PAGE_SIZE);
14831490
free_sec_ring:
14841491
xhci_sideband_remove_interrupter(uadev[card_num].sb);
1492+
usb_offload_put(subs->dev);
14851493
drop_sync_ep:
14861494
if (subs->sync_endpoint) {
14871495
uaudio_iommu_unmap(MEM_XFER_RING,

0 commit comments

Comments
 (0)