msm8953-mainline / linux

Linux mainline kernel with WIP patches for msm8953 devices
Other
111 stars 59 forks source link

6.5.2/ipa #132

Closed alikates closed 7 months ago

alikates commented 11 months ago

Add IPA driver but with data transactions disabled to prevent crashing the phone. This way we can have calls and SMS with ModemManager.

spasswolf commented 7 months ago

Are there any details known about the crash when using mobile data? I tried to capture a debug message using netconsole over usb ethernet (cdc_ether) but got nothing ...

kotleni commented 7 months ago

Good job, lol!

spasswolf commented 7 months ago

To test the mobile data crash issue I cherry-picked the old ipa patches on top of 6.6.10. There the crash does not occur but when I try to ping something I get errors like these:

[ 2180.419735] ipa 7940000.ipa: unexpected tagged packet from endpoint 4
[ 2181.456583] ipa 7940000.ipa: unexpected tagged packet from endpoint 4
[...]

The code is in branch v6.6.10_ipa_old of https://github.com/spasswolf/msm8953-linux.git

spasswolf commented 7 months ago

The crash when using mobile data with the new ipa_legacy driver occurs when using bam dma with the ap_modem_tx dma channel (the ap_modem_rx and ap_lan_rx channels do not crash).

Edit: This was found with netconsole using the following debugging patch:

diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index a560288f00e1..ff3d2b8fd2f8 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -416,6 +416,8 @@ static inline void __iomem *bam_addr(struct bam_device *bdev, u32 pipe,
        enum bam_reg reg)
 {
    const struct reg_offset_data r = bdev->layout[reg];
+   printk(KERN_INFO "%s: bdev->regs=%px r.base_offset=0x%x r.pipe_mult=0x%x r.evnt_mult=0x%x pipe=0x%x r.ee_mult=0x%x bdev->ee=0x%x",
+           __func__, bdev->regs, r.base_offset, r.pipe_mult, r.evnt_mult, pipe, r.ee_mult, bdev->ee);

    return bdev->regs + r.base_offset +
        r.pipe_mult * pipe +
@@ -1097,6 +1099,7 @@ static void bam_start_dma(struct bam_chan *bchan)
    int ret;
    unsigned int avail;
    struct dmaengine_desc_callback cb;
+   printk(KERN_INFO "%s: %d\n", __func__, __LINE__);

    lockdep_assert_held(&bchan->vc.lock);

@@ -1172,12 +1175,15 @@ static void bam_start_dma(struct bam_chan *bchan)
        bchan->tail %= MAX_DESCRIPTORS;
        list_add_tail(&async_desc->desc_node, &bchan->desc_list);
    }
+   printk(KERN_INFO "%s: %d\n", __func__, __LINE__);

    /* ensure descriptor writes and dma start not reordered */
    wmb();
+   printk(KERN_INFO "%s: %d: bam_addr = %px\n", __func__, __LINE__, bam_addr(bdev, bchan->id, BAM_P_EVNT_REG));
    writel_relaxed(bchan->tail * sizeof(struct bam_desc_hw),
            bam_addr(bdev, bchan->id, BAM_P_EVNT_REG));

+   printk(KERN_INFO "%s: %d\n", __func__, __LINE__);
    pm_runtime_mark_last_busy(bdev->dev);
    pm_runtime_put_autosuspend(bdev->dev);
 }
@@ -1217,6 +1223,7 @@ static void bam_issue_pending(struct dma_chan *chan)
 {
    struct bam_chan *bchan = to_bam_chan(chan);
    unsigned long flags;
+   printk(KERN_INFO "%s 0: chan->name = %s\n", __func__, chan->name);

    spin_lock_irqsave(&bchan->vc.lock, flags);

@@ -1224,6 +1231,7 @@ static void bam_issue_pending(struct dma_chan *chan)
    if (vchan_issue_pending(&bchan->vc) && !IS_BUSY(bchan))
        bam_start_dma(bchan);

+   printk(KERN_INFO "%s 1: chan->name = %s\n", __func__, chan->name);
    spin_unlock_irqrestore(&bchan->vc.lock, flags);
 }
barni2000 commented 7 months ago

Did you reverted this commit https://github.com/msm8953-mainline/linux/pull/132/commits/e7797492485f14684f5575f82800d09508df2034? It was an effort for disable data.

spasswolf commented 7 months ago

Yes, I try to investigate the cause of the problem as it does not occur in the old IPA driver (i.e. the combined v2 and v3 driver).

spasswolf commented 7 months ago

I cannot find the error in the new-legacy driver so I'm trying to recreate it from the old IPA v2+v3 driver by removing the v3+ stuff while checking trying to preserve the mobile data behaviour. Code can be found in https://github.com/spasswolf/msm8953-linux.git branch v6.6.10_new_legacy.

spasswolf commented 7 months ago

Found an error in ipa_legacy, unfortunately it still crashes:

diff --git a/drivers/net/ipa-legacy/ipa_cmd.c b/drivers/net/ipa-legacy/ipa_cmd.c
index f880cc317838..56e98c4074a1 100644
--- a/drivers/net/ipa-legacy/ipa_cmd.c
+++ b/drivers/net/ipa-legacy/ipa_cmd.c
@@ -45,8 +45,8 @@ enum pipeline_clear_options {
 /* IPA_CMD_IP_V{4,6}_{FILTER,ROUTING}_INIT */

 struct ipa_cmd_hw_ip_fltrt_init {
-       __le64 hash_rules_addr;
-       __le64 flags;
+       __le32 hash_rules_addr;
+       __le32 flags;
 };

 /* Field masks for ipa_cmd_hw_ip_fltrt_init structure fields */
@@ -59,7 +59,7 @@ struct ipa_cmd_hw_ip_fltrt_init {
 /* IPA_CMD_HDR_INIT_LOCAL */

 struct ipa_cmd_hw_hdr_init_local {
-       __le64 hdr_table_addr;
+       __le32 hdr_table_addr;
        __le32 flags;
 };
barni2000 commented 7 months ago

@spasswolf Check 6.7.0/main, there is an new driver there and mobile data works with it.

spasswolf commented 7 months ago

Tested 6.7.0/main with debian stable userspace, SMS works and mobile data doesn't crash, but I get the a similar problem as with the old driver, when I ping I don't get return packets.

I get a network interface when enabling mobile data:

$ ip addr show qmapmux0.0
8: qmapmux0.0@rmnet_ipa0: <UP,LOWER_UP> mtu 1496 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/[519] 
    inet 10.209.254.139/29 brd 10.209.254.143 scope global noprefixroute qmapmux0.0
       valid_lft forever preferred_lft forever

and the following routes (output from ip route):

default via 10.209.254.140 dev qmapmux0.0 proto static metric 1050 
10.209.254.136/29 dev qmapmux0.0 proto kernel scope link src 10.209.254.139 metric 1050 

When I ping 10.209.254.140 I get after 10 packets:

$ cat /proc/net/dev | grep -E "rmnet|qmap|Inter|face"
Inter-|   Receive                                                |  Transmit
 face |       bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
rmnet_ipa0:      40      10    0    0    0     0          0         0      880      10    0   12    0     0       0          0
qmapmux0.0:       0       0    0    0    0     0          0         0      880      10    0    0    0     0       0          0

This is a slight improvement over the old driver, as I at least get rx packets in rmnet_ipa0 (with the old driver all receive numbers were 0). Does this work in postmarketOS? Might this be a userspace issue? (I enabled mobile data by clicking the gnome thing ...)

barni2000 commented 7 months ago

Tested 6.7.0/main with debian stable userspace, SMS works and mobile data doesn't crash, but I get the a similar problem as with the old driver, when I ping I don't get return packets.

I get a network interface when enabling mobile data:

$ ip addr show qmapmux0.0
8: qmapmux0.0@rmnet_ipa0: <UP,LOWER_UP> mtu 1496 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/[519] 
    inet 10.209.254.139/29 brd 10.209.254.143 scope global noprefixroute qmapmux0.0
       valid_lft forever preferred_lft forever

and the following routes (output from ip route):

default via 10.209.254.140 dev qmapmux0.0 proto static metric 1050 
10.209.254.136/29 dev qmapmux0.0 proto kernel scope link src 10.209.254.139 metric 1050 

When I ping 10.209.254.140 I get after 10 packets:

$ cat /proc/net/dev | grep -E "rmnet|qmap|Inter|face"
Inter-|   Receive                                                |  Transmit
 face |       bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
rmnet_ipa0:      40      10    0    0    0     0          0         0      880      10    0   12    0     0       0          0
qmapmux0.0:       0       0    0    0    0     0          0         0      880      10    0    0    0     0       0          0

This is a slight improvement over the old driver, as I at least get rx packets in rmnet_ipa0 (with the old driver all receive numbers were 0). Does this work in postmarketOS? Might this be a userspace issue? (I enabled mobile data by clicking the gnome thing ...)

ping works for me on xiaomi-vince

spasswolf commented 7 months ago

With postmarketOS as userspace?

barni2000 commented 7 months ago

With postmarketOS as userspace?

yes

spasswolf commented 7 months ago

Mobile data works now for me with 6.7.0/main and ipa2-lite and debian stable (bookworm) as userspace. Trying to ping was actually a bad idea, that's still not working, but I can ping e.g. 1.1.1.1 and also access wikipedia with firefox-esr.

barni2000 commented 7 months ago

I think this MR should be closed.