我进行了更改以使 mmc 驱动程序可加载内核模块,但是当我尝试mmc_host_module
使用rmmod mmc_host_module
.
注意:我已停用CONFIG_MMC_CLKGATE
.
所有插入命令都能正常工作:
insmod mmc_core.ko
insmod mmc_block.ko
insmod sdhci.ko
insmod shdci_pltfm.ko
insmod mmc_host_module.ko
但是当我尝试卸载 mmc_host_module 时,删除模块后直接出现以下错误:
mmc0: Reset 0x1 never completed.
mmc0: Reset 0x1 never completed.
mmc0: Reset 0x1 failed with workaround
之后我从崩溃转储(dmesg)中得到:
114.044574: <6> mmc0: In suspend emmc_reset_gpio: 51, val: 0
114.049031: <6> mmc0: In suspend emmc_reset_gpio get_value: 0
116.708652: <6> mmc0: emmc_reset_gpio: 51, val: 1
116.712232: <6> mmc0: In resume emmc_reset_gpio get_value: 1
117.051544: <6> mmc0: _mmc_resume: awake failed (-110), fallback to full init
119.846145: <6> mmc0: card 0001 removed
124.841021: <6> ------------[ cut here ]------------
124.841081: <6> WARNING: CPU: 0 PID: 1830 at drivers/mmc/host/sdhci-msm.c:2596 sdhci_msm_check_power_status+0xd4/0x124 [mmc_host_module]()
124.841091: <2> mmc0: request(1) timed out waiting for pwr_irq
124.841098: <2> Modules linked in: mmc_host_module(-) sdhci_pltfm sdhci mmc_block mmc_core .......... # I have removed the rest of line
124.841177: <6> CPU: 0 PID: 1830 Comm: rmmod Tainted: G U 3.18.48LE
124.841208: <2> [<c00141d0>] (unwind_backtrace) from [<c0011fd4>] (show_stack+0x10/0x14)
124.841225: <2> [<c0011fd4>] (show_stack) from [<c001f4f8>] (warn_slowpath_common+0x6c/0x84)
124.841240: <2> [<c001f4f8>] (warn_slowpath_common) from [<c001f540>] (warn_slowpath_fmt+0x30/0x40)
124.841266: <2> [<c001f540>] (warn_slowpath_fmt) from [<bf26130c>] (sdhci_msm_check_power_status+0xd4/0x124 [mmc_host_module])
124.841326: <2> [<bf26130c>] (sdhci_msm_check_power_status [mmc_host_module]) from [<bf23a5a8>] (sdhci_reset+0x78/0x220 [sdhci])
124.841351: <2> [<bf23a5a8>] (sdhci_reset [sdhci]) from [<bf239038>] (0xbf239038)
124.841375: <2> [<bf239038>] (0xbf239038) from [<bf23dcc8>] (sdhci_set_ios+0x6c/0xb4 [sdhci])
124.841400: <2> [<bf23dcc8>] (sdhci_set_ios [sdhci]) from [<bf23db2c>] (sdhci_request+0x898/0x9c8 [sdhci])
124.841424: <2> [<bf23db2c>] (sdhci_request [sdhci]) from [<bf23dc84>] (sdhci_set_ios+0x28/0xb4 [sdhci])
124.841528: <2> [<bf23dc84>] (sdhci_set_ios [sdhci]) from [<bf2d2dac>] (mmc_set_ios+0x2c/0x120 [mmc_core])
124.841627: <2> [<bf2d2dac>] (mmc_set_ios [mmc_core]) from [<bf2d490c>] (mmc_check_bkops+0xd4/0xf4 [mmc_core])
124.841717: <2> [<bf2d490c>] (mmc_check_bkops [mmc_core]) from [<bf2d6c14>] (mmc_stop_host+0x13c/0x144 [mmc_core])
124.841807: <2> [<bf2d6c14>] (mmc_stop_host [mmc_core]) from [<bf2d7e28>] (mmc_remove_host+0x28/0x60 [mmc_core])
124.841865: <2> [<bf2d7e28>] (mmc_remove_host [mmc_core]) from [<bf23a1e0>] (sdhci_remove_host+0x68/0x280 [sdhci])
124.841896: <2> [<bf23a1e0>] (sdhci_remove_host [sdhci]) from [<bf261b58>] (sdhci_msm_remove+0x60/0x1f0 [mmc_host_module])
124.841923: <2> [<bf261b58>] (sdhci_msm_remove [mmc_host_module]) from [<c02c4b1c>] (platform_drv_remove+0x18/0x30)
124.841939: <2> [<c02c4b1c>] (platform_drv_remove) from [<c02c2ff8>] (__device_release_driver+0x88/0xf4)
124.841953: <2> [<c02c2ff8>] (__device_release_driver) from [<c02c36c8>] (driver_detach+0x9c/0xa4)
124.841966: <2> [<c02c36c8>] (driver_detach) from [<c02c2b80>] (bus_remove_driver+0x4c/0xa0)
124.841980: <2> [<c02c2b80>] (bus_remove_driver) from [<c0065a90>] (SyS_delete_module+0x134/0x1c8)
124.841996: <2> [<c0065a90>] (SyS_delete_module) from [<c000e4dc>] (__sys_trace_return+0x0/0x24)
124.842005: <6> ---[ end trace f9057010bff1a7d5 ]---
125.652365: <6> mmc0: Reset 0x1 never completed.
125.655605: <6> mmc0: waiting for SW_RST_REQ is successful
130.680118: <6> ------------[ cut here ]------------
130.680172: <6> WARNING: CPU: 0 PID: 1830 at drivers/mmc/host/sdhci-msm.c:2596 sdhci_msm_check_power_status+0xd4/0x124 [mmc_host_module]()
130.680181: <2> mmc0: request(1) timed out waiting for pwr_irq
130.680190: <2> Modules linked in: mmc_host_module(-) sdhci_pltfm sdhci mmc_block mmc_core .......... # I have removed the rest of line
130.680268: <6> CPU: 0 PID: 1830 Comm: rmmod Tainted: G U W 3.18.48LE.UM.1.2-78600-9x07-174-g3e3630e-dirty #118
130.680298: <2> [<c00141d0>] (unwind_backtrace) from [<c0011fd4>] (show_stack+0x10/0x14)
130.680315: <2> [<c0011fd4>] (show_stack) from [<c001f4f8>] (warn_slowpath_common+0x6c/0x84)
130.680330: <2> [<c001f4f8>] (warn_slowpath_common) from [<c001f540>] (warn_slowpath_fmt+0x30/0x40)
130.680356: <2> [<c001f540>] (warn_slowpath_fmt) from [<bf26130c>] (sdhci_msm_check_power_status+0xd4/0x124 [mmc_host_module])
130.680393: <2> [<bf26130c>] (sdhci_msm_check_power_status [mmc_host_module]) from [<bf23a5a8>] (sdhci_reset+0x78/0x220 [sdhci])
130.680417: <2> [<bf23a5a8>] (sdhci_reset [sdhci]) from [<bf239038>] (0xbf239038)
130.680440: <2> [<bf239038>] (0xbf239038) from [<bf23dcc8>] (sdhci_set_ios+0x6c/0xb4 [sdhci])
130.680465: <2> [<bf23dcc8>] (sdhci_set_ios [sdhci]) from [<bf23db2c>] (sdhci_request+0x898/0x9c8 [sdhci])
130.680490: <2> [<bf23db2c>] (sdhci_request [sdhci]) from [<bf23dc84>] (sdhci_set_ios+0x28/0xb4 [sdhci])
130.680596: <2> [<bf23dc84>] (sdhci_set_ios [sdhci]) from [<bf2d2dac>] (mmc_set_ios+0x2c/0x120 [mmc_core])
130.680691: <2> [<bf2d2dac>] (mmc_set_ios [mmc_core]) from [<bf2d490c>] (mmc_check_bkops+0xd4/0xf4 [mmc_core])
130.680781: <2> [<bf2d490c>] (mmc_check_bkops [mmc_core]) from [<bf2d6c14>] (mmc_stop_host+0x13c/0x144 [mmc_core])
130.680871: <2> [<bf2d6c14>] (mmc_stop_host [mmc_core]) from [<bf2d7e28>] (mmc_remove_host+0x28/0x60 [mmc_core])
130.680930: <2> [<bf2d7e28>] (mmc_remove_host [mmc_core]) from [<bf23a1e0>] (sdhci_remove_host+0x68/0x280 [sdhci])
130.680962: <2> [<bf23a1e0>] (sdhci_remove_host [sdhci]) from [<bf261b58>] (sdhci_msm_remove+0x60/0x1f0 [mmc_host_module])
130.680990: <2> [<bf261b58>] (sdhci_msm_remove [mmc_host_module]) from [<c02c4b1c>] (platform_drv_remove+0x18/0x30)
130.681006: <2> [<c02c4b1c>] (platform_drv_remove) from [<c02c2ff8>] (__device_release_driver+0x88/0xf4)
130.681020: <2> [<c02c2ff8>] (__device_release_driver) from [<c02c36c8>] (driver_detach+0x9c/0xa4)
130.681034: <2> [<c02c36c8>] (driver_detach) from [<c02c2b80>] (bus_remove_driver+0x4c/0xa0)
130.681048: <2> [<c02c2b80>] (bus_remove_driver) from [<c0065a90>] (SyS_delete_module+0x134/0x1c8)
130.681064: <2> [<c0065a90>] (SyS_delete_module) from [<c000e4dc>] (__sys_trace_return+0x0/0x24)
130.681073: <6> ---[ end trace f9057010bff1a7d6 ]---
131.491258: <6> mmc0: Reset 0x1 never completed.
131.494497: <6> mmc0: Reset 0x1 failed with workaround
131.499269: <6> sdhci: =========== REGISTER DUMP (mmc0)===========
131.499278: <6> sdhci: Sys addr: 0x00000000 | Version: 0x00002e02
131.499287: <6> sdhci: Blk size: 0x00004000 | Blk cnt: 0x00000000
131.499296: <6> sdhci: Argument: 0x00000000 | Trn mode: 0x00000000
131.499305: <6> sdhci: Present: 0x01f80000 | Host ctl: 0x00000000
131.499314: <6> sdhci: Power: 0x00000000 | Blk gap: 0x00000000
131.499322: <6> sdhci: Wake-up: 0x00000000 | Clock: 0x00000003
131.499331: <6> sdhci: Timeout: 0x00000000 | Int stat: 0x00000000
131.499340: <6> sdhci: Int enab: 0x00000000 | Sig enab: 0x00000000
131.499348: <6> sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000
131.499357: <6> sdhci: Caps: 0x262dc8b2 | Caps_1: 0x00008007
131.499366: <6> sdhci: Cmd: 0x00000000 | Max curr: 0x00000000
131.499375: <6> sdhci: Resp 1: 0x00000000 | Resp 0: 0x00000000
131.499383: <6> sdhci: Resp 3: 0x00000000 | Resp 2: 0x00000000
131.499391: <6> sdhci: Host ctl2: 0x00000000
131.499401: <6> sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x00000000
131.499409: <6> ----------- VENDOR REGISTER DUMP -----------
131.499420: <6> Data cnt: 0x00000000 | Fifo cnt: 0x00000000 | Int sts: 0x000c0000
131.499430: <6> DLL cfg: 0x60006400 | DLL sts: 0x00000000 | SDCC ver: 0x1000002e
131.499440: <6> Vndr func: 0x00018a1c | Vndr adma err : addr0: 0x00000000 addr1: 0x00000000
131.499448: <6> Vndr func2: 0xfa8218a8
131.499513: <6> Test bus[0 to 3]: 0x0000c846 0x000000ce 0x00006010 0x018001ff
131.499523: <6> Test bus[4 to 7]: 0x00063dd0 0x0004c030 0x00000000 0x0003ffff
131.499532: <6> Test bus[8 to 11]: 0x47fc1604 0x40800002 0x2003e089 0x00000cc0
131.499542: <6> Test bus[12 to 15]: 0x004f0408 0x801f0180 0x0d000000 0x00000ab6
131.499551: <6> Test bus[16 to 19]: 0x00000000 0x000f800c 0x00000000 0x00000091
131.499560: <6> Test bus[20 to 23]: 0x0240ff01 0x00050021 0x00000000 0x00000000
131.499569: <6> Test bus[24 to 27]: 0x00000000 0x00000000 0x00000000 0x00000000
131.499578: <6> Test bus[28 to 31]: 0x00000000 0x00000000 0x00000000 0x00000000
131.499586: <6> Test bus[32 to 35]: 0x00000000 0x00000000 0x00000000 0x00000000
131.499595: <6> Test bus[36 to 39]: 0x00000000 0x00000000 0x00000000 0x00000000
131.499604: <6> Test bus[40 to 43]: 0x00000000 0x00000000 0x00000000 0x00000000
131.499613: <6> Test bus[44 to 47]: 0x00000000 0x00000000 0x00000000 0x00000000
131.499622: <6> Test bus[48 to 51]: 0x00000000 0x00000000 0x00000000 0x00000000
131.499631: <6> Test bus[52 to 55]: 0x00000000 0x00000000 0x00000000 0x00000000
131.499640: <6> Test bus[56 to 59]: 0x00000000 0x00000000 0x00000000 0x00000000
131.499650: <6> mmc0: clk: 0 claimer: rmmod pwr: 12 host->irq = 0
131.499658: <6> mmc0: rpmstatus[pltfm](runtime-suspend:usage_count:disable_depth)(2:1:1)
131.499666: <6> sdhci: ===========================================
136.560108: <6> ------------[ cut here ]------------
136.560158: <6> WARNING: CPU: 0 PID: 1830 at drivers/mmc/host/sdhci-msm.c:2596 sdhci_msm_check_power_status+0xd4/0x124 [mmc_host_module]()
136.560167: <2> mmc0: request(1) timed out waiting for pwr_irq
136.560174: <2> Modules linked in: mmc_host_module(-) sdhci_pltfm sdhci mmc_block mmc_core .......... # I have removed the rest of line
136.560285: <6> CPU: 0 PID: 1830 Comm: rmmod Tainted: G U W 3.18.48LE
136.560316: <2> [<c00141d0>] (unwind_backtrace) from [<c0011fd4>] (show_stack+0x10/0x14)
136.560332: <2> [<c0011fd4>] (show_stack) from [<c001f4f8>] (warn_slowpath_common+0x6c/0x84)
136.560346: <2> [<c001f4f8>] (warn_slowpath_common) from [<c001f540>] (warn_slowpath_fmt+0x30/0x40)
136.560373: <2> [<c001f540>] (warn_slowpath_fmt) from [<bf26130c>] (sdhci_msm_check_power_status+0xd4/0x124 [mmc_host_module])
136.560409: <2> [<bf26130c>] (sdhci_msm_check_power_status [mmc_host_module]) from [<bf23af5c>] (sdhci_get_cd+0x210/0x29c [sdhci])
136.560434: <2> [<bf23af5c>] (sdhci_get_cd [sdhci]) from [<bf23db54>] (sdhci_request+0x8c0/0x9c8 [sdhci])
136.560458: <2> [<bf23db54>] (sdhci_request [sdhci]) from [<bf23dc84>] (sdhci_set_ios+0x28/0xb4 [sdhci])
136.560558: <2> [<bf23dc84>] (sdhci_set_ios [sdhci]) from [<bf2d2dac>] (mmc_set_ios+0x2c/0x120 [mmc_core])
136.560653: <2> [<bf2d2dac>] (mmc_set_ios [mmc_core]) from [<bf2d490c>] (mmc_check_bkops+0xd4/0xf4 [mmc_core])
136.560741: <2> [<bf2d490c>] (mmc_check_bkops [mmc_core]) from [<bf2d6c14>] (mmc_stop_host+0x13c/0x144 [mmc_core])
136.560830: <2> [<bf2d6c14>] (mmc_stop_host [mmc_core]) from [<bf2d7e28>] (mmc_remove_host+0x28/0x60 [mmc_core])
136.560888: <2> [<bf2d7e28>] (mmc_remove_host [mmc_core]) from [<bf23a1e0>] (sdhci_remove_host+0x68/0x280 [sdhci])
136.560920: <2> [<bf23a1e0>] (sdhci_remove_host [sdhci]) from [<bf261b58>] (sdhci_msm_remove+0x60/0x1f0 [mmc_host_module])
136.560947: <2> [<bf261b58>] (sdhci_msm_remove [mmc_host_module]) from [<c02c4b1c>] (platform_drv_remove+0x18/0x30)
136.560962: <2> [<c02c4b1c>] (platform_drv_remove) from [<c02c2ff8>] (__device_release_driver+0x88/0xf4)
136.560975: <2> [<c02c2ff8>] (__device_release_driver) from [<c02c36c8>] (driver_detach+0x9c/0xa4)
136.560988: <2> [<c02c36c8>] (driver_detach) from [<c02c2b80>] (bus_remove_driver+0x4c/0xa0)
136.561002: <2> [<c02c2b80>] (bus_remove_driver) from [<c0065a90>] (SyS_delete_module+0x134/0x1c8)
136.561016: <2> [<c0065a90>] (SyS_delete_module) from [<c000e4dc>] (__sys_trace_return+0x0/0x24)
136.561026: <6> ---[ end trace f9057010bff1a7d7 ]---
我认为这个错误static void sdhci_msm_check_power_status(struct sdhci_host *host, u32 req_type)
与void sdhci_reset(struct sdhci_host *host, u8 mask)
功能有关。有什么建议/解决方案来解决这个内核问题吗?
注意:我在这个链接https://android.googlesource.com/kernel/msm/+/android-msm-marlin-3.18-nougat-dr1/drivers/mmc有相同的来源,你可以看到 host/sdhci-msm .c、host/sdhci.c、core/core.c、core/host.c
更新:
在 sdhci-msm.c 中:在 rmmod 中调用的 sdhci_msm_remove() 函数中,readl_relaxed(host->ioaddr + SDHCI_INT_STATUS)
总是返回 0,我认为这是内核崩溃的根本原因
static int sdhci_msm_remove(struct platform_device *pdev)
{
struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_msm_host *msm_host = pltfm_host->priv;
struct sdhci_msm_pltfm_data *pdata = msm_host->pdata;
int dead = (readl_relaxed(host->ioaddr + SDHCI_INT_STATUS) ==
0xffffffff);
//readl_relaxed(host->ioaddr + SDHCI_INT_STATUS) returns always 0 have an explanation why ?
pr_err("%s: %s :: readl_relaxed(host->ioaddr + SDHCI_INT_STATUS) = 0x%x", dev_name(&pdev->dev), __func__, readl_relaxed(host->ioaddr + SDHCI_INT_STATUS));
pr_debug("%s: %s\n", dev_name(&pdev->dev), __func__);
if (!gpio_is_valid(msm_host->pdata->status_gpio))
device_remove_file(&pdev->dev, &msm_host->polling);
device_remove_file(&pdev->dev, &msm_host->msm_bus_vote.max_bus_bw);
pm_runtime_disable(&pdev->dev);
sdhci_remove_host(host, dead);
sdhci_pltfm_free(pdev);
if (gpio_is_valid(msm_host->pdata->status_gpio))
mmc_gpio_free_cd(msm_host->mmc);
sdhci_msm_vreg_init(&pdev->dev, msm_host->pdata, false);
sdhci_msm_setup_pins(pdata, true);
sdhci_msm_setup_pins(pdata, false);
if (msm_host->msm_bus_vote.client_handle) {
sdhci_msm_bus_cancel_work_and_set_vote(host, 0);
sdhci_msm_bus_unregister(msm_host);
}
return 0;
}