Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 497630

Summary: =sys-kernel/gentoo-sources-3.10.25 unable to mount SD card with JMicron reader with Intel VT-d on
Product: Gentoo Linux Reporter: Kamil Roman <kamil.lech.roman>
Component: [OLD] Core systemAssignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers <kernel>
Status: RESOLVED UPSTREAM    
Severity: normal Keywords: UPSTREAM
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
URL: https://bugzilla.kernel.org/show_bug.cgi?id=42679
Whiteboard: watch-linux-bugzilla
Package list:
Runtime testing required: ---
Attachments: Kernel .config file
output of lspci -knnv
output of dmesg

Description Kamil Roman 2014-01-09 16:05:11 UTC
When trying to mount an SD Card in JMicron SD Controller with Intel VT-d on I get following error reported in dmesg

[    3.357428] dmar: DRHD: handling fault status reg 2
[    3.359923] dmar: DMAR:[DMA Write] Request device [24:00.1] fault addr fffff000 
DMAR:[fault reason 02] Present bit in context entry is clear
[    3.365016] mmc0: unrecognised SCR structure version 3
[    3.367599] mmc0: error -22 whilst initialising SD card

I have 
CONFIG_INTEL_IOMMU=y
CONFIG_INTEL_IOMMU_DEFAULT_ON=y

which makes it probably related to:

https://bugzilla.kernel.org/show_bug.cgi?id=42679

I can mount the SD Card normally when the VT-d is turned off in BIOS.

Reproducible: Always

Steps to Reproduce:
1. Compile kernel with IOMMU flags and 
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_PCI=y
(required for JMicron SD Controller)
2. Turn on the Intel VT-d in BIOS
3. Run the system
Actual Results:  
Error is reported in dmesg, and I can't mount the SD card

Expected Results:  
The SD card can be mounted normally
Comment 1 Kamil Roman 2014-01-09 16:08:01 UTC
Created attachment 367490 [details]
Kernel .config file
Comment 2 Kamil Roman 2014-01-09 16:10:00 UTC
Created attachment 367492 [details]
output of lspci -knnv
Comment 3 Kamil Roman 2014-01-09 16:12:57 UTC
Created attachment 367494 [details]
output of dmesg
Comment 4 Tom Wijsman (TomWij) (RETIRED) gentoo-dev 2014-04-02 16:00:38 UTC
Thank you for reporting. Let's see how the upstream bug goes.
Comment 5 Andrew Cooks 2014-04-20 04:01:01 UTC
Kamil,

Are you able to test patches for this issue? The patch that is attached to the upstream bug report doesn't contain the correct entry for your device yet and I'd like to add that.

In this case the device causing the fault could be either 24:00.0 or 24:00.2 and it could be using 24:00.1 only, or it could use both (24:00.1 and 24:00.0) or (24:00.1 and 24:00.2). It might take a few attempts to work it out.
Comment 6 Kamil Roman 2014-05-17 16:57:57 UTC
Can test it, but:
1. Could you provide me with a patch file? I can see a patch attachment upstream but it's from 31st Jan and in Alex Williamson's comment #45 I can see a reference  to patch series sent to LKML in May. So the patches from LKML are probably better. But on the LKML website Alex links to I can't see either a patch file or even a git commit hash I could generate patch files from.
2. Which kernel version should I test the patch with? Latest stable gentoo-sources (3.12.13 as of today)?
Comment 7 Tom Wijsman (TomWij) (RETIRED) gentoo-dev 2014-05-18 14:32:27 UTC
(In reply to Kamil Roman from comment #6)
> Can test it, but:
> 1. Could you provide me with a patch file? I can see a patch attachment
> upstream but it's from 31st Jan and in Alex Williamson's comment #45 I can
> see a reference  to patch series sent to LKML in May. So the patches from
> LKML are probably better. But on the LKML website Alex links to I can't see
> either a patch file or even a git commit hash I could generate patch files
> from.

Click on the link (https://lkml.org/lkml/2014/5/1/290) and then in the first depth you'll find 13 "Alex Williamson" links, you can click on each link and then click on "Get diff 1". Resulting in these links:

01/13: https://lkml.org/lkml/diff/2014/5/1/291/1
02/13: https://lkml.org/lkml/diff/2014/5/1/292/1
03/13: https://lkml.org/lkml/diff/2014/5/1/293/1
04/13: https://lkml.org/lkml/diff/2014/5/1/294/1
05/13: https://lkml.org/lkml/diff/2014/5/1/296/1
06/13: https://lkml.org/lkml/diff/2014/5/1/297/1
07/13: https://lkml.org/lkml/diff/2014/5/1/298/1
08/13: https://lkml.org/lkml/diff/2014/5/1/299/1
09/13: https://lkml.org/lkml/diff/2014/5/1/300/1
10/13: https://lkml.org/lkml/diff/2014/5/1/301/1
11/13: https://lkml.org/lkml/diff/2014/5/1/302/1
12/13: https://lkml.org/lkml/diff/2014/5/1/304/1
13/13: https://lkml.org/lkml/diff/2014/5/1/305/1

You can download each one; eg.

    wget https://lkml.org/lkml/diff/2014/5/1/291/1 -O 1.patch
    wget https://lkml.org/lkml/diff/2014/5/1/292/1 -O 2.patch
    ...

and then apply it like this, eg.

    patch -p1 < 1.patch
    patch -p1 < 2.patch
    ...

Alternatively; if you have Git and want to use that instead, you can

    git clone git://github.com/awilliam/linux-vfio.git

and then do

    git checkout dma-alias

which might be easier to execute than downloading and applying 13 patches.

Worth noting is that as said in the original comment, you'll want to add your controller to patch 4 if it is not already in there; if you need help with that, feel free to let us know.

> 2. Which kernel version should I test the patch with? Latest stable
> gentoo-sources (3.12.13 as of today)?

git-sources-3.15-rc3
Comment 8 Kamil Roman 2014-06-04 21:00:33 UTC
I will use the dma-alias branch. Could you just tell me which file and how should I modify it? I would be grateful if you could be detailed as I am not a C, but only a poor Java developer ;). Thanks for your patience :)