Search code examples
linux-kernellinux-device-driveruserland

How can I stop emmc recovery?


I have a prebuilt Linux kernel 4.19. I can't build a fresh one. I can mount an emmc partition read-only with no issue. I have trouble mounting partitions read and write. It reports "running CQE recovery"

I am thinking of killing the recovery function when it starts after I mount partition -o rw. I am suspecting the function is in core.c My idea would be to set the MMC_CQE_RECOVERY_TIMEOUT as a kernel command line parameter. But I don't know which parameter does that if it exists. Or I could run a function that stops the recovery. I could maybe create a binary that calls the function mmc_cqe_request_done(mmc, mrq) from cqhci-core.c but I don't have access to mmc, mrq parameters since im not making a kernel driver or maybe I can create the parameters somehow from a block device itself after booting the kernel and running mknod(). Which of these is possible?

I am not trying to patch any kernel source I want to know if it's possible to stop running QCE recovery by creating a binary I can run or use a kernel parameter that can stop qce recovery.


Solution

  • When I asked the question I had no idea device tree blobs could be modified. My goto solution was the impression I could run code in userspace to stop the recovery. I found a simpler solution. Which has nothing to do with writing code.

    The problem was I needed to stop the command queue and I had no idea how to do it and didn't know where it was being enabled in the first place.

    It turns out the device tree has mediatek,cqhci property which isn't supported well by the kernel. It seems my kernel sources probably had it enabled by patching their kernel sources since it wasn't available for mainline MEDIATEK mmc

    /dts-v1/;
    
    / {
        mmc@11230000 {
            compatible = "mediatek,mt6768-mmc";
            mediatek,cqhci;
        };
    };
    

    So I had to modify the device tree file with fdtput.

    fdtput -d /path/to/fdt /mmc@11230000 "mediatek,cqhci"
    

    Steps

    1. I dumped the device tree blob from the boot.img
    2. I Binwalked through the blob to get the pure flattened device tree
    3. Deleted the command queue enabler property from the blob with fdtput