You've already forked linux-t2-patches
mirror of
https://github.com/t2linux/linux-t2-patches.git
synced 2026-04-30 13:52:11 -07:00
Fix bce cold boot
This commit is contained in:
+120
-40
@@ -1,12 +1,12 @@
|
||||
From 54a49b19e01908431a429bd136dacd30c3db0d02 Mon Sep 17 00:00:00 2001
|
||||
From e1a23245810b453b4588fde8351645493ccf5826 Mon Sep 17 00:00:00 2001
|
||||
From: Aditya Garg <gargaditya08@live.com>
|
||||
Date: Thu, 11 Jul 2024 10:59:04 +0000
|
||||
Date: Sun, 22 Feb 2026 04:11:04 +0000
|
||||
Subject: [PATCH] Add apple-bce driver
|
||||
|
||||
---
|
||||
drivers/staging/apple-bce/Makefile | 28 +
|
||||
drivers/staging/apple-bce/apple_bce.c | 445 ++++++++++
|
||||
drivers/staging/apple-bce/apple_bce.h | 38 +
|
||||
drivers/staging/apple-bce/apple_bce.h | 41 +
|
||||
drivers/staging/apple-bce/audio/audio.c | 711 ++++++++++++++++
|
||||
drivers/staging/apple-bce/audio/audio.h | 125 +++
|
||||
drivers/staging/apple-bce/audio/description.h | 42 +
|
||||
@@ -14,22 +14,22 @@ Subject: [PATCH] Add apple-bce driver
|
||||
drivers/staging/apple-bce/audio/pcm.h | 16 +
|
||||
drivers/staging/apple-bce/audio/protocol.c | 347 ++++++++
|
||||
drivers/staging/apple-bce/audio/protocol.h | 147 ++++
|
||||
.../staging/apple-bce/audio/protocol_bce.c | 226 ++++++
|
||||
.../staging/apple-bce/audio/protocol_bce.c | 226 +++++
|
||||
.../staging/apple-bce/audio/protocol_bce.h | 72 ++
|
||||
drivers/staging/apple-bce/mailbox.c | 151 ++++
|
||||
drivers/staging/apple-bce/mailbox.c | 155 ++++
|
||||
drivers/staging/apple-bce/mailbox.h | 53 ++
|
||||
drivers/staging/apple-bce/queue.c | 390 +++++++++
|
||||
drivers/staging/apple-bce/queue.c | 415 +++++++++
|
||||
drivers/staging/apple-bce/queue.h | 177 ++++
|
||||
drivers/staging/apple-bce/queue_dma.c | 220 +++++
|
||||
drivers/staging/apple-bce/queue_dma.h | 50 ++
|
||||
drivers/staging/apple-bce/vhci/command.h | 204 +++++
|
||||
drivers/staging/apple-bce/vhci/queue.c | 268 +++++++
|
||||
drivers/staging/apple-bce/vhci/command.h | 205 +++++
|
||||
drivers/staging/apple-bce/vhci/queue.c | 268 ++++++
|
||||
drivers/staging/apple-bce/vhci/queue.h | 76 ++
|
||||
drivers/staging/apple-bce/vhci/transfer.c | 661 +++++++++++++++
|
||||
drivers/staging/apple-bce/vhci/transfer.h | 73 ++
|
||||
drivers/staging/apple-bce/vhci/vhci.c | 759 ++++++++++++++++++
|
||||
drivers/staging/apple-bce/vhci/vhci.h | 52 ++
|
||||
25 files changed, 5639 insertions(+)
|
||||
drivers/staging/apple-bce/vhci/transfer.c | 673 +++++++++++++++
|
||||
drivers/staging/apple-bce/vhci/transfer.h | 72 ++
|
||||
drivers/staging/apple-bce/vhci/vhci.c | 796 ++++++++++++++++++
|
||||
drivers/staging/apple-bce/vhci/vhci.h | 53 ++
|
||||
25 files changed, 5721 insertions(+)
|
||||
create mode 100644 drivers/staging/apple-bce/Makefile
|
||||
create mode 100644 drivers/staging/apple-bce/apple_bce.c
|
||||
create mode 100644 drivers/staging/apple-bce/apple_bce.h
|
||||
@@ -543,11 +543,12 @@ index 000000000..4fd2415d7
|
||||
+module_exit(apple_bce_module_exit);
|
||||
diff --git a/drivers/staging/apple-bce/apple_bce.h b/drivers/staging/apple-bce/apple_bce.h
|
||||
new file mode 100644
|
||||
index 000000000..f13ab8d57
|
||||
index 000000000..58dbeff79
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/apple_bce.h
|
||||
@@ -0,0 +1,38 @@
|
||||
+#pragma once
|
||||
@@ -0,0 +1,41 @@
|
||||
+#ifndef APPLE_BCE_H
|
||||
+#define APPLE_BCE_H
|
||||
+
|
||||
+#include <linux/pci.h>
|
||||
+#include <linux/spinlock.h>
|
||||
@@ -585,7 +586,8 @@ index 000000000..f13ab8d57
|
||||
+};
|
||||
+
|
||||
+extern struct apple_bce_device *global_bce;
|
||||
\ No newline at end of file
|
||||
+
|
||||
+#endif //APPLE_BCE_H
|
||||
diff --git a/drivers/staging/apple-bce/audio/audio.c b/drivers/staging/apple-bce/audio/audio.c
|
||||
new file mode 100644
|
||||
index 000000000..bd16ddd16
|
||||
@@ -2637,13 +2639,14 @@ index 000000000..14d26c05d
|
||||
+#endif //AAUDIO_PROTOCOL_BCE_H
|
||||
diff --git a/drivers/staging/apple-bce/mailbox.c b/drivers/staging/apple-bce/mailbox.c
|
||||
new file mode 100644
|
||||
index 000000000..e24bd3521
|
||||
index 000000000..07ce11928
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/mailbox.c
|
||||
@@ -0,0 +1,151 @@
|
||||
@@ -0,0 +1,155 @@
|
||||
+#include "mailbox.h"
|
||||
+#include <linux/atomic.h>
|
||||
+#include "apple_bce.h"
|
||||
+#include <linux/version.h>
|
||||
+
|
||||
+#define REG_MBOX_OUT_BASE 0x820
|
||||
+#define REG_MBOX_REPLY_COUNTER 0x108
|
||||
@@ -2764,8 +2767,11 @@ index 000000000..e24bd3521
|
||||
+ spin_lock_irqsave(&ts->stop_sl, flags);
|
||||
+ ts->stopped = true;
|
||||
+ spin_unlock_irqrestore(&ts->stop_sl, flags);
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,15,0)
|
||||
+ del_timer_sync(&ts->timer);
|
||||
+
|
||||
+#else
|
||||
+ timer_delete_sync(&ts->timer);
|
||||
+#endif
|
||||
+ iowrite32((u32) -2, regb + 2);
|
||||
+ iowrite32((u32) -1, regb);
|
||||
+}
|
||||
@@ -2792,7 +2798,6 @@ index 000000000..e24bd3521
|
||||
+ spin_unlock(&ts->stop_sl);
|
||||
+ local_irq_restore(flags);
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/drivers/staging/apple-bce/mailbox.h b/drivers/staging/apple-bce/mailbox.h
|
||||
new file mode 100644
|
||||
index 000000000..f3323f95b
|
||||
@@ -2854,12 +2859,13 @@ index 000000000..f3323f95b
|
||||
+#endif //BCEDRIVER_MAILBOX_H
|
||||
diff --git a/drivers/staging/apple-bce/queue.c b/drivers/staging/apple-bce/queue.c
|
||||
new file mode 100644
|
||||
index 000000000..bc9cd3bc6
|
||||
index 000000000..948286157
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/queue.c
|
||||
@@ -0,0 +1,390 @@
|
||||
@@ -0,0 +1,415 @@
|
||||
+#include "queue.h"
|
||||
+#include "apple_bce.h"
|
||||
+#include <linux/version.h>
|
||||
+
|
||||
+#define REG_DOORBELL_BASE 0x44000
|
||||
+
|
||||
@@ -3179,7 +3185,11 @@ index 000000000..bc9cd3bc6
|
||||
+{
|
||||
+ struct bce_queue_cq *cq;
|
||||
+ struct bce_queue_memcfg cfg;
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,18,0)
|
||||
+ int qid = ida_simple_get(&dev->queue_ida, BCE_QUEUE_USER_MIN, BCE_QUEUE_USER_MAX, GFP_KERNEL);
|
||||
+#else
|
||||
+ int qid = ida_alloc_range(&dev->queue_ida, BCE_QUEUE_USER_MIN, BCE_QUEUE_USER_MAX - 1, GFP_KERNEL);
|
||||
+#endif
|
||||
+ if (qid < 0)
|
||||
+ return NULL;
|
||||
+ cq = bce_alloc_cq(dev, qid, el_count);
|
||||
@@ -3189,7 +3199,11 @@ index 000000000..bc9cd3bc6
|
||||
+ if (bce_cmd_register_queue(dev->cmd_cmdq, &cfg, NULL, false) != 0) {
|
||||
+ pr_err("apple-bce: CQ registration failed (%i)", qid);
|
||||
+ bce_free_cq(dev, cq);
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,18,0)
|
||||
+ ida_simple_remove(&dev->queue_ida, (uint) qid);
|
||||
+#else
|
||||
+ ida_free(&dev->queue_ida, (uint) qid);
|
||||
+#endif
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ dev->queues[qid] = (struct bce_queue *) cq;
|
||||
@@ -3208,7 +3222,11 @@ index 000000000..bc9cd3bc6
|
||||
+ return NULL; /* name can not be null */
|
||||
+ if (direction != DMA_TO_DEVICE && direction != DMA_FROM_DEVICE)
|
||||
+ return NULL; /* unsupported direction */
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,18,0)
|
||||
+ qid = ida_simple_get(&dev->queue_ida, BCE_QUEUE_USER_MIN, BCE_QUEUE_USER_MAX, GFP_KERNEL);
|
||||
+#else
|
||||
+ qid = ida_alloc_range(&dev->queue_ida, BCE_QUEUE_USER_MIN, BCE_QUEUE_USER_MAX - 1, GFP_KERNEL);
|
||||
+#endif
|
||||
+ if (qid < 0)
|
||||
+ return NULL;
|
||||
+ sq = bce_alloc_sq(dev, qid, sizeof(struct bce_qe_submission), el_count, compl, userdata);
|
||||
@@ -3218,7 +3236,11 @@ index 000000000..bc9cd3bc6
|
||||
+ if (bce_cmd_register_queue(dev->cmd_cmdq, &cfg, name, direction != DMA_FROM_DEVICE) != 0) {
|
||||
+ pr_err("apple-bce: SQ registration failed (%i)", qid);
|
||||
+ bce_free_sq(dev, sq);
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,18,0)
|
||||
+ ida_simple_remove(&dev->queue_ida, (uint) qid);
|
||||
+#else
|
||||
+ ida_free(&dev->queue_ida, (uint) qid);
|
||||
+#endif
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ spin_lock(&dev->queues_lock);
|
||||
@@ -3234,7 +3256,11 @@ index 000000000..bc9cd3bc6
|
||||
+ spin_lock(&dev->queues_lock);
|
||||
+ dev->queues[cq->qid] = NULL;
|
||||
+ spin_unlock(&dev->queues_lock);
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,18,0)
|
||||
+ ida_simple_remove(&dev->queue_ida, (uint) cq->qid);
|
||||
+#else
|
||||
+ ida_free(&dev->queue_ida, (uint) cq->qid);
|
||||
+#endif
|
||||
+ bce_free_cq(dev, cq);
|
||||
+}
|
||||
+
|
||||
@@ -3245,7 +3271,11 @@ index 000000000..bc9cd3bc6
|
||||
+ spin_lock(&dev->queues_lock);
|
||||
+ dev->queues[sq->qid] = NULL;
|
||||
+ spin_unlock(&dev->queues_lock);
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,18,0)
|
||||
+ ida_simple_remove(&dev->queue_ida, (uint) sq->qid);
|
||||
+#else
|
||||
+ ida_free(&dev->queue_ida, (uint) sq->qid);
|
||||
+#endif
|
||||
+ bce_free_sq(dev, sq);
|
||||
+}
|
||||
\ No newline at end of file
|
||||
@@ -3717,10 +3747,10 @@ index 000000000..f8a57e50e
|
||||
+#endif //BCE_QUEUE_DMA_H
|
||||
diff --git a/drivers/staging/apple-bce/vhci/command.h b/drivers/staging/apple-bce/vhci/command.h
|
||||
new file mode 100644
|
||||
index 000000000..26619e0bc
|
||||
index 000000000..5cba51561
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/vhci/command.h
|
||||
@@ -0,0 +1,204 @@
|
||||
@@ -0,0 +1,205 @@
|
||||
+#ifndef BCE_VHCI_COMMAND_H
|
||||
+#define BCE_VHCI_COMMAND_H
|
||||
+
|
||||
@@ -3750,6 +3780,7 @@ index 000000000..26619e0bc
|
||||
+ BCE_VHCI_CMD_PORT_RESET = 0x14,
|
||||
+ BCE_VHCI_CMD_PORT_DISABLE = 0x15,
|
||||
+ BCE_VHCI_CMD_PORT_STATUS = 0x16,
|
||||
+ BCE_VHCI_CMD_PORT_STATUS_CHANGE = 0x18,
|
||||
+
|
||||
+ BCE_VHCI_CMD_DEVICE_CREATE = 0x30,
|
||||
+ BCE_VHCI_CMD_DEVICE_DESTROY = 0x31,
|
||||
@@ -4283,10 +4314,10 @@ index 000000000..adb705b6b
|
||||
+#endif //BCE_VHCI_QUEUE_H
|
||||
diff --git a/drivers/staging/apple-bce/vhci/transfer.c b/drivers/staging/apple-bce/vhci/transfer.c
|
||||
new file mode 100644
|
||||
index 000000000..8226363d6
|
||||
index 000000000..d77220707
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/vhci/transfer.c
|
||||
@@ -0,0 +1,661 @@
|
||||
@@ -0,0 +1,673 @@
|
||||
+#include "transfer.h"
|
||||
+#include "../queue.h"
|
||||
+#include "vhci.h"
|
||||
@@ -4689,6 +4720,7 @@ index 000000000..8226363d6
|
||||
+ struct bce_vhci_urb *vurb;
|
||||
+ unsigned long flags;
|
||||
+ int ret;
|
||||
+ enum bce_vhci_urb_state old_state;
|
||||
+
|
||||
+ spin_lock_irqsave(&q->urb_lock, flags);
|
||||
+ if ((ret = usb_hcd_check_unlink_urb(q->vhci->hcd, urb, status))) {
|
||||
@@ -4697,8 +4729,19 @@ index 000000000..8226363d6
|
||||
+ }
|
||||
+
|
||||
+ vurb = urb->hcpriv;
|
||||
+
|
||||
+ old_state = vurb->state; /* save old state to use later because we'll set state as cancelled */
|
||||
+
|
||||
+ if (old_state == BCE_VHCI_URB_CANCELLED) {
|
||||
+ spin_unlock_irqrestore(&q->urb_lock, flags);
|
||||
+ pr_debug("bce-vhci: URB %p is already cancelled, skipping\n", urb);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ vurb->state = BCE_VHCI_URB_CANCELLED;
|
||||
+
|
||||
+ /* If the URB wasn't posted to the device yet, we can still remove it on the host without pausing the queue. */
|
||||
+ if (vurb->state != BCE_VHCI_URB_INIT_PENDING) {
|
||||
+ if (old_state != BCE_VHCI_URB_INIT_PENDING) {
|
||||
+ pr_debug("bce-vhci: [%02x] Cancelling URB\n", q->endp_addr);
|
||||
+
|
||||
+ spin_unlock_irqrestore(&q->urb_lock, flags);
|
||||
@@ -4714,7 +4757,7 @@ index 000000000..8226363d6
|
||||
+
|
||||
+ usb_hcd_giveback_urb(q->vhci->hcd, urb, status);
|
||||
+
|
||||
+ if (vurb->state != BCE_VHCI_URB_INIT_PENDING)
|
||||
+ if (old_state != BCE_VHCI_URB_INIT_PENDING)
|
||||
+ bce_vhci_transfer_queue_resume(q, BCE_VHCI_PAUSE_INTERNAL_WQ);
|
||||
+
|
||||
+ kfree(vurb);
|
||||
@@ -4950,10 +4993,10 @@ index 000000000..8226363d6
|
||||
+}
|
||||
diff --git a/drivers/staging/apple-bce/vhci/transfer.h b/drivers/staging/apple-bce/vhci/transfer.h
|
||||
new file mode 100644
|
||||
index 000000000..89ecad6bc
|
||||
index 000000000..2f4df78c7
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/vhci/transfer.h
|
||||
@@ -0,0 +1,73 @@
|
||||
@@ -0,0 +1,72 @@
|
||||
+#ifndef BCEDRIVER_TRANSFER_H
|
||||
+#define BCEDRIVER_TRANSFER_H
|
||||
+
|
||||
@@ -4993,14 +5036,13 @@ index 000000000..89ecad6bc
|
||||
+};
|
||||
+enum bce_vhci_urb_state {
|
||||
+ BCE_VHCI_URB_INIT_PENDING,
|
||||
+
|
||||
+ BCE_VHCI_URB_WAITING_FOR_TRANSFER_REQUEST,
|
||||
+ BCE_VHCI_URB_WAITING_FOR_COMPLETION,
|
||||
+ BCE_VHCI_URB_DATA_TRANSFER_COMPLETE,
|
||||
+
|
||||
+ BCE_VHCI_URB_CONTROL_WAITING_FOR_SETUP_REQUEST,
|
||||
+ BCE_VHCI_URB_CONTROL_WAITING_FOR_SETUP_COMPLETION,
|
||||
+ BCE_VHCI_URB_CONTROL_COMPLETE
|
||||
+ BCE_VHCI_URB_CONTROL_COMPLETE,
|
||||
+ BCE_VHCI_URB_CANCELLED
|
||||
+};
|
||||
+struct bce_vhci_urb {
|
||||
+ struct urb *urb;
|
||||
@@ -5029,10 +5071,10 @@ index 000000000..89ecad6bc
|
||||
+#endif //BCEDRIVER_TRANSFER_H
|
||||
diff --git a/drivers/staging/apple-bce/vhci/vhci.c b/drivers/staging/apple-bce/vhci/vhci.c
|
||||
new file mode 100644
|
||||
index 000000000..eb26f5500
|
||||
index 000000000..675d47756
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/vhci/vhci.c
|
||||
@@ -0,0 +1,759 @@
|
||||
@@ -0,0 +1,796 @@
|
||||
+#include "vhci.h"
|
||||
+#include "../apple_bce.h"
|
||||
+#include "command.h"
|
||||
@@ -5147,7 +5189,24 @@ index 000000000..eb26f5500
|
||||
+
|
||||
+static int bce_vhci_hub_status_data(struct usb_hcd *hcd, char *buf)
|
||||
+{
|
||||
+ return 0;
|
||||
+ struct bce_vhci *vhci = bce_vhci_from_hcd(hcd);
|
||||
+ unsigned long changed;
|
||||
+ int i, bytes;
|
||||
+
|
||||
+ changed = xchg(&vhci->port_change_pending, 0);
|
||||
+ if (!changed)
|
||||
+ return 0;
|
||||
+
|
||||
+ /* USB hub status bitmap: bit 0 = hub, bits 1..N = ports 1..N.
|
||||
+ * Since we set_bit(port_number, &pending), port N is already
|
||||
+ * in bit N — matching the USB spec layout directly. */
|
||||
+
|
||||
+ bytes = DIV_ROUND_UP(vhci->port_count + 1, 8);
|
||||
+
|
||||
+ for (i = 0; i < bytes; i++)
|
||||
+ buf[i] = (changed >> (i * 8)) & 0xff;
|
||||
+
|
||||
+ return bytes;
|
||||
+}
|
||||
+
|
||||
+static int bce_vhci_reset_device(struct bce_vhci *vhci, int index, u16 timeout);
|
||||
@@ -5275,7 +5334,11 @@ index 000000000..eb26f5500
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0)
|
||||
+static int bce_vhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
|
||||
+#else
|
||||
+static int bce_vhci_address_device(struct usb_hcd *hcd, struct usb_device *udev, unsigned int timeout_ms) //TODO: follow timeout
|
||||
+#endif
|
||||
+{
|
||||
+ /* This is the same as enable_device, but instead in the old scheme */
|
||||
+ return bce_vhci_enable_device(hcd, udev);
|
||||
@@ -5698,8 +5761,24 @@ index 000000000..eb26f5500
|
||||
+
|
||||
+static void bce_vhci_handle_system_event(struct bce_vhci_event_queue *q, struct bce_vhci_message *msg)
|
||||
+{
|
||||
+ struct usb_hcd *hcd = q->vhci->hcd;
|
||||
+ if (msg->cmd & 0x8000) {
|
||||
+ bce_vhci_command_queue_deliver_completion(&q->vhci->cq, msg);
|
||||
+ } else if (msg->cmd == BCE_VHCI_CMD_PORT_STATUS_CHANGE &&
|
||||
+ msg->param1 > 0 &&
|
||||
+ msg->param1 <= q->vhci->port_count) {
|
||||
+ /* Port status change notification from T2 — flag the port and
|
||||
+ * tell the USB framework to re-scan so late-initializing devices
|
||||
+ * (camera, Touch Bar, iBridge) are discovered. */
|
||||
+ if (hcd) {
|
||||
+ pr_warn("bce-vhci: Port %u status change event, requesting hub rescan\n",
|
||||
+ msg->param1);
|
||||
+ set_bit(msg->param1, &q->vhci->port_change_pending);
|
||||
+ usb_hcd_poll_rh_status(hcd);
|
||||
+ } else {
|
||||
+ pr_warn("bce-vhci: port %u change received but HCD is NULL\n",
|
||||
+ msg->param1);
|
||||
+ }
|
||||
+ } else {
|
||||
+ pr_warn("bce-vhci: Unhandled system event: %x s=%x p1=%x p2=%llx\n",
|
||||
+ msg->cmd, msg->status, msg->param1, msg->param2);
|
||||
@@ -5794,10 +5873,10 @@ index 000000000..eb26f5500
|
||||
+MODULE_PARM_DESC(vhci_port_mask, "Specifies which VHCI ports are enabled");
|
||||
diff --git a/drivers/staging/apple-bce/vhci/vhci.h b/drivers/staging/apple-bce/vhci/vhci.h
|
||||
new file mode 100644
|
||||
index 000000000..6c2e22622
|
||||
index 000000000..d1e80d8e8
|
||||
--- /dev/null
|
||||
+++ b/drivers/staging/apple-bce/vhci/vhci.h
|
||||
@@ -0,0 +1,52 @@
|
||||
@@ -0,0 +1,53 @@
|
||||
+#ifndef BCE_VHCI_H
|
||||
+#define BCE_VHCI_H
|
||||
+
|
||||
@@ -5837,6 +5916,7 @@ index 000000000..6c2e22622
|
||||
+ struct bce_vhci_device *devices[16];
|
||||
+ struct workqueue_struct *tq_state_wq;
|
||||
+ struct work_struct w_fw_events;
|
||||
+ unsigned long port_change_pending;
|
||||
+};
|
||||
+
|
||||
+int __init bce_vhci_module_init(void);
|
||||
@@ -5851,5 +5931,5 @@ index 000000000..6c2e22622
|
||||
+
|
||||
+#endif //BCE_VHCI_H
|
||||
--
|
||||
2.45.2
|
||||
2.52.0
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
From f19c26b239797221f5b5d0afffef8a639261ec2c Mon Sep 17 00:00:00 2001
|
||||
From: Aditya Garg <gargaditya08@live.com>
|
||||
Date: Sun, 13 Apr 2025 11:43:53 +0530
|
||||
Subject: [PATCH 1/2] Fix sparse errors
|
||||
|
||||
apple_bce.h was using #pragma once, which is not acceptable by sparse
|
||||
---
|
||||
drivers/staging/apple-bce/apple_bce.h | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/staging/apple-bce/apple_bce.h b/drivers/staging/apple-bce/apple_bce.h
|
||||
index f13ab8d57..58dbeff79 100644
|
||||
--- a/drivers/staging/apple-bce/apple_bce.h
|
||||
+++ b/drivers/staging/apple-bce/apple_bce.h
|
||||
@@ -1,4 +1,5 @@
|
||||
-#pragma once
|
||||
+#ifndef APPLE_BCE_H
|
||||
+#define APPLE_BCE_H
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include <linux/spinlock.h>
|
||||
@@ -35,4 +36,6 @@ struct apple_bce_device {
|
||||
struct bce_vhci vhci;
|
||||
};
|
||||
|
||||
-extern struct apple_bce_device *global_bce;
|
||||
\ No newline at end of file
|
||||
+extern struct apple_bce_device *global_bce;
|
||||
+
|
||||
+#endif //APPLE_BCE_H
|
||||
--
|
||||
2.49.0
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
From e0bfaa626a26d2a41d5385a768132e54294f7af5 Mon Sep 17 00:00:00 2001
|
||||
From: mnural <mehmet.nrl@hotmail.com>
|
||||
Date: Mon, 14 Apr 2025 14:44:20 +0530
|
||||
Subject: [PATCH 2/2] Fix freezing on turning off camera
|
||||
|
||||
Detailed logs and reason behind can be seen here:
|
||||
https://github.com/t2linux/T2-Debian-and-Ubuntu-Kernel/issues/130#issuecomment-2799130835
|
||||
---
|
||||
drivers/staging/apple-bce/vhci/transfer.c | 16 ++++++++++++++--
|
||||
drivers/staging/apple-bce/vhci/transfer.h | 4 +++-
|
||||
2 files changed, 17 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/staging/apple-bce/vhci/transfer.c b/drivers/staging/apple-bce/vhci/transfer.c
|
||||
index 8226363d6..d77220707 100644
|
||||
--- a/drivers/staging/apple-bce/vhci/transfer.c
|
||||
+++ b/drivers/staging/apple-bce/vhci/transfer.c
|
||||
@@ -400,6 +400,7 @@ int bce_vhci_urb_request_cancel(struct bce_vhci_transfer_queue *q, struct urb *u
|
||||
struct bce_vhci_urb *vurb;
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
+ enum bce_vhci_urb_state old_state;
|
||||
|
||||
spin_lock_irqsave(&q->urb_lock, flags);
|
||||
if ((ret = usb_hcd_check_unlink_urb(q->vhci->hcd, urb, status))) {
|
||||
@@ -408,8 +409,19 @@ int bce_vhci_urb_request_cancel(struct bce_vhci_transfer_queue *q, struct urb *u
|
||||
}
|
||||
|
||||
vurb = urb->hcpriv;
|
||||
+
|
||||
+ old_state = vurb->state; /* save old state to use later because we'll set state as cancelled */
|
||||
+
|
||||
+ if (old_state == BCE_VHCI_URB_CANCELLED) {
|
||||
+ spin_unlock_irqrestore(&q->urb_lock, flags);
|
||||
+ pr_debug("bce-vhci: URB %p is already cancelled, skipping\n", urb);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ vurb->state = BCE_VHCI_URB_CANCELLED;
|
||||
+
|
||||
/* If the URB wasn't posted to the device yet, we can still remove it on the host without pausing the queue. */
|
||||
- if (vurb->state != BCE_VHCI_URB_INIT_PENDING) {
|
||||
+ if (old_state != BCE_VHCI_URB_INIT_PENDING) {
|
||||
pr_debug("bce-vhci: [%02x] Cancelling URB\n", q->endp_addr);
|
||||
|
||||
spin_unlock_irqrestore(&q->urb_lock, flags);
|
||||
@@ -425,7 +437,7 @@ int bce_vhci_urb_request_cancel(struct bce_vhci_transfer_queue *q, struct urb *u
|
||||
|
||||
usb_hcd_giveback_urb(q->vhci->hcd, urb, status);
|
||||
|
||||
- if (vurb->state != BCE_VHCI_URB_INIT_PENDING)
|
||||
+ if (old_state != BCE_VHCI_URB_INIT_PENDING)
|
||||
bce_vhci_transfer_queue_resume(q, BCE_VHCI_PAUSE_INTERNAL_WQ);
|
||||
|
||||
kfree(vurb);
|
||||
diff --git a/drivers/staging/apple-bce/vhci/transfer.h b/drivers/staging/apple-bce/vhci/transfer.h
|
||||
index 89ecad6bc..b5403d570 100644
|
||||
--- a/drivers/staging/apple-bce/vhci/transfer.h
|
||||
+++ b/drivers/staging/apple-bce/vhci/transfer.h
|
||||
@@ -44,7 +44,9 @@ enum bce_vhci_urb_state {
|
||||
|
||||
BCE_VHCI_URB_CONTROL_WAITING_FOR_SETUP_REQUEST,
|
||||
BCE_VHCI_URB_CONTROL_WAITING_FOR_SETUP_COMPLETION,
|
||||
- BCE_VHCI_URB_CONTROL_COMPLETE
|
||||
+ BCE_VHCI_URB_CONTROL_COMPLETE,
|
||||
+
|
||||
+ BCE_VHCI_URB_CANCELLED
|
||||
};
|
||||
struct bce_vhci_urb {
|
||||
struct urb *urb;
|
||||
--
|
||||
2.49.0
|
||||
|
||||
Reference in New Issue
Block a user