1. 05 2月, 2021 1 次提交
  2. 10 12月, 2020 1 次提交
  3. 18 8月, 2020 1 次提交
    • T
      of: platform: Destroy child devices symmetrically · 70a29209
      Thierry Reding 提交于
      Iterate over child devices in reverse when unpopulating a platform
      device to make this step symmetrical with the population step. This
      fixes an issue in the Tegra DRM driver where upon module unload the
      DPAUX controller tries to unregister an I2C controller but will end
      up waiting indefinitely because one of the SOR devices is keeping a
      reference to it. Since the SOR devices are instantiated after the
      DPAUX devices, they would only be removed (and hence release their
      reference to the I2C controller) after the DPAUX devices have been
      removed.
      
      While destroying the child devices in reverse order helps in this
      situation, it isn't fully safe to do so either. An even better way
      would be for the child devices to be reordered to match the probe
      order, which would work irrespective of the instantiation order.
      
      However, reordering by probe order would be fairly complicated and
      doesn't fix any known issues, so we'll go with the simpler fix for
      now.
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Link: https://lore.kernel.org/r/20200806153650.3883530-1-thierry.reding@gmail.comSigned-off-by: NRob Herring <robh@kernel.org>
      70a29209
  4. 28 5月, 2020 1 次提交
  5. 15 5月, 2020 1 次提交
  6. 13 12月, 2019 1 次提交
  7. 10 12月, 2019 1 次提交
  8. 04 10月, 2019 1 次提交
  9. 28 8月, 2019 7 次提交
  10. 15 8月, 2019 1 次提交
  11. 07 8月, 2019 2 次提交
  12. 01 8月, 2019 4 次提交
    • S
      of/platform: Don't create device links for default busses · b3173c22
      Saravana Kannan 提交于
      Default busses also have devices created for them. But there's no point
      in creating device links for them. It's especially wasteful as it'll
      cause the traversal of the entire device tree and also spend a lot of
      time checking and figuring out that creating those links isn't allowed.
      So check for default busses and skip trying to create device links for
      them.
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190731221721.187713-8-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b3173c22
    • S
      of/platform: Create device links for all child-supplier depencencies · 709fb829
      Saravana Kannan 提交于
      A parent device can have child devices that it adds when it probes. But
      this probing of the parent device can happen way after kernel init is done
      -- for example, when the parent device's driver is loaded as a module.
      
      In such cases, if the child devices depend on a supplier in the system, we
      need to make sure the supplier gets the sync_state() callback only after
      these child devices are added and probed.
      
      To achieve this, when creating device links for a device by looking at its
      DT node, don't just look at DT references at the top node level. Look at DT
      references in all the descendant nodes too and create device links from the
      ancestor device to all these supplier devices.
      
      This way, when the parent device probes and adds child devices, the child
      devices can then create their own device links to the suppliers and further
      delay the supplier's sync_state() callback to after the child devices are
      probed.
      
      Example:
      In this illustration, -> denotes DT references and indentation
      represents child status.
      
      Device node A
      	Device node B -> D
      	Device node C -> B, D
      
      Device node D
      
      Assume all these devices have their drivers loaded as modules.
      
      Without this patch, this is the sequence of events:
      1. D is added.
      2. A is added.
      3. Device D probes.
      4. Device D gets its sync_state() callback.
      5. Device B and C might malfunction because their resources got
         altered/turned off before they can make active requests for them.
      
      With this patch, this is the sequence of events:
      1. D is added.
      2. A is added and creates device links to D.
      3. Device link from A to B is not added because A is a parent of B.
      4. Device D probes.
      5. Device D does not get it's sync_state() callback because consumer A
         hasn't probed yet.
      5. Device A probes.
      5. a. Devices B and C are added.
      5. b. Device links from B and C to D are added.
      5. c. Device A's probe completes.
      6. Device D does not get it's sync_state() callback because consumer A
         has probed but consumers B and C haven't probed yet.
      7. Device B and C probe.
      8. Device D gets it's sync_state() callback because all its consumers
         have probed.
      9. None of the devices malfunction.
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190731221721.187713-7-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      709fb829
    • S
      of/platform: Pause/resume sync state during init and of_platform_populate() · 21871a99
      Saravana Kannan 提交于
      When all the top level devices are populated from DT during kernel
      init, the supplier devices could be added and probed before the
      consumer devices are added and linked to the suppliers. To avoid the
      sync_state() callback from being called prematurely, pause the
      sync_state() callbacks before populating the devices and resume them
      at late_initcall_sync().
      
      Similarly, when children devices are populated after kernel init using
      of_platform_populate(), there could be supplier-consumer dependencies
      between the children devices that are populated. To avoid the same
      problem with sync_state() being called prematurely, pause and resume
      sync_state() callbacks across of_platform_populate().
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190731221721.187713-6-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21871a99
    • S
      of/platform: Add functional dependency link from DT bindings · 690ff788
      Saravana Kannan 提交于
      Add device-links after the devices are created (but before they are
      probed) by looking at common DT bindings like clocks and
      interconnects.
      
      Automatically adding device-links for functional dependencies at the
      framework level provides the following benefits:
      
      - Optimizes device probe order and avoids the useless work of
        attempting probes of devices that will not probe successfully
        (because their suppliers aren't present or haven't probed yet).
      
        For example, in a commonly available mobile SoC, registering just
        one consumer device's driver at an initcall level earlier than the
        supplier device's driver causes 11 failed probe attempts before the
        consumer device probes successfully. This was with a kernel with all
        the drivers statically compiled in. This problem gets a lot worse if
        all the drivers are loaded as modules without direct symbol
        dependencies.
      
      - Supplier devices like clock providers, interconnect providers, etc
        need to keep the resources they provide active and at a particular
        state(s) during boot up even if their current set of consumers don't
        request the resource to be active. This is because the rest of the
        consumers might not have probed yet and turning off the resource
        before all the consumers have probed could lead to a hang or
        undesired user experience.
      
        Some frameworks (Eg: regulator) handle this today by turning off
        "unused" resources at late_initcall_sync and hoping all the devices
        have probed by then. This is not a valid assumption for systems with
        loadable modules. Other frameworks (Eg: clock) just don't handle
        this due to the lack of a clear signal for when they can turn off
        resources. This leads to downstream hacks to handle cases like this
        that can easily be solved in the upstream kernel.
      
        By linking devices before they are probed, we give suppliers a clear
        count of the number of dependent consumers. Once all of the
        consumers are active, the suppliers can turn off the unused
        resources without making assumptions about the number of consumers.
      
      By default we just add device-links to track "driver presence" (probe
      succeeded) of the supplier device. If any other functionality provided
      by device-links are needed, it is left to the consumer/supplier
      devices to change the link when they probe.
      
      kbuild test robot reported clang error about missing const
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/20190731221721.187713-4-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      690ff788
  13. 30 7月, 2019 1 次提交
    • S
      drivers: Introduce device lookup variants by of_node · cfba5de9
      Suzuki K Poulose 提交于
      Introduce wrappers for {bus/driver/class}_find_device() to
      locate devices by its of_node.
      
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maxime Ripard <maxime.ripard@bootlin.com>
      Cc: dri-devel@lists.freedesktop.org
      Cc: David Airlie <airlied@linux.ie>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: devicetree@vger.kernel.org
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: Heiko Stuebner <heiko@sntech.de>
      Cc: Liam Girdwood <lgirdwood@gmail.com>
      Cc: linux-i2c@vger.kernel.org
      Cc: linux-rockchip@lists.infradead.org
      Cc: linux-spi@vger.kernel.org
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Cc: Takashi Iwai <tiwai@suse.com>
      Cc: Alan Tull <atull@kernel.org>
      Cc: linux-fpga@vger.kernel.org
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Heiner Kallweit <hkallweit1@gmail.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: Liam Girdwood <lgirdwood@gmail.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Thor Thayer <thor.thayer@linux.intel.com>
      Cc: Jiri Slaby <jslaby@suse.com>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: Peter Rosin <peda@axentia.se>
      Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Acked-by: NLee Jones <lee.jones@linaro.org>
      Acked-by: Wolfram Sang <wsa@the-dreams.de> # I2C part
      Acked-by: Moritz Fischer <mdf@kernel.org> # For FPGA part
      Acked-by: NMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20190723221838.12024-3-suzuki.poulose@arm.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cfba5de9
  14. 09 7月, 2019 1 次提交
  15. 24 6月, 2019 1 次提交
    • S
      bus_find_device: Unify the match callback with class_find_device · 418e3ea1
      Suzuki K Poulose 提交于
      There is an arbitrary difference between the prototypes of
      bus_find_device() and class_find_device() preventing their callers
      from passing the same pair of data and match() arguments to both of
      them, which is the const qualifier used in the prototype of
      class_find_device().  If that qualifier is also used in the
      bus_find_device() prototype, it will be possible to pass the same
      match() callback function to both bus_find_device() and
      class_find_device(), which will allow some optimizations to be made in
      order to avoid code duplication going forward.  Also with that, constify
      the "data" parameter as it is passed as a const to the match function.
      
      For this reason, change the prototype of bus_find_device() to match
      the prototype of class_find_device() and adjust its callers to use the
      const qualifier in accordance with the new prototype of it.
      
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: Andreas Noever <andreas.noever@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Corey Minyard <minyard@acm.org>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: David Kershner <david.kershner@unisys.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: Grygorii Strashko <grygorii.strashko@ti.com>
      Cc: Harald Freudenberger <freude@linux.ibm.com>
      Cc: Hartmut Knaack <knaack.h@gmx.de>
      Cc: Heiko Stuebner <heiko@sntech.de>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Jonathan Cameron <jic23@kernel.org>
      Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michael Jamet <michael.jamet@intel.com>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
      Cc: Sebastian Ott <sebott@linux.ibm.com>
      Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
      Cc: rafael@kernel.org
      Acked-by: NCorey Minyard <minyard@acm.org>
      Acked-by: NDavid Kershner <david.kershner@unisys.com>
      Acked-by: NMark Brown <broonie@kernel.org>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Acked-by: Wolfram Sang <wsa@the-dreams.de> # for the I2C parts
      Acked-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      418e3ea1
  16. 08 9月, 2018 1 次提交
  17. 02 9月, 2018 1 次提交
    • L
      of/platform: initialise AMBA default DMA masks · 8c89ef7b
      Linus Walleij 提交于
      This addresses a v4.19-rc1 regression in the PL111 DRM driver in
      drivers/gpu/pl111/*
      
      The driver uses the CMA KMS helpers and will thus at some point call
      down to dma_alloc_attrs() to allocate a chunk of contigous DMA memory
      for the framebuffer.
      
      It appears that in v4.18, it was OK that this (and other DMA mastering
      AMBA devices) left dev->coherent_dma_mask blank (zero).
      
      In v4.19-rc1 the WARN_ON_ONCE(dev && !dev->coherent_dma_mask) in
      dma_alloc_attrs() in include/linux/dma-mapping.h is triggered.  The
      allocation later fails when get_coherent_dma_mask() is called from
      __dma_alloc() and __dma_alloc() returns NULL:
      
      drm-clcd-pl111 dev:20: coherent DMA mask is unset
      drm-clcd-pl111 dev:20: [drm:drm_fb_helper_fbdev_setup] *ERROR*
       	       	        Failed to set fbdev configuration
      
      It turns out that in commit 4d8bde88 ("OF: Don't set default
      coherent DMA mask") the OF core stops setting the default DMA mask on
      new devices, especially those lines of the patch:
      
      - if (!dev->coherent_dma_mask)
      -               dev->coherent_dma_mask = DMA_BIT_MASK(32);
      
      Robin Murphy solved a similar problem in a5516219 ("of/platform:
      Initialise default DMA masks") by simply assigning dev.coherent_dma_mask
      and the dev.dma_mask to point to the same when creating devices from the
      device tree, and introducing the same code into the code path creating
      AMBA/PrimeCell devices solved my problem, graphics now come up.
      
      The code simply assumes that the device can access all of the system
      memory by setting the coherent DMA mask to 0xffffffff when creating a
      device from the device tree, which is crude, but seems to be what kernel
      v4.18 assumed.
      
      The AMBA PrimeCells do not differ between coherent and streaming DMA so
      we can just assign the same to any DMA mask.
      
      Possibly drivers should augment their coherent DMA mask in accordance
      with "dma-ranges" from the device tree if more finegranular masking is
      needed.
      Reported-by: NRussell King <linux@armlinux.org.uk>
      Fixes: 4d8bde88 ("OF: Don't set default coherent DMA mask")
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      8c89ef7b
  18. 28 7月, 2018 1 次提交
    • R
      of/platform: Initialise default DMA masks · a5516219
      Robin Murphy 提交于
      When of_dma_configure() was first born in 591c1ee4 ("of: configure
      the platform device dma parameters"), everything DMA-related was
      factored out of of_platform_device_create_pdata() as seemed appropriate
      at the time. However, now that of_dma_configure() has grown into the
      generic handler for processing DMA-related properties from DT for all
      kinds of devices, it is no longer an appropriate place to be doing
      OF-platform-specific business. Since there are still plenty of platform
      drivers not setting their own masks and depending on the bus default,
      let's reinstate that inialisation in the OF-platform code itself, and
      restore the long-standing status quo from 0589342c ("of: set
      dma_mask to point to coherent_dma_mask")
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Acked-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      a5516219
  19. 13 6月, 2018 1 次提交
    • K
      treewide: kzalloc() -> kcalloc() · 6396bb22
      Kees Cook 提交于
      The kzalloc() function has a 2-factor argument form, kcalloc(). This
      patch replaces cases of:
      
              kzalloc(a * b, gfp)
      
      with:
              kcalloc(a * b, gfp)
      
      as well as handling cases of:
      
              kzalloc(a * b * c, gfp)
      
      with:
      
              kzalloc(array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              kzalloc_array(array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              kzalloc(4 * 1024, gfp)
      
      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;
      @@
      
      (
        kzalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        kzalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        kzalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	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;
      @@
      
      (
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
      - kzalloc
      + kcalloc
        (
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	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;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	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;
      @@
      
      (
        kzalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	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;
      @@
      
      (
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(sizeof(THING) * C2, ...)
      |
        kzalloc(sizeof(TYPE) * C2, ...)
      |
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(C1 * C2, ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      6396bb22
  20. 04 6月, 2018 1 次提交
    • S
      of: platform: stop accessing invalid dev in of_platform_device_destroy · 522811e9
      Srinivas Kandagatla 提交于
      Immediately after the platform_device_unregister() the device will be
      cleaned up. Accessing the freed pointer immediately after that will
      crash the system.
      
      Found this bug when kernel is built with CONFIG_PAGE_POISONING and testing
      loading/unloading audio drivers in a loop on Qcom platforms.
      
      Fix this by moving of_node_clear_flag() just before the unregister calls.
      
      Below is the crash trace:
      
      Unable to handle kernel paging request at virtual address 6b6b6b6b6b6c03
      Mem abort info:
        ESR = 0x96000021
        Exception class = DABT (current EL), IL = 32 bits
        SET = 0, FnV = 0
        EA = 0, S1PTW = 0
      Data abort info:
        ISV = 0, ISS = 0x00000021
        CM = 0, WnR = 0
      [006b6b6b6b6b6c03] address between user and kernel address ranges
      Internal error: Oops: 96000021 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 2 PID: 1784 Comm: sh Tainted: G        W         4.17.0-rc7-02230-ge3a63a7ef641-dirty #204
      Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
      pstate: 80000005 (Nzcv daif -PAN -UAO)
      pc : clear_bit+0x18/0x2c
      lr : of_platform_device_destroy+0x64/0xb8
      sp : ffff00000c9c3930
      x29: ffff00000c9c3930 x28: ffff80003d39b200
      x27: ffff000008bb1000 x26: 0000000000000040
      x25: 0000000000000124 x24: ffff80003a9a3080
      x23: 0000000000000060 x22: ffff00000939f518
      x21: ffff80003aa79e98 x20: ffff80003aa3dae0
      x19: ffff80003aa3c890 x18: ffff800009feb794
      x17: 0000000000000000 x16: 0000000000000000
      x15: ffff800009feb790 x14: 0000000000000000
      x13: ffff80003a058778 x12: ffff80003a058728
      x11: ffff80003a058750 x10: 0000000000000000
      x9 : 0000000000000006 x8 : ffff80003a825988
      x7 : bbbbbbbbbbbbbbbb x6 : 0000000000000001
      x5 : 0000000000000000 x4 : 0000000000000001
      x3 : 0000000000000008 x2 : 0000000000000001
      x1 : 6b6b6b6b6b6b6c03 x0 : 0000000000000000
      Process sh (pid: 1784, stack limit = 0x        (ptrval))
      Call trace:
       clear_bit+0x18/0x2c
       q6afe_remove+0x20/0x38
       apr_device_remove+0x30/0x70
       device_release_driver_internal+0x170/0x208
       device_release_driver+0x14/0x20
       bus_remove_device+0xcc/0x150
       device_del+0x10c/0x310
       device_unregister+0x1c/0x70
       apr_remove_device+0xc/0x18
       device_for_each_child+0x50/0x80
       apr_remove+0x18/0x20
       rpmsg_dev_remove+0x38/0x68
       device_release_driver_internal+0x170/0x208
       device_release_driver+0x14/0x20
       bus_remove_device+0xcc/0x150
       device_del+0x10c/0x310
       device_unregister+0x1c/0x70
       qcom_smd_remove_device+0xc/0x18
       device_for_each_child+0x50/0x80
       qcom_smd_unregister_edge+0x3c/0x70
       smd_subdev_remove+0x18/0x28
       rproc_stop+0x48/0xd8
       rproc_shutdown+0x60/0xe8
       state_store+0xbc/0xf8
       dev_attr_store+0x18/0x28
       sysfs_kf_write+0x3c/0x50
       kernfs_fop_write+0x118/0x1e0
       __vfs_write+0x18/0x110
       vfs_write+0xa4/0x1a8
       ksys_write+0x48/0xb0
       sys_write+0xc/0x18
       el0_svc_naked+0x30/0x34
      Code: d2800022 8b400c21 f9800031 9ac32043 (c85f7c22)
      ---[ end trace 32020935775616a2 ]---
      Signed-off-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NRob Herring <robh@kernel.org>
      522811e9
  21. 26 5月, 2018 1 次提交
  22. 24 4月, 2018 1 次提交
  23. 23 1月, 2018 1 次提交
  24. 08 1月, 2018 1 次提交
  25. 05 1月, 2018 1 次提交
  26. 22 10月, 2017 2 次提交
  27. 25 8月, 2017 1 次提交
  28. 19 7月, 2017 1 次提交
  29. 23 6月, 2017 1 次提交