• Paulo Zanoni's avatar
    drm/i915: reorganize the unclaimed register detection code · 5978118c
    Paulo Zanoni authored
    The current code only runs when we do an I915_WRITE operation. It
    checks if the unclaimed register flag is set before we do the
    operation, and then it checks it again after we do the operation. This
    double check allows us to find out if the I915_WRITE operation in
    question is the bad one, or if some previous code is the bad one. When
    it finds a problem, our code uses DRM_ERROR to signal it.
    
    The good thing about the current code is that it detects the problem,
    so at least we can know we did something wrong. The problem is that
    even though we find the problem, we don't really have much information
    to actually debug it. So whenever I see one of these DRM_ERROR
    messages on my systems, the first thing I do is apply a patch to
    change the DRM_ERROR to a WARN and also check for unclaimed registers
    on I915_READ operations. This local patch makes things even slower,
    but it usually helps a lot in finding the bad code.
    
    The first point here is that since the current code is only useful to
    detect whether we have a problem or not, but it is not really good to
    find the cause of the problem, I don't think we should be checking
    both before and after every I915_WRITE operation: just doing the check
    once should be enough for us to quickly detect problems. With this
    change, the code that runs by default for every single user will only
    do 1 read operation for every single I915_WRITE, instead of 2. This
    patch does this change.
    
    The second point is that the local patch I have should be upstream,
    but since it makes things slower it should be disabled by default. So
    I added the i915.mmio_debug option to enable it.
    
    So after this patch, this is what will happen:
     - By default, we will try to detect unclaimed registers once after
       every I915_WRITE operation. Previously we tried twice for every
       I915_WRITE.
     - When we find an unclaimed register we will still print a DRM_ERROR
       message, but we will now tell the user to try again with
       i915.mmio_debug=1.
     - When we use i915.mmio_debug=1 we will try to find unclaimed
       registers both before and after every I915_READ and I915_WRITE
       operation, and we will print stack traces in case we find them.
       This should really help locating the exact point of the bad code
       (or at least finding out that i915.ko is not the problem).
    
    This commit also opens space for really-slow register debugging
    operations on other platforms. In theory we can now add lots and lots
    of debug code behind i915.mmio_debug, enable this option on our tests,
    and catch more problems.
    
    v2: - Remove not-so-useful comments (Daniel)
        - Fix the param definition macros (Rodrigo)
    Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@gmail.com>
    Signed-off-by: default avatarPaulo Zanoni <paulo.r.zanoni@intel.com>
    Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
    5978118c
i915_params.c 6.5 KB