08 Aug, 2018

1 commit

  • All iommu drivers use the default_iommu_map_sg implementation, and there
    is no good reason to ever override it. Just expose it as iommu_map_sg
    directly and remove the indirection, specially in our post-spectre world
    where indirect calls are horribly expensive.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Joerg Roedel

    Christoph Hellwig
     

13 Jun, 2018

1 commit

  • The vmalloc() function has no 2-factor argument form, so multiplication
    factors need to be wrapped in array_size(). This patch replaces cases of:

    vmalloc(a * b)

    with:
    vmalloc(array_size(a, b))

    as well as handling cases of:

    vmalloc(a * b * c)

    with:

    vmalloc(array3_size(a, b, c))

    This does, however, attempt to ignore constant size factors like:

    vmalloc(4 * 1024)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    vmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    vmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    vmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_ID
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_ID
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    vmalloc(
    - SIZE * COUNT
    + array_size(COUNT, SIZE)
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    vmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    vmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    vmalloc(C1 * C2 * C3, ...)
    |
    vmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants.
    @@
    expression E1, E2;
    constant C1, C2;
    @@

    (
    vmalloc(C1 * C2, ...)
    |
    vmalloc(
    - E1 * E2
    + array_size(E1, E2)
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

03 May, 2018

2 commits

  • It must return the number of unmapped bytes on success, returning 0 means
    that unmapping failed and in result only one page is unmapped.

    Signed-off-by: Dmitry Osipenko
    Reviewed-by: Thierry Reding
    Acked-by: Thierry Reding
    Signed-off-by: Joerg Roedel

    Dmitry Osipenko
     
  • Page mapping could overwritten by an accident (a bug). We can catch this
    case by checking 'VALID' bit of GART's page entry prior to mapping of a
    page. Since that check introduces a small performance impact, it should be
    enabled explicitly using new GART's kernel module 'debug' parameter.

    Signed-off-by: Dmitry Osipenko
    Acked-by: Thierry Reding
    Signed-off-by: Joerg Roedel

    Dmitry Osipenko
     

17 Aug, 2017

1 commit


10 Aug, 2017

1 commit

  • As the last step to making groups mandatory, clean up the remaining
    drivers by adding basic support. Whilst it may not perfectly reflect the
    isolation capabilities of the hardware, using generic_device_group()
    should at least maintain existing behaviour with respect to the API.

    Signed-off-by: Robin Murphy
    Tested-by: Dmitry Osipenko
    Signed-off-by: Joerg Roedel

    Robin Murphy
     

02 Apr, 2015

1 commit


31 Mar, 2015

2 commits


26 Jan, 2015

2 commits

  • Commit 315786ebbf4a ("iommu: Add iommu_map_sg() function") adds a new
    ->map_sg() callback and provides a default implementation that drivers
    can use until they implement a hardware-specific variant. Unfortunately
    the Tegra GART driver was not updated as part of that commit, so that
    iommu_map_sg() calls on a domain provided by the GART cause an oops.

    Fixes: 315786ebbf4a ("iommu: Add iommu_map_sg() function")
    Cc: Hiroshi Doyu
    Signed-off-by: Thierry Reding
    Signed-off-by: Joerg Roedel

    Thierry Reding
     
  • The driver currently doesn't work as expected and causes existing setups
    with Tegra20 to break after commit df06b759f2cf ("drm/tegra: Add IOMMU
    support"). To restore these setups, do not register the operations with
    the platform bus for now. Fixing this properly will involve non-trivial
    changes to the DRM driver, which are unlikely to be accepted at this
    point in the release cycle.

    Reported-by: Misha Komarovskiy
    Reported-by: Nicolas Chauvet
    Tested-by: Misha Komarovskiy
    Tested-by: Dmitry Osipenko
    Cc: Hiroshi Doyu
    Signed-off-by: Thierry Reding
    Signed-off-by: Joerg Roedel

    Thierry Reding
     

20 Oct, 2014

1 commit


25 Sep, 2014

2 commits


07 Jul, 2014

1 commit


01 Nov, 2013

1 commit


24 Sep, 2013

2 commits

  • The devm_[kzalloc|ioremap] functions allocates data that are released
    when a driver detaches. Thus, there is no reason to explicitly call
    devm_[kfree|iounmap] in probe or remove functions.

    Signed-off-by: Wei Yongjun
    Acked-by: Hiroshi Doyu
    Signed-off-by: Joerg Roedel

    Wei Yongjun
     
  • When enabling LPAE on ARM, phys_addr_t becomes 64 bits wide and printing
    a variable of that type using a simple %x format specifier causes the
    compiler to complain. Change the format specifier to %pa, which is used
    specifically for variables of type phys_addr_t.

    Signed-off-by: Thierry Reding
    Acked-by: Olof Johansson
    Signed-off-by: Joerg Roedel

    Thierry Reding
     

02 May, 2013

2 commits


03 Apr, 2013

1 commit


19 Feb, 2013

1 commit


04 Jan, 2013

1 commit

  • CONFIG_HOTPLUG is going away as an option. As a result, the __dev*
    markings need to be removed.

    This change removes the use of __devinit, __devexit_p, __devinitdata,
    and __devexit from these drivers.

    Based on patches originally written by Bill Pemberton, but redone by me
    in order to handle some of the coding style issues better, by hand.

    Cc: Bill Pemberton
    Cc: David Woodhouse
    Cc: Joerg Roedel
    Cc: Ohad Ben-Cohen
    Cc: Tony Lindgren
    Cc: Omar Ramirez Luna
    Cc: Mauro Carvalho Chehab
    Cc: Hiroshi Doyu
    Cc: Stephen Warren
    Cc: Bharat Nihalani
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

28 Nov, 2012

1 commit


11 Jul, 2012

1 commit


11 May, 2012

1 commit


16 Apr, 2012

2 commits


13 Mar, 2012

1 commit


26 Jan, 2012

1 commit

  • Tegra 20 IOMMU H/W, GART (Graphics Address Relocation Table). This
    patch implements struct iommu_ops for GART for the upper IOMMU API.

    This H/W module supports only single virtual address space(domain),
    and manages a single level 1-to-1 mapping H/W translation page table.

    [With small fixes by Joerg Roedel]

    Signed-off-by: Hiroshi DOYU
    Signed-off-by: Joerg Roedel

    Hiroshi DOYU