Update BCE

This commit is contained in:
Aditya Garg
2022-09-21 23:14:16 +05:30
parent 8be2883366
commit df76339eb1
3 changed files with 38 additions and 270 deletions
+38 -45
View File
@@ -1,14 +1,13 @@
From 1b75b72332cb0fd2735d7246054a57b2dc93c015 Mon Sep 17 00:00:00 2001 From 28d876289e6c7fe64a6fcdbc377035a99edbae44 Mon Sep 17 00:00:00 2001
From: Aditya Garg <gargaditya08@live.com> From: Aditya Garg <gargaditya08@live.com>
Date: Sat, 14 May 2022 11:58:24 +0530 Date: Wed, 21 Sep 2022 23:12:21 +0530
Subject: [PATCH 1/2] Add apple-bce driver Subject: [PATCH] Add apple-bce driver
--- ---
drivers/staging/apple-bce/Makefile | 28 + drivers/staging/apple-bce/Makefile | 28 +
drivers/staging/apple-bce/README.md | 11 +
drivers/staging/apple-bce/apple_bce.c | 438 ++++++++++ drivers/staging/apple-bce/apple_bce.c | 438 ++++++++++
drivers/staging/apple-bce/apple_bce.h | 38 + drivers/staging/apple-bce/apple_bce.h | 38 +
drivers/staging/apple-bce/audio/audio.c | 693 ++++++++++++++++ drivers/staging/apple-bce/audio/audio.c | 706 ++++++++++++++++
drivers/staging/apple-bce/audio/audio.h | 123 +++ drivers/staging/apple-bce/audio/audio.h | 123 +++
drivers/staging/apple-bce/audio/description.h | 42 + drivers/staging/apple-bce/audio/description.h | 42 +
drivers/staging/apple-bce/audio/pcm.c | 308 +++++++ drivers/staging/apple-bce/audio/pcm.c | 308 +++++++
@@ -30,9 +29,8 @@ Subject: [PATCH 1/2] Add apple-bce driver
drivers/staging/apple-bce/vhci/transfer.h | 78 ++ drivers/staging/apple-bce/vhci/transfer.h | 78 ++
drivers/staging/apple-bce/vhci/vhci.c | 755 ++++++++++++++++++ drivers/staging/apple-bce/vhci/vhci.c | 755 ++++++++++++++++++
drivers/staging/apple-bce/vhci/vhci.h | 48 ++ drivers/staging/apple-bce/vhci/vhci.h | 48 ++
26 files changed, 5658 insertions(+) 25 files changed, 5660 insertions(+)
create mode 100644 drivers/staging/apple-bce/Makefile create mode 100644 drivers/staging/apple-bce/Makefile
create mode 100644 drivers/staging/apple-bce/README.md
create mode 100644 drivers/staging/apple-bce/apple_bce.c create mode 100644 drivers/staging/apple-bce/apple_bce.c
create mode 100644 drivers/staging/apple-bce/apple_bce.h create mode 100644 drivers/staging/apple-bce/apple_bce.h
create mode 100644 drivers/staging/apple-bce/audio/audio.c create mode 100644 drivers/staging/apple-bce/audio/audio.c
@@ -92,23 +90,6 @@ index 000000000..a6a656f06
+ +
+install: +install:
+ $(MAKE) -C $(KDIR) M=$(PWD) modules_install + $(MAKE) -C $(KDIR) M=$(PWD) modules_install
diff --git a/drivers/staging/apple-bce/README.md b/drivers/staging/apple-bce/README.md
new file mode 100644
index 000000000..ab1054dea
--- /dev/null
+++ b/drivers/staging/apple-bce/README.md
@@ -0,0 +1,11 @@
+# MacBook Bridge/T2 Linux Driver
+A driver for MacBook models 2018 and newer, implementing the VHCI (required for mouse/keyboard/etc.) and audio functionality.
+
+The project is divided into 3 main components:
+- BCE (Buffer Copy Engine) - this is what the files in the root directory are for. This estabilishes a basic communication channel with the T2. VHCI and Audio both require this component.
+- VHCI - this is a virtual USB host controller; keyboard, mouse and other system components are provided by this component (other drivers use this host controller to provide more functionality, however USB drivers are not in this project's scope).
+- Audio - a driver for the T2 audio interface, currently only audio output is supported.
+
+Please note that the `master` branch does not currently support system suspend and resume.
+
+If you want to support me, you can do so by donating to me on PayPal: https://paypal.me/mcmrarm
diff --git a/drivers/staging/apple-bce/apple_bce.c b/drivers/staging/apple-bce/apple_bce.c diff --git a/drivers/staging/apple-bce/apple_bce.c b/drivers/staging/apple-bce/apple_bce.c
new file mode 100644 new file mode 100644
index 000000000..4f733a0fa index 000000000..4f733a0fa
@@ -601,10 +582,10 @@ index 000000000..f13ab8d57
\ No newline at end of file \ No newline at end of file
diff --git a/drivers/staging/apple-bce/audio/audio.c b/drivers/staging/apple-bce/audio/audio.c diff --git a/drivers/staging/apple-bce/audio/audio.c b/drivers/staging/apple-bce/audio/audio.c
new file mode 100644 new file mode 100644
index 000000000..14aa3a062 index 000000000..2e0f75f2d
--- /dev/null --- /dev/null
+++ b/drivers/staging/apple-bce/audio/audio.c +++ b/drivers/staging/apple-bce/audio/audio.c
@@ -0,0 +1,693 @@ @@ -0,0 +1,706 @@
+#include <linux/pci.h> +#include <linux/pci.h>
+#include <linux/spinlock.h> +#include <linux/spinlock.h>
+#include <linux/module.h> +#include <linux/module.h>
@@ -630,6 +611,7 @@ index 000000000..14aa3a062
+static int aaudio_probe(struct pci_dev *dev, const struct pci_device_id *id) +static int aaudio_probe(struct pci_dev *dev, const struct pci_device_id *id)
+{ +{
+ struct aaudio_device *aaudio = NULL; + struct aaudio_device *aaudio = NULL;
+ struct aaudio_subdevice *sdev = NULL;
+ int status = 0; + int status = 0;
+ u32 cfg; + u32 cfg;
+ +
@@ -697,7 +679,7 @@ index 000000000..14aa3a062
+ dev_err(&dev->dev, "aaudio: Failed to create ALSA card\n"); + dev_err(&dev->dev, "aaudio: Failed to create ALSA card\n");
+ goto fail; + goto fail;
+ } + }
+ strcpy(aaudio->card->driver, "AppleT2"); +
+ strcpy(aaudio->card->shortname, "Apple T2 Audio"); + strcpy(aaudio->card->shortname, "Apple T2 Audio");
+ strcpy(aaudio->card->longname, "Apple T2 Audio"); + strcpy(aaudio->card->longname, "Apple T2 Audio");
+ strcpy(aaudio->card->mixername, "Apple T2 Audio"); + strcpy(aaudio->card->mixername, "Apple T2 Audio");
@@ -708,10 +690,12 @@ index 000000000..14aa3a062
+ dev_err(&dev->dev, "aaudio: Failed to initialize over BCE\n"); + dev_err(&dev->dev, "aaudio: Failed to initialize over BCE\n");
+ goto fail_snd; + goto fail_snd;
+ } + }
+
+ if (aaudio_init_bs(aaudio)) { + if (aaudio_init_bs(aaudio)) {
+ dev_err(&dev->dev, "aaudio: Failed to initialize BufferStruct\n"); + dev_err(&dev->dev, "aaudio: Failed to initialize BufferStruct\n");
+ goto fail_snd; + goto fail_snd;
+ } + }
+
+ if ((status = aaudio_cmd_set_remote_access(aaudio, AAUDIO_REMOTE_ACCESS_ON))) { + if ((status = aaudio_cmd_set_remote_access(aaudio, AAUDIO_REMOTE_ACCESS_ON))) {
+ dev_err(&dev->dev, "Failed to set remote access\n"); + dev_err(&dev->dev, "Failed to set remote access\n");
+ return status; + return status;
@@ -722,6 +706,16 @@ index 000000000..14aa3a062
+ goto fail_snd; + goto fail_snd;
+ } + }
+ +
+ list_for_each_entry(sdev, &aaudio->subdevice_list, list) {
+ struct aaudio_buffer_struct_device *dev = &aaudio->bs->devices[sdev->buf_id];
+
+ if (sdev->out_stream_cnt == 1 && !strcmp(dev->name, "Speaker")) {
+ struct snd_pcm_hardware *hw = sdev->out_streams[0].alsa_hw_desc;
+
+ snprintf(aaudio->card->driver, sizeof(aaudio->card->driver) / sizeof(char), "AppleT2x%d", hw->channels_min);
+ }
+ }
+
+ return 0; + return 0;
+ +
+fail_snd: +fail_snd:
@@ -1207,7 +1201,7 @@ index 000000000..14aa3a062
+ struct aaudio_subdevice *sdev; + struct aaudio_subdevice *sdev;
+ u64 devid, timestamp, update_seed; + u64 devid, timestamp, update_seed;
+ aaudio_msg_read_update_timestamp(msg, &devid, &timestamp, &update_seed); + aaudio_msg_read_update_timestamp(msg, &devid, &timestamp, &update_seed);
+ dev_info(a->dev, "Received timestamp update for dev=%llx ts=%llx seed=%llx\n", devid, timestamp, update_seed); + dev_dbg(a->dev, "Received timestamp update for dev=%llx ts=%llx seed=%llx\n", devid, timestamp, update_seed);
+ +
+ sdev = aaudio_find_dev_by_dev_id(a, devid); + sdev = aaudio_find_dev_by_dev_id(a, devid);
+ aaudio_handle_timestamp(sdev, time_os, timestamp); + aaudio_handle_timestamp(sdev, time_os, timestamp);
@@ -1298,7 +1292,6 @@ index 000000000..14aa3a062
+MODULE_PARM_DESC(index, "Index value for Apple Internal Audio soundcard."); +MODULE_PARM_DESC(index, "Index value for Apple Internal Audio soundcard.");
+module_param_named(id, aaudio_alsa_id, charp, 0444); +module_param_named(id, aaudio_alsa_id, charp, 0444);
+MODULE_PARM_DESC(id, "ID string for Apple Internal Audio soundcard."); +MODULE_PARM_DESC(id, "ID string for Apple Internal Audio soundcard.");
\ No newline at end of file
diff --git a/drivers/staging/apple-bce/audio/audio.h b/drivers/staging/apple-bce/audio/audio.h diff --git a/drivers/staging/apple-bce/audio/audio.h b/drivers/staging/apple-bce/audio/audio.h
new file mode 100644 new file mode 100644
index 000000000..693006e93 index 000000000..693006e93
@@ -1478,7 +1471,7 @@ index 000000000..dfef3ab68
+#endif //AAUDIO_DESCRIPTION_H +#endif //AAUDIO_DESCRIPTION_H
diff --git a/drivers/staging/apple-bce/audio/pcm.c b/drivers/staging/apple-bce/audio/pcm.c diff --git a/drivers/staging/apple-bce/audio/pcm.c b/drivers/staging/apple-bce/audio/pcm.c
new file mode 100644 new file mode 100644
index 000000000..faf80b53f index 000000000..1026e10a9
--- /dev/null --- /dev/null
+++ b/drivers/staging/apple-bce/audio/pcm.c +++ b/drivers/staging/apple-bce/audio/pcm.c
@@ -0,0 +1,308 @@ @@ -0,0 +1,308 @@
@@ -1593,7 +1586,7 @@ index 000000000..faf80b53f
+ +
+static int aaudio_pcm_open(struct snd_pcm_substream *substream) +static int aaudio_pcm_open(struct snd_pcm_substream *substream)
+{ +{
+ pr_info("aaudio_pcm_open\n"); + pr_debug("aaudio_pcm_open\n");
+ substream->runtime->hw = *aaudio_pcm_stream(substream)->alsa_hw_desc; + substream->runtime->hw = *aaudio_pcm_stream(substream)->alsa_hw_desc;
+ +
+ return 0; + return 0;
@@ -1601,7 +1594,7 @@ index 000000000..faf80b53f
+ +
+static int aaudio_pcm_close(struct snd_pcm_substream *substream) +static int aaudio_pcm_close(struct snd_pcm_substream *substream)
+{ +{
+ pr_info("aaudio_pcm_close\n"); + pr_debug("aaudio_pcm_close\n");
+ return 0; + return 0;
+} +}
+ +
@@ -1613,7 +1606,7 @@ index 000000000..faf80b53f
+static int aaudio_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) +static int aaudio_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params)
+{ +{
+ struct aaudio_stream *astream = aaudio_pcm_stream(substream); + struct aaudio_stream *astream = aaudio_pcm_stream(substream);
+ pr_info("aaudio_pcm_hw_params\n"); + pr_debug("aaudio_pcm_hw_params\n");
+ +
+ if (!astream->buffer_cnt || !astream->buffers) + if (!astream->buffer_cnt || !astream->buffers)
+ return -EINVAL; + return -EINVAL;
@@ -1626,7 +1619,7 @@ index 000000000..faf80b53f
+ +
+static int aaudio_pcm_hw_free(struct snd_pcm_substream *substream) +static int aaudio_pcm_hw_free(struct snd_pcm_substream *substream)
+{ +{
+ pr_info("aaudio_pcm_hw_free\n"); + pr_debug("aaudio_pcm_hw_free\n");
+ return 0; + return 0;
+} +}
+ +
@@ -1647,7 +1640,7 @@ index 000000000..faf80b53f
+ buf = kmalloc(s, GFP_KERNEL); + buf = kmalloc(s, GFP_KERNEL);
+ memcpy_fromio(buf, substream->runtime->dma_area, s); + memcpy_fromio(buf, substream->runtime->dma_area, s);
+ time_end = ktime_get(); + time_end = ktime_get();
+ pr_info("aaudio: Backed up the buffer in %lluns [%li]\n", ktime_to_ns(time_end - time_start), + pr_debug("aaudio: Backed up the buffer in %lluns [%li]\n", ktime_to_ns(time_end - time_start),
+ substream->runtime->control->appl_ptr); + substream->runtime->control->appl_ptr);
+ } + }
+ +
@@ -1659,14 +1652,14 @@ index 000000000..faf80b53f
+ memcpy_toio(substream->runtime->dma_area, buf, s); + memcpy_toio(substream->runtime->dma_area, buf, s);
+ +
+ time_end = ktime_get(); + time_end = ktime_get();
+ pr_info("aaudio: Started the audio device in %lluns\n", ktime_to_ns(time_end - time_start)); + pr_debug("aaudio: Started the audio device in %lluns\n", ktime_to_ns(time_end - time_start));
+} +}
+ +
+static int aaudio_pcm_trigger(struct snd_pcm_substream *substream, int cmd) +static int aaudio_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+{ +{
+ struct aaudio_subdevice *sdev = snd_pcm_substream_chip(substream); + struct aaudio_subdevice *sdev = snd_pcm_substream_chip(substream);
+ struct aaudio_stream *stream = aaudio_pcm_stream(substream); + struct aaudio_stream *stream = aaudio_pcm_stream(substream);
+ pr_info("aaudio_pcm_trigger %x\n", cmd); + pr_debug("aaudio_pcm_trigger %x\n", cmd);
+ +
+ /* We only supports triggers on the #0 buffer */ + /* We only supports triggers on the #0 buffer */
+ if (substream->number != 0) + if (substream->number != 0)
@@ -5066,7 +5059,7 @@ index 000000000..e46e00ad8
+#endif //BCEDRIVER_TRANSFER_H +#endif //BCEDRIVER_TRANSFER_H
diff --git a/drivers/staging/apple-bce/vhci/vhci.c b/drivers/staging/apple-bce/vhci/vhci.c diff --git a/drivers/staging/apple-bce/vhci/vhci.c b/drivers/staging/apple-bce/vhci/vhci.c
new file mode 100644 new file mode 100644
index 000000000..fa8c79152 index 000000000..ae6abcf76
--- /dev/null --- /dev/null
+++ b/drivers/staging/apple-bce/vhci/vhci.c +++ b/drivers/staging/apple-bce/vhci/vhci.c
@@ -0,0 +1,755 @@ @@ -0,0 +1,755 @@
@@ -5242,7 +5235,7 @@ index 000000000..fa8c79152
+ if (port_status & 0x40000) + if (port_status & 0x40000)
+ ps->wPortChange |= USB_PORT_STAT_C_CONNECTION; + ps->wPortChange |= USB_PORT_STAT_C_CONNECTION;
+ +
+ pr_info("bce-vhci: Translated status %x to %x:%x\n", port_status, ps->wPortStatus, ps->wPortChange); + pr_debug("bce-vhci: Translated status %x to %x:%x\n", port_status, ps->wPortStatus, ps->wPortChange);
+ return 0; + return 0;
+ } else if (typeReq == SetPortFeature) { + } else if (typeReq == SetPortFeature) {
+ if (wValue == USB_PORT_FEAT_POWER) { + if (wValue == USB_PORT_FEAT_POWER) {
@@ -5257,7 +5250,7 @@ index 000000000..fa8c79152
+ } + }
+ if (wValue == USB_PORT_FEAT_SUSPEND) { + if (wValue == USB_PORT_FEAT_SUSPEND) {
+ /* TODO: Am I supposed to also suspend the endpoints? */ + /* TODO: Am I supposed to also suspend the endpoints? */
+ pr_info("bce-vhci: Suspending port %i\n", wIndex); + pr_debug("bce-vhci: Suspending port %i\n", wIndex);
+ return bce_vhci_cmd_port_suspend(&vhci->cq, (u8) wIndex); + return bce_vhci_cmd_port_suspend(&vhci->cq, (u8) wIndex);
+ } + }
+ } else if (typeReq == ClearPortFeature) { + } else if (typeReq == ClearPortFeature) {
@@ -5275,7 +5268,7 @@ index 000000000..fa8c79152
+ return 0; + return 0;
+ } + }
+ if (wValue == USB_PORT_FEAT_SUSPEND) { + if (wValue == USB_PORT_FEAT_SUSPEND) {
+ pr_info("bce-vhci: Resuming port %i\n", wIndex); + pr_debug("bce-vhci: Resuming port %i\n", wIndex);
+ return bce_vhci_cmd_port_resume(&vhci->cq, (u8) wIndex); + return bce_vhci_cmd_port_resume(&vhci->cq, (u8) wIndex);
+ } + }
+ } + }
@@ -5363,7 +5356,7 @@ index 000000000..fa8c79152
+ } + }
+ } + }
+ vhci->devices[devid] = NULL; + vhci->devices[devid] = NULL;
+ vhci->port_to_device[devid] = 0; + vhci->port_to_device[index] = 0;
+ bce_vhci_cmd_device_destroy(&vhci->cq, devid); + bce_vhci_cmd_device_destroy(&vhci->cq, devid);
+ } + }
+ status = bce_vhci_cmd_port_reset(&vhci->cq, (u8) index, timeout); + status = bce_vhci_cmd_port_reset(&vhci->cq, (u8) index, timeout);
@@ -5487,14 +5480,14 @@ index 000000000..fa8c79152
+static int bce_vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) +static int bce_vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
+{ +{
+ struct bce_vhci_transfer_queue *q = urb->ep->hcpriv; + struct bce_vhci_transfer_queue *q = urb->ep->hcpriv;
+ pr_info("bce_vhci_urb_dequeue %x\n", urb->ep->desc.bEndpointAddress); + pr_debug("bce_vhci_urb_dequeue %x\n", urb->ep->desc.bEndpointAddress);
+ return bce_vhci_urb_request_cancel(q, urb, status); + return bce_vhci_urb_request_cancel(q, urb, status);
+} +}
+ +
+static void bce_vhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) +static void bce_vhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
+{ +{
+ struct bce_vhci_transfer_queue *q = ep->hcpriv; + struct bce_vhci_transfer_queue *q = ep->hcpriv;
+ pr_info("bce_vhci_endpoint_reset\n"); + pr_debug("bce_vhci_endpoint_reset\n");
+ if (q) + if (q)
+ bce_vhci_transfer_queue_request_reset(q); + bce_vhci_transfer_queue_request_reset(q);
+} +}
@@ -5512,7 +5505,7 @@ index 000000000..fa8c79152
+ struct bce_vhci *vhci = bce_vhci_from_hcd(hcd); + struct bce_vhci *vhci = bce_vhci_from_hcd(hcd);
+ bce_vhci_device_t devid = vhci->port_to_device[udev->portnum]; + bce_vhci_device_t devid = vhci->port_to_device[udev->portnum];
+ struct bce_vhci_device *vdev = vhci->devices[devid]; + struct bce_vhci_device *vdev = vhci->devices[devid];
+ pr_info("bce_vhci_add_endpoint %x/%x:%x\n", udev->portnum, devid, endp_index); + pr_debug("bce_vhci_add_endpoint %x/%x:%x\n", udev->portnum, devid, endp_index);
+ +
+ if (udev->bus->root_hub == udev) /* The USB hub */ + if (udev->bus->root_hub == udev) /* The USB hub */
+ return 0; + return 0;
-153
View File
@@ -1,153 +0,0 @@
From 7cd7875724bc9e02c1f5cd8283af35be54b10a42 Mon Sep 17 00:00:00 2001
From: Redecorating <redecorating@protonmail.com>
Date: Mon, 29 Aug 2022 22:36:52 +1000
Subject: [PATCH 1/1] change many info logs to debug
reduces spam in the journal, which saves disk space (or if you set a
limit on journal size, it means less of that limited space will be
filled with these debug messages)
---
drivers/staging/apple-bce/audio/audio.c | 2 +-
drivers/staging/apple-bce/audio/pcm.c | 14 +++++++-------
drivers/staging/apple-bce/vhci/vhci.c | 12 ++++++------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/apple-bce/audio/audio.c b/drivers/staging/apple-bce/audio/audio.c
index 14aa3a0..5708dfb 100644
--- a/drivers/staging/apple-bce/audio/audio.c
+++ b/drivers/staging/apple-bce/audio/audio.c
@@ -600,7 +600,7 @@ void aaudio_handle_cmd_timestamp(struct aaudio_device *a, struct aaudio_msg *msg
struct aaudio_subdevice *sdev;
u64 devid, timestamp, update_seed;
aaudio_msg_read_update_timestamp(msg, &devid, &timestamp, &update_seed);
- dev_info(a->dev, "Received timestamp update for dev=%llx ts=%llx seed=%llx\n", devid, timestamp, update_seed);
+ dev_dbg(a->dev, "Received timestamp update for dev=%llx ts=%llx seed=%llx\n", devid, timestamp, update_seed);
sdev = aaudio_find_dev_by_dev_id(a, devid);
aaudio_handle_timestamp(sdev, time_os, timestamp);
diff --git a/drivers/staging/apple-bce/audio/pcm.c b/drivers/staging/apple-bce/audio/pcm.c
index faf80b5..1026e10 100644
--- a/drivers/staging/apple-bce/audio/pcm.c
+++ b/drivers/staging/apple-bce/audio/pcm.c
@@ -109,7 +109,7 @@ static struct aaudio_stream *aaudio_pcm_stream(struct snd_pcm_substream *substre
static int aaudio_pcm_open(struct snd_pcm_substream *substream)
{
- pr_info("aaudio_pcm_open\n");
+ pr_debug("aaudio_pcm_open\n");
substream->runtime->hw = *aaudio_pcm_stream(substream)->alsa_hw_desc;
return 0;
@@ -117,7 +117,7 @@ static int aaudio_pcm_open(struct snd_pcm_substream *substream)
static int aaudio_pcm_close(struct snd_pcm_substream *substream)
{
- pr_info("aaudio_pcm_close\n");
+ pr_debug("aaudio_pcm_close\n");
return 0;
}
@@ -129,7 +129,7 @@ static int aaudio_pcm_prepare(struct snd_pcm_substream *substream)
static int aaudio_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params)
{
struct aaudio_stream *astream = aaudio_pcm_stream(substream);
- pr_info("aaudio_pcm_hw_params\n");
+ pr_debug("aaudio_pcm_hw_params\n");
if (!astream->buffer_cnt || !astream->buffers)
return -EINVAL;
@@ -142,7 +142,7 @@ static int aaudio_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_
static int aaudio_pcm_hw_free(struct snd_pcm_substream *substream)
{
- pr_info("aaudio_pcm_hw_free\n");
+ pr_debug("aaudio_pcm_hw_free\n");
return 0;
}
@@ -163,7 +163,7 @@ static void aaudio_pcm_start(struct snd_pcm_substream *substream)
buf = kmalloc(s, GFP_KERNEL);
memcpy_fromio(buf, substream->runtime->dma_area, s);
time_end = ktime_get();
- pr_info("aaudio: Backed up the buffer in %lluns [%li]\n", ktime_to_ns(time_end - time_start),
+ pr_debug("aaudio: Backed up the buffer in %lluns [%li]\n", ktime_to_ns(time_end - time_start),
substream->runtime->control->appl_ptr);
}
@@ -175,14 +175,14 @@ static void aaudio_pcm_start(struct snd_pcm_substream *substream)
memcpy_toio(substream->runtime->dma_area, buf, s);
time_end = ktime_get();
- pr_info("aaudio: Started the audio device in %lluns\n", ktime_to_ns(time_end - time_start));
+ pr_debug("aaudio: Started the audio device in %lluns\n", ktime_to_ns(time_end - time_start));
}
static int aaudio_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
struct aaudio_subdevice *sdev = snd_pcm_substream_chip(substream);
struct aaudio_stream *stream = aaudio_pcm_stream(substream);
- pr_info("aaudio_pcm_trigger %x\n", cmd);
+ pr_debug("aaudio_pcm_trigger %x\n", cmd);
/* We only supports triggers on the #0 buffer */
if (substream->number != 0)
diff --git a/drivers/staging/apple-bce/vhci/vhci.c b/drivers/staging/apple-bce/vhci/vhci.c
index fa8c791..2e6cec5 100644
--- a/drivers/staging/apple-bce/vhci/vhci.c
+++ b/drivers/staging/apple-bce/vhci/vhci.c
@@ -170,7 +170,7 @@ static int bce_vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u1
if (port_status & 0x40000)
ps->wPortChange |= USB_PORT_STAT_C_CONNECTION;
- pr_info("bce-vhci: Translated status %x to %x:%x\n", port_status, ps->wPortStatus, ps->wPortChange);
+ pr_debug("bce-vhci: Translated status %x to %x:%x\n", port_status, ps->wPortStatus, ps->wPortChange);
return 0;
} else if (typeReq == SetPortFeature) {
if (wValue == USB_PORT_FEAT_POWER) {
@@ -185,7 +185,7 @@ static int bce_vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u1
}
if (wValue == USB_PORT_FEAT_SUSPEND) {
/* TODO: Am I supposed to also suspend the endpoints? */
- pr_info("bce-vhci: Suspending port %i\n", wIndex);
+ pr_debug("bce-vhci: Suspending port %i\n", wIndex);
return bce_vhci_cmd_port_suspend(&vhci->cq, (u8) wIndex);
}
} else if (typeReq == ClearPortFeature) {
@@ -203,7 +203,7 @@ static int bce_vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u1
return 0;
}
if (wValue == USB_PORT_FEAT_SUSPEND) {
- pr_info("bce-vhci: Resuming port %i\n", wIndex);
+ pr_debug("bce-vhci: Resuming port %i\n", wIndex);
return bce_vhci_cmd_port_resume(&vhci->cq, (u8) wIndex);
}
}
@@ -415,14 +415,14 @@ static int bce_vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_
static int bce_vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{
struct bce_vhci_transfer_queue *q = urb->ep->hcpriv;
- pr_info("bce_vhci_urb_dequeue %x\n", urb->ep->desc.bEndpointAddress);
+ pr_debug("bce_vhci_urb_dequeue %x\n", urb->ep->desc.bEndpointAddress);
return bce_vhci_urb_request_cancel(q, urb, status);
}
static void bce_vhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
{
struct bce_vhci_transfer_queue *q = ep->hcpriv;
- pr_info("bce_vhci_endpoint_reset\n");
+ pr_debug("bce_vhci_endpoint_reset\n");
if (q)
bce_vhci_transfer_queue_request_reset(q);
}
@@ -440,7 +440,7 @@ static int bce_vhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, s
struct bce_vhci *vhci = bce_vhci_from_hcd(hcd);
bce_vhci_device_t devid = vhci->port_to_device[udev->portnum];
struct bce_vhci_device *vdev = vhci->devices[devid];
- pr_info("bce_vhci_add_endpoint %x/%x:%x\n", udev->portnum, devid, endp_index);
+ pr_debug("bce_vhci_add_endpoint %x/%x:%x\n", udev->portnum, devid, endp_index);
if (udev->bus->root_hub == udev) /* The USB hub */
return 0;
--
2.37.2
@@ -1,72 +0,0 @@
From cc48defd162c9228a6ce1aedea90868fa825a254 Mon Sep 17 00:00:00 2001
From: Redecorating <redecorating@protonmail.com>
Date: Fri, 8 Jul 2022 18:45:08 +1000
Subject: [PATCH 1/1] vhci: drop_endpoint: check for null vdev
prevents nullptr on module unload.
BUG: unable to handle page fault for address: 0000000000001500
\#PF: supervisor read access in kernel mode
\#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP PTI
CPU: 1 PID: 2171 Comm: rmmod Tainted: G U OE 5.18.7-arch1-1-t2 #1 1fe04e8c20509e7958729d88520f97e5abcf1475
Hardware name: Apple Inc. MacBookPro16,1/Mac-E1008331FDC96864, BIOS 1715.60.5.0.0 (iBridge: 19.16.10647.0.0,0) 11/16/2021
RIP: 0010:bce_vhci_drop_endpoint+0xec/0x143 [apple_bce_vhci]
Code: dc d4 eb 6e 48 c7 c7 71 28 d8 c0 e8 70 a6 dc d4 8a 55 02 8b 74 24 04 49 8d bc 24 d0 00 00 00 81 e2 8f 00 00 00 e8 9c fe ff ff <8b> b3 00 15 00 00 48 c7 c7 7c 28 d8 c0 e8 44 a6 dc d4 44 89 f1 48
RSP: 0018:ffffae65411d3d20 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000008041
RDX: 0000000000000000 RSI: 0000000000000041 RDI: ffff968d708e1908
RBP: ffff968d411e57e0 R08: 00000000000325f0 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: ffff968d708e1800
R13: ffff968d7da16b28 R14: 0000000000000011 R15: 0000000000000011
FS: 00007fd141620740(0000) GS:ffff9690aea40000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000001500 CR3: 0000000204968002 CR4: 00000000003706e0
Call Trace:
<TASK>
usb_hcd_alloc_bandwidth+0x1dd/0x360
usb_disable_device_endpoints+0x70/0xc0
usb_disconnect+0xe3/0x2d0
usb_disconnect+0xc8/0x2d0
usb_remove_hcd+0xd8/0x187
bce_vhci_destroy+0x16/0x40 [apple_bce_vhci ac46d6ed402cfcfbc87e02be0b0382b488ad5ea7]
bce_vhci_module_exit+0x10/0xff [apple_bce_vhci ac46d6ed402cfcfbc87e02be0b0382b488ad5ea7]
__do_sys_delete_module+0x1a3/0x290
do_syscall_64+0x5f/0x90
? exc_page_fault+0x74/0x170
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fd1417378ab
Code: 73 01 c3 48 8b 0d ed a4 0e 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d bd a4 0e 00 f7 d8 64 89 01 48
RSP: 002b:00007ffd3c7ede88 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
RAX: ffffffffffffffda RBX: 00005569166297a0 RCX: 00007fd1417378ab
RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000556916629808
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 00007fd1417c6ac0 R11: 0000000000000206 R12: 00007ffd3c7ee0e0
R13: 00005569166292a0 R14: 00007ffd3c7ee766 R15: 00005569166297a0
</TASK>
Modules linked in: apple_mfi_fastcharge apple_bce_vhci(OE-) apple_bce(OE) uhid nft_redir nft_objref nf_conntrack_netbios_ns nf_conntrack_broadcast rfcomm snd_seq_dummy snd_hrtimer snd_seq snd_seq_dev
iTCO_vendor_support mtd mei_pxp mei_hdcp 8250_dw snd_hwdep btrtl i915 applesmc kvm btbcm gpu_sched snd_pcm drm_buddy i2c_i801 btintel irqbypass spi_intel_pci drm_ttm_helper cfg80211 rapl intel_lpss_
CR2: 0000000000001500
---[ end trace 0000000000000000 ]---
---
drivers/staging/apple-bce/vhci/vhci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/apple-bce/vhci/vhci.c b/drivers/staging/apple-bce/vhci/vhci.c
index 98bb51d..6a9f9fc 100644
--- a/drivers/staging/apple-bce/vhci/vhci.c
+++ b/drivers/staging/apple-bce/vhci/vhci.c
@@ -496,7 +496,8 @@ static int bce_vhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
}
bce_vhci_cmd_endpoint_destroy(&vhci->cq, devid, (u8) (endp->desc.bEndpointAddress & 0x8Fu));
- vhci->devices[devid]->tq_mask &= ~BIT(endp_index);
+ if (vdev)
+ vdev->tq_mask &= ~BIT(endp_index);
bce_vhci_destroy_transfer_queue(vhci, q);
return 0;
}
--
2.37.2