1. 25 Jun, 2020 40 commits
    • Pawel Laszczak's avatar
      usb: gadget: Fix issue with config_ep_by_speed function · 48326995
      Pawel Laszczak authored
      [ Upstream commit 5d363120 ]
      
      This patch adds new config_ep_by_speed_and_alt function which
      extends the config_ep_by_speed about alt parameter.
      This additional parameter allows to find proper usb_ss_ep_comp_descriptor.
      
      Problem has appeared during testing f_tcm (BOT/UAS) driver function.
      
      f_tcm function for SS use array of headers for both  BOT/UAS alternate
      setting:
      
      static struct usb_descriptor_header *uasp_ss_function_desc[] = {
              (struct usb_descriptor_header *) &bot_intf_desc,
              (struct usb_descriptor_header *) &uasp_ss_bi_desc,
              (struct usb_descriptor_header *) &bot_bi_ep_comp_desc,
              (struct usb_descriptor_header *) &uasp_ss_bo_desc,
              (struct usb_descriptor_header *) &bot_bo_ep_comp_desc,
      
              (struct usb_descriptor_header *) &uasp_intf_desc,
              (struct usb_descriptor_header *) &uasp_ss_bi_desc,
              (struct usb_descriptor_header *) &uasp_bi_ep_comp_desc,
              (struct usb_descriptor_header *) &uasp_bi_pipe_desc,
              (struct usb_descriptor_header *) &uasp_ss_bo_desc,
              (struct usb_descriptor_header *) &uasp_bo_ep_comp_desc,
              (struct usb_descriptor_header *) &uasp_bo_pipe_desc,
              (struct usb_descriptor_header *) &uasp_ss_status_desc,
              (struct usb_descriptor_header *) &uasp_status_in_ep_comp_desc,
              (struct usb_descriptor_header *) &uasp_status_pipe_desc,
              (struct usb_descriptor_header *) &uasp_ss_cmd_desc,
              (struct usb_descriptor_header *) &uasp_cmd_comp_desc,
              (struct usb_descriptor_header *) &uasp_cmd_pipe_desc,
              NULL,
      };
      
      The first 5 descriptors are associated with BOT alternate setting,
      and others are associated with UAS.
      
      During handling UAS alternate setting f_tcm driver invokes
      config_ep_by_speed and this function sets incorrect companion endpoint
      descriptor in usb_ep object.
      
      Instead setting ep->comp_desc to uasp_bi_ep_comp_desc function in this
      case set ep->comp_desc to uasp_ss_bi_desc.
      
      This is due to the fact that it searches endpoint based on endpoint
      address:
      
              for_each_ep_desc(speed_desc, d_spd) {
                      chosen_desc = (struct usb_endpoint_descriptor *)*d_spd;
                      if (chosen_desc->bEndpoitAddress == _ep->address)
                              goto ep_found;
              }
      
      And in result it uses the descriptor from BOT alternate setting
      instead UAS.
      
      Finally, it causes that controller driver during enabling endpoints
      detect that just enabled endpoint for bot.
      Signed-off-by: default avatarJayshri Pawar <jpawar@cadence.com>
      Signed-off-by: default avatarPawel Laszczak <pawell@cadence.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      48326995
    • Qiushi Wu's avatar
      usb: gadget: fix potential double-free in m66592_probe. · 1a17c51d
      Qiushi Wu authored
      [ Upstream commit 44734a59 ]
      
      m66592_free_request() is called under label "err_add_udc"
      and "clean_up", and m66592->ep0_req is not set to NULL after
      first free, leading to a double-free. Fix this issue by
      setting m66592->ep0_req to NULL after the first free.
      
      Fixes: 0f91349b ("usb: gadget: convert all users to the new udc infrastructure")
      Signed-off-by: default avatarQiushi Wu <wu000273@umn.edu>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1a17c51d
    • Colin Ian King's avatar
      usb: gadget: lpc32xx_udc: don't dereference ep pointer before null check · 8124abb2
      Colin Ian King authored
      [ Upstream commit eafa8004 ]
      
      Currently pointer ep is being dereferenced before it is null checked
      leading to a null pointer dereference issue.  Fix this by only assigning
      pointer udc once ep is known to be not null.  Also remove a debug
      message that requires a valid udc which may not be possible at that
      point.
      
      Addresses-Coverity: ("Dereference before null check")
      Fixes: 24a28e42 ("USB: gadget driver for LPC32xx")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8124abb2
    • Nathan Chancellor's avatar
      USB: gadget: udc: s3c2410_udc: Remove pointless NULL check in s3c2410_udc_nuke · 3ff50396
      Nathan Chancellor authored
      [ Upstream commit 7a0fbcf7 ]
      
      Clang warns:
      
      drivers/usb/gadget/udc/s3c2410_udc.c:255:11: warning: comparison of
      address of 'ep->queue' equal to a null pointer is always false
      [-Wtautological-pointer-compare]
              if (&ep->queue == NULL)
                   ~~~~^~~~~    ~~~~
      1 warning generated.
      
      It is not wrong, queue is not a pointer so if ep is not NULL, the
      address of queue cannot be NULL. No other driver does a check like this
      and this check has been around since the driver was first introduced,
      presumably with no issues so it does not seem like this check should be
      something else. Just remove it.
      
      Commit afe956c5 ("kbuild: Enable -Wtautological-compare") exposed
      this but it is not the root cause of the warning.
      
      Fixes: 3fc154b6 ("USB Gadget driver for Samsung s3c2410 ARM SoC")
      Link: https://github.com/ClangBuiltLinux/linux/issues/1004Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3ff50396
    • Fabrice Gasnier's avatar
      usb: dwc2: gadget: move gadget resume after the core is in L0 state · b601b5dc
      Fabrice Gasnier authored
      [ Upstream commit 8c935dea ]
      
      When the remote wakeup interrupt is triggered, lx_state is resumed from L2
      to L0 state. But when the gadget resume is called, lx_state is still L2.
      This prevents the resume callback to queue any request. Any attempt
      to queue a request from resume callback will result in:
      - "submit request only in active state" debug message to be issued
      - dwc2_hsotg_ep_queue() returns -EAGAIN
      
      Call the gadget resume routine after the core is in L0 state.
      
      Fixes: f81f46e1 ("usb: dwc2: implement hibernation during bus suspend/resume")
      Acked-by: default avatarMinas Harutyunyan <hminas@synopsys.com>
      Signed-off-by: default avatarFabrice Gasnier <fabrice.gasnier@st.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b601b5dc
    • Stefan Riedmueller's avatar
      watchdog: da9062: No need to ping manually before setting timeout · 6fe93f52
      Stefan Riedmueller authored
      [ Upstream commit a0948ddb ]
      
      There is actually no need to ping the watchdog before disabling it
      during timeout change. Disabling the watchdog already takes care of
      resetting the counter.
      
      This fixes an issue during boot when the userspace watchdog handler takes
      over and the watchdog is already running. Opening the watchdog in this case
      leads to the first ping and directly after that without the required
      heartbeat delay a second ping issued by the set_timeout call. Due to the
      missing delay this resulted in a reset.
      Signed-off-by: default avatarStefan Riedmueller <s.riedmueller@phytec.de>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Reviewed-by: default avatarAdam Thomson <Adam.Thomson.Opensource@diasemi.com>
      Link: https://lore.kernel.org/r/20200403130728.39260-3-s.riedmueller@phytec.deSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6fe93f52
    • Maor Gottlieb's avatar
      IB/cma: Fix ports memory leak in cma_configfs · 4053198b
      Maor Gottlieb authored
      [ Upstream commit 63a3345c ]
      
      The allocated ports structure in never freed. The free function should be
      called by release_cma_ports_group, but the group is never released since
      we don't remove its default group.
      
      Remove default groups when device group is deleted.
      
      Fixes: 045959db ("IB/cma: Add configfs for rdma_cm")
      Link: https://lore.kernel.org/r/20200521072650.567908-1-leon@kernel.orgSigned-off-by: default avatarMaor Gottlieb <maorg@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4053198b
    • Marc Zyngier's avatar
      PCI: dwc: Fix inner MSI IRQ domain registration · ff613691
      Marc Zyngier authored
      [ Upstream commit 0414b93e ]
      
      On a system that uses the internal DWC MSI widget, I get this
      warning from debugfs when CONFIG_GENERIC_IRQ_DEBUGFS is selected:
      
        debugfs: File ':soc:pcie@fc000000' in directory 'domains' already present!
      
      This is due to the fact that the DWC MSI code tries to register two
      IRQ domains for the same firmware node, without telling the low
      level code how to distinguish them (by setting a bus token). This
      further confuses debugfs which tries to create corresponding
      files for each domain.
      
      Fix it by tagging the inner domain as DOMAIN_BUS_NEXUS, which is
      the closest thing we have as to "generic MSI".
      
      Link: https://lore.kernel.org/r/20200501113921.366597-1-maz@kernel.orgSigned-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: default avatarJingoo Han <jingoohan1@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ff613691
    • Bjorn Helgaas's avatar
      PCI/PTM: Inherit Switch Downstream Port PTM settings from Upstream Port · 78cf33ae
      Bjorn Helgaas authored
      [ Upstream commit 7b38fd97 ]
      
      Except for Endpoints, we enable PTM at enumeration-time.  Previously we did
      not account for the fact that Switch Downstream Ports are not permitted to
      have a PTM capability; their PTM behavior is controlled by the Upstream
      Port (PCIe r5.0, sec 7.9.16).  Since Downstream Ports don't have a PTM
      capability, we did not mark them as "ptm_enabled", which meant that
      pci_enable_ptm() on an Endpoint failed because there was no PTM path to it.
      
      Mark Downstream Ports as "ptm_enabled" if their Upstream Port has PTM
      enabled.
      
      Fixes: eec097d4 ("PCI: Add pci_enable_ptm() for drivers to enable PTM on endpoints")
      Reported-by: default avatarAditya Paluri <Venkata.AdityaPaluri@synopsys.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      78cf33ae
    • Hannes Reinecke's avatar
      dm zoned: return NULL if dmz_get_zone_for_reclaim() fails to find a zone · 4ad7add5
      Hannes Reinecke authored
      [ Upstream commit 489dc0f0 ]
      
      The only case where dmz_get_zone_for_reclaim() cannot return a zone is
      if the respective lists are empty. So we should just return a simple
      NULL value here as we really don't have an error code which would make
      sense.
      Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
      Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4ad7add5
    • Qian Cai's avatar
      powerpc/64s/pgtable: fix an undefined behaviour · 080fcec7
      Qian Cai authored
      [ Upstream commit c2e929b1 ]
      
      Booting a power9 server with hash MMU could trigger an undefined
      behaviour because pud_offset(p4d, 0) will do,
      
      0 >> (PAGE_SHIFT:16 + PTE_INDEX_SIZE:8 + H_PMD_INDEX_SIZE:10)
      
      Fix it by converting pud_index() and friends to static inline
      functions.
      
      UBSAN: shift-out-of-bounds in arch/powerpc/mm/ptdump/ptdump.c:282:15
      shift exponent 34 is too large for 32-bit type 'int'
      CPU: 6 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc4-next-20200303+ #13
      Call Trace:
      dump_stack+0xf4/0x164 (unreliable)
      ubsan_epilogue+0x18/0x78
      __ubsan_handle_shift_out_of_bounds+0x160/0x21c
      walk_pagetables+0x2cc/0x700
      walk_pud at arch/powerpc/mm/ptdump/ptdump.c:282
      (inlined by) walk_pagetables at arch/powerpc/mm/ptdump/ptdump.c:311
      ptdump_check_wx+0x8c/0xf0
      mark_rodata_ro+0x48/0x80
      kernel_init+0x74/0x194
      ret_from_kernel_thread+0x5c/0x74
      Suggested-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Link: https://lore.kernel.org/r/20200306044852.3236-1-cai@lca.pwSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      080fcec7
    • Jon Hunter's avatar
      arm64: tegra: Fix ethernet phy-mode for Jetson Xavier · c9004fb1
      Jon Hunter authored
      [ Upstream commit bba25915 ]
      
      The 'phy-mode' property is currently defined as 'rgmii' for Jetson
      Xavier. This indicates that the RGMII RX and TX delays are set by the
      MAC and the internal delays set by the PHY are not used.
      
      If the Marvell PHY driver is enabled, such that it is used and not the
      generic PHY, ethernet failures are seen (DHCP is failing to obtain an
      IP address) and this is caused because the Marvell PHY driver is
      disabling the internal RX and TX delays. For Jetson Xavier the internal
      PHY RX and TX delay should be used and so fix this by setting the
      'phy-mode' to 'rgmii-id' and not 'rgmii'.
      
      Fixes: f89b58ce ("arm64: tegra: Add ethernet controller on Tegra194")
      Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c9004fb1
    • Bodo Stroesser's avatar
      scsi: target: tcmu: Userspace must not complete queued commands · 0a562db7
      Bodo Stroesser authored
      [ Upstream commit 61fb2482 ]
      
      When tcmu queues a new command - no matter whether in command ring or in
      qfull_queue - a cmd_id from IDR udev->commands is assigned to the command.
      
      If userspace sends a wrong command completion containing the cmd_id of a
      command on the qfull_queue, tcmu_handle_completions() finds the command in
      the IDR and calls tcmu_handle_completion() for it. This might do some nasty
      things because commands in qfull_queue do not have a valid dbi list.
      
      To fix this bug, we no longer add queued commands to the idr.  Instead the
      cmd_id is assign when a command is written to the command ring.
      
      Due to this change I had to adapt the source code at several places where
      up to now an idr_for_each had been done.
      
      [mkp: fix checkpatch warnings]
      
      Link: https://lore.kernel.org/r/20200518164833.12775-1-bstroesser@ts.fujitsu.comAcked-by: default avatarMike Christie <mchristi@redhat.com>
      Signed-off-by: default avatarBodo Stroesser <bstroesser@ts.fujitsu.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0a562db7
    • Marek Szyprowski's avatar
      clk: samsung: exynos5433: Add IGNORE_UNUSED flag to sclk_i2s1 · 34d68f5c
      Marek Szyprowski authored
      [ Upstream commit 25bdae0f ]
      
      Mark the SCLK clock for Exynos5433 I2S1 device with IGNORE_UNUSED flag to
      match its behaviour with SCLK clock for AUD_I2S (I2S0) device until
      a proper fix for Exynos I2S driver is ready.
      
      This fixes the following synchronous abort issue revealed by the probe
      order change caused by the commit 93d2e432 ("of: platform: Batch
      fwnode parsing when adding all top level devices")
      
      Internal error: synchronous external abort: 96000210 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 0 PID: 50 Comm: kworker/0:1 Not tainted 5.7.0-rc5+ #701
      Hardware name: Samsung TM2E board (DT)
      Workqueue: events deferred_probe_work_func
      pstate: 60000005 (nZCv daif -PAN -UAO)
      pc : samsung_i2s_probe+0x768/0x8f0
      lr : samsung_i2s_probe+0x688/0x8f0
      ...
      Call trace:
       samsung_i2s_probe+0x768/0x8f0
       platform_drv_probe+0x50/0xa8
       really_probe+0x108/0x370
       driver_probe_device+0x54/0xb8
       __device_attach_driver+0x90/0xc0
       bus_for_each_drv+0x70/0xc8
       __device_attach+0xdc/0x140
       device_initial_probe+0x10/0x18
       bus_probe_device+0x94/0xa0
       deferred_probe_work_func+0x70/0xa8
       process_one_work+0x2a8/0x718
       worker_thread+0x48/0x470
       kthread+0x134/0x160
       ret_from_fork+0x10/0x1c
      Code: 17ffffaf d503201f f94086c0 91003000 (88dffc00)
      ---[ end trace ccf721c9400ddbd6 ]---
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      34d68f5c
    • Souptick Joarder's avatar
      fpga: dfl: afu: Corrected error handling levels · 23abe47c
      Souptick Joarder authored
      [ Upstream commit c9d7e3da ]
      
      Corrected error handling goto sequnece. Level put_pages should
      be called when pinned pages >= 0 && pinned != npages. Level
      free_pages should be called when pinned pages < 0.
      
      Fixes: fa8dda1e ("fpga: dfl: afu: add DFL_FPGA_PORT_DMA_MAP/UNMAP ioctls support")
      Signed-off-by: default avatarSouptick Joarder <jrdr.linux@gmail.com>
      Acked-by: default avatarWu Hao <hao.wu@intel.com>
      Reviewed-by: default avatarXu Yilun <yilun.xu@intel.com>
      Link: https://lore.kernel.org/r/1589825991-3545-1-git-send-email-jrdr.linux@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      23abe47c
    • Gregory CLEMENT's avatar
      tty: n_gsm: Fix bogus i++ in gsm_data_kick · 2783eb90
      Gregory CLEMENT authored
      [ Upstream commit 4dd31f1f ]
      
      When submitting the previous fix "tty: n_gsm: Fix waking up upper tty
      layer when room available". It was suggested to switch from a while to
      a for loop, but when doing it, there was a remaining bogus i++.
      
      This patch removes this i++ and also reorganizes the code making it more
      compact.
      
      Fixes: e1eaea46 ("tty: n_gsm line discipline")
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      Link: https://lore.kernel.org/r/20200518084517.2173242-3-gregory.clement@bootlin.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2783eb90
    • Tang Bin's avatar
      USB: host: ehci-mxc: Add error handling in ehci_mxc_drv_probe() · 549ff843
      Tang Bin authored
      [ Upstream commit d4929202 ]
      
      The function ehci_mxc_drv_probe() does not perform sufficient error
      checking after executing platform_get_irq(), thus fix it.
      
      Fixes: 7e8d5cd9 ("USB: Add EHCI support for MX27 and MX31 based boards")
      Signed-off-by: default avatarZhang Shengju <zhangshengju@cmss.chinamobile.com>
      Signed-off-by: default avatarTang Bin <tangbin@cmss.chinamobile.com>
      Reviewed-by: default avatarPeter Chen <peter.chen@nxp.com>
      Link: https://lore.kernel.org/r/20200513132647.5456-1-tangbin@cmss.chinamobile.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      549ff843
    • Hans de Goede's avatar
      ASoC: Intel: bytcr_rt5640: Add quirk for Toshiba Encore WT8-A tablet · efe7880e
      Hans de Goede authored
      [ Upstream commit 0e0e10fd ]
      
      The Toshiba Encore WT8-A tablet almost fully works with the default
      settings for non-CR Bay Trail devices. The only problem is that its
      jack-detect switch is not inverted (it is active high instead of
      the normal active low).
      
      Add a quirk for this model using the default settings +
      BYT_RT5640_JD_NOT_INV.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Acked-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20200518072416.5348-1-hdegoede@redhat.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      efe7880e
    • Roy Spliet's avatar
      drm/msm/mdp5: Fix mdp5_init error path for failed mdp5_kms allocation · ccfdc995
      Roy Spliet authored
      [ Upstream commit e4337877 ]
      
      When allocation for mdp5_kms fails, calling mdp5_destroy() leads to undefined
      behaviour, likely a nullptr exception or use-after-free troubles.
      Signed-off-by: default avatarRoy Spliet <nouveau@spliet.org>
      Reviewed-by: default avatarAbhinav Kumar <abhinavk@codeaurora.org>
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ccfdc995
    • Qais Yousef's avatar
      usb/ohci-platform: Fix a warning when hibernating · c83258a7
      Qais Yousef authored
      [ Upstream commit 1cb3b009 ]
      
      The following warning was observed when attempting to suspend to disk
      using a USB flash as a swap device.
      
      [  111.779649] ------------[ cut here ]------------
      [  111.788382] URB (____ptrval____) submitted while active
      [  111.796646] WARNING: CPU: 3 PID: 365 at drivers/usb/core/urb.c:363 usb_submit_urb+0x3d8/0x590
      [  111.805417] Modules linked in:
      [  111.808584] CPU: 3 PID: 365 Comm: kworker/3:2 Not tainted 5.6.0-rc6-00002-gdfd1731f9a3e-dirty #545
      [  111.817796] Hardware name: ARM Juno development board (r2) (DT)
      [  111.823896] Workqueue: usb_hub_wq hub_event
      [  111.828217] pstate: 60000005 (nZCv daif -PAN -UAO)
      [  111.833156] pc : usb_submit_urb+0x3d8/0x590
      [  111.837471] lr : usb_submit_urb+0x3d8/0x590
      [  111.841783] sp : ffff800018de38b0
      [  111.845205] x29: ffff800018de38b0 x28: 0000000000000003
      [  111.850682] x27: ffff000970530b20 x26: ffff8000133fd000
      [  111.856159] x25: ffff8000133fd000 x24: ffff800018de3b38
      [  111.861635] x23: 0000000000000004 x22: 0000000000000c00
      [  111.867112] x21: 0000000000000000 x20: 00000000fffffff0
      [  111.872589] x19: ffff0009704e7a00 x18: ffffffffffffffff
      [  111.878065] x17: 00000000a7c8f4bc x16: 000000002af33de8
      [  111.883542] x15: ffff8000133fda88 x14: 0720072007200720
      [  111.889019] x13: 0720072007200720 x12: 0720072007200720
      [  111.894496] x11: 0000000000000000 x10: 00000000a5286134
      [  111.899973] x9 : 0000000000000002 x8 : ffff000970c837a0
      [  111.905449] x7 : 0000000000000000 x6 : ffff800018de3570
      [  111.910926] x5 : 0000000000000001 x4 : 0000000000000003
      [  111.916401] x3 : 0000000000000000 x2 : ffff800013427118
      [  111.921879] x1 : 9d4e965b4b7d7c00 x0 : 0000000000000000
      [  111.927356] Call trace:
      [  111.929892]  usb_submit_urb+0x3d8/0x590
      [  111.933852]  hub_activate+0x108/0x7f0
      [  111.937633]  hub_resume+0xac/0x148
      [  111.941149]  usb_resume_interface.isra.10+0x60/0x138
      [  111.946265]  usb_resume_both+0xe4/0x140
      [  111.950225]  usb_runtime_resume+0x24/0x30
      [  111.954365]  __rpm_callback+0xdc/0x138
      [  111.958236]  rpm_callback+0x34/0x98
      [  111.961841]  rpm_resume+0x4a8/0x720
      [  111.965445]  rpm_resume+0x50c/0x720
      [  111.969049]  __pm_runtime_resume+0x4c/0xb8
      [  111.973276]  usb_autopm_get_interface+0x28/0x60
      [  111.977948]  hub_event+0x80/0x16d8
      [  111.981466]  process_one_work+0x2a4/0x748
      [  111.985604]  worker_thread+0x48/0x498
      [  111.989387]  kthread+0x13c/0x140
      [  111.992725]  ret_from_fork+0x10/0x18
      [  111.996415] irq event stamp: 354
      [  111.999756] hardirqs last  enabled at (353): [<ffff80001019ea1c>] console_unlock+0x504/0x5b8
      [  112.008441] hardirqs last disabled at (354): [<ffff8000100a95d0>] do_debug_exception+0x1a8/0x258
      [  112.017479] softirqs last  enabled at (350): [<ffff8000100818a4>] __do_softirq+0x4bc/0x568
      [  112.025984] softirqs last disabled at (343): [<ffff8000101145a4>] irq_exit+0x144/0x150
      [  112.034129] ---[ end trace dc96030b9cf6c8a3 ]---
      
      The problem was tracked down to a missing call to
      pm_runtime_set_active() on resume in ohci-platform.
      
      Link: https://lore.kernel.org/lkml/20200323143857.db5zphxhq4hz3hmd@e107158-lin.cambridge.arm.com/Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarQais Yousef <qais.yousef@arm.com>
      CC: Tony Prisk <linux@prisktech.co.nz>
      CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      CC: Mathias Nyman <mathias.nyman@intel.com>
      CC: Oliver Neukum <oneukum@suse.de>
      CC: linux-arm-kernel@lists.infradead.org
      CC: linux-usb@vger.kernel.org
      CC: linux-kernel@vger.kernel.org
      Link: https://lore.kernel.org/r/20200518154931.6144-1-qais.yousef@arm.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c83258a7
    • Alex Williamson's avatar
      vfio-pci: Mask cap zero · e9aaff2b
      Alex Williamson authored
      [ Upstream commit bc138db1 ]
      
      The PCI Code and ID Assignment Specification changed capability ID 0
      from reserved to a NULL capability in the v1.1 revision.  The NULL
      capability is defined to include only the 16-bit capability header,
      ie. only the ID and next pointer.  Unfortunately vfio-pci creates a
      map of config space, where ID 0 is used to reserve the standard type
      0 header.  Finding an actual capability with this ID therefore results
      in a bogus range marked in that map and conflicts with subsequent
      capabilities.  As this seems to be a dummy capability anyway and we
      already support dropping capabilities, let's hide this one rather than
      delving into the potentially subtle dependencies within our map.
      
      Seen on an NVIDIA Tesla T4.
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e9aaff2b
    • Geoff Levand's avatar
      powerpc/ps3: Fix kexec shutdown hang · 020d0e37
      Geoff Levand authored
      [ Upstream commit 12655446 ]
      
      The ps3_mm_region_destroy() and ps3_mm_vas_destroy() routines
      are called very late in the shutdown via kexec's mmu_cleanup_all
      routine.  By the time mmu_cleanup_all runs it is too late to use
      udbg_printf, and calling it will cause PS3 systems to hang.
      
      Remove all debugging statements from ps3_mm_region_destroy() and
      ps3_mm_vas_destroy() and replace any error reporting with calls
      to lv1_panic.
      
      With this change builds with 'DEBUG' defined will not cause kexec
      reboots to hang, and builds with 'DEBUG' defined or not will end
      in lv1_panic if an error is encountered.
      Signed-off-by: default avatarGeoff Levand <geoff@infradead.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/7325c4af2b4c989c19d6a26b90b1fec9c0615ddf.1589049250.git.geoff@infradead.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      020d0e37
    • Nicholas Piggin's avatar
      powerpc/pseries/ras: Fix FWNMI_VALID off by one · 45a4f5d3
      Nicholas Piggin authored
      [ Upstream commit deb70f7a ]
      
      This was discovered developing qemu fwnmi sreset support. This
      off-by-one bug means the last 16 bytes of the rtas area can not
      be used for a 16 byte save area.
      
      It's not a serious bug, and QEMU implementation has to retain a
      workaround for old kernels, but it's good to tighten it.
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Acked-by: default avatarMahesh Salgaonkar <mahesh@linux.ibm.com>
      Link: https://lore.kernel.org/r/20200508043408.886394-7-npiggin@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      45a4f5d3
    • Feng Tang's avatar
      ipmi: use vzalloc instead of kmalloc for user creation · 1d9c47a3
      Feng Tang authored
      [ Upstream commit 7c47a219 ]
      
      We met mulitple times of failure of staring bmc-watchdog,
      due to the runtime memory allocation failure of order 4.
      
           bmc-watchdog: page allocation failure: order:4, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0-1
           CPU: 1 PID: 2571 Comm: bmc-watchdog Not tainted 5.5.0-00045-g7d6bb61d6188c #1
           Hardware name: Intel Corporation S2600WFT/S2600WFT, BIOS SE5C620.86B.00.01.0015.110720180833 11/07/2018
           Call Trace:
            dump_stack+0x66/0x8b
            warn_alloc+0xfe/0x160
            __alloc_pages_slowpath+0xd3e/0xd80
            __alloc_pages_nodemask+0x2f0/0x340
            kmalloc_order+0x18/0x70
            kmalloc_order_trace+0x1d/0xb0
            ipmi_create_user+0x55/0x2c0 [ipmi_msghandler]
            ipmi_open+0x72/0x110 [ipmi_devintf]
            chrdev_open+0xcb/0x1e0
            do_dentry_open+0x1ce/0x380
            path_openat+0x305/0x14f0
            do_filp_open+0x9b/0x110
            do_sys_open+0x1bd/0x250
            do_syscall_64+0x5b/0x1f0
            entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Using vzalloc/vfree for creating ipmi_user heals the
      problem
      
      Thanks to Stephen Rothwell for finding the vmalloc.h
      inclusion issue.
      Signed-off-by: default avatarFeng Tang <feng.tang@intel.com>
      Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1d9c47a3
    • Cristian Klein's avatar
      HID: Add quirks for Trust Panora Graphic Tablet · 5a5b485c
      Cristian Klein authored
      [ Upstream commit fb68ada8 ]
      
      The Trust Panora Graphic Tablet has two interfaces. Interface zero reports pen
      movement, pen pressure and pen buttons. Interface one reports tablet buttons
      and tablet scroll. Both use the mouse protocol.
      
      Without these quirks, libinput gets confused about what device it talks to.
      
      For completeness, here is the usbhid-dump:
      
      ```
      $ sudo usbhid-dump -d 145f:0212
      003:013:001:DESCRIPTOR         1588949402.559961
       05 0D 09 01 A1 01 85 07 A1 02 09 00 75 08 95 07
       81 02 C0 C0 09 0E A1 01 85 05 09 23 A1 02 09 52
       09 53 25 0A 75 08 95 02 B1 02 C0 C0 05 0C 09 36
       A1 00 85 06 05 09 19 01 29 20 15 00 25 01 95 20
       75 01 81 02 C0
      
      003:013:000:DESCRIPTOR         1588949402.563942
       05 01 09 02 A1 01 85 08 09 01 A1 00 05 09 19 01
       29 03 15 00 25 01 95 03 75 01 81 02 95 05 81 01
       05 01 09 30 09 31 09 38 09 00 15 81 25 7F 75 08
       95 04 81 06 C0 C0 05 01 09 02 A1 01 85 09 09 01
       A1 00 05 09 19 01 29 03 15 00 25 01 95 03 75 01
       81 02 95 05 81 01 05 01 09 30 09 31 26 FF 7F 95
       02 75 10 81 02 05 0D 09 30 26 FF 03 95 01 75 10
       81 02 C0 C0 05 01 09 00 A1 01 85 04 A1 00 26 FF
       00 09 00 75 08 95 07 B1 02 C0 C0
      ```
      Signed-off-by: default avatarCristian Klein <cristian.klein@elastisys.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5a5b485c
    • Gregory CLEMENT's avatar
      tty: n_gsm: Fix waking up upper tty layer when room available · d1ceda6f
      Gregory CLEMENT authored
      [ Upstream commit 01dbb362 ]
      
      Warn the upper layer when n_gms is ready to receive data
      again. Without this the associated virtual tty remains blocked
      indefinitely.
      
      Fixes: e1eaea46 ("tty: n_gsm line discipline")
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      Link: https://lore.kernel.org/r/20200512115323.1447922-4-gregory.clement@bootlin.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d1ceda6f
    • Gregory CLEMENT's avatar
      tty: n_gsm: Fix SOF skipping · 56e3912e
      Gregory CLEMENT authored
      [ Upstream commit 84d6f81c ]
      
      For at least some modems like the TELIT LE910, skipping SOF makes
      transfers blocking indefinitely after a short amount of data
      transferred.
      
      Given the small improvement provided by skipping the SOF (just one
      byte on about 100 bytes), it seems better to completely remove this
      "feature" than make it optional.
      
      Fixes: e1eaea46 ("tty: n_gsm line discipline")
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      Link: https://lore.kernel.org/r/20200512115323.1447922-3-gregory.clement@bootlin.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      56e3912e
    • Michael Ellerman's avatar
      powerpc/64: Don't initialise init_task->thread.regs · 615e2d0b
      Michael Ellerman authored
      [ Upstream commit 7ffa8b7d ]
      
      Aneesh increased the size of struct pt_regs by 16 bytes and started
      seeing this WARN_ON:
      
        smp: Bringing up secondary CPUs ...
        ------------[ cut here ]------------
        WARNING: CPU: 0 PID: 0 at arch/powerpc/kernel/process.c:455 giveup_all+0xb4/0x110
        Modules linked in:
        CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.7.0-rc2-gcc-8.2.0-1.g8f6a41f-default+ #318
        NIP:  c00000000001a2b4 LR: c00000000001a29c CTR: c0000000031d0000
        REGS: c0000000026d3980 TRAP: 0700   Not tainted  (5.7.0-rc2-gcc-8.2.0-1.g8f6a41f-default+)
        MSR:  800000000282b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>  CR: 48048224  XER: 00000000
        CFAR: c000000000019cc8 IRQMASK: 1
        GPR00: c00000000001a264 c0000000026d3c20 c0000000026d7200 800000000280b033
        GPR04: 0000000000000001 0000000000000000 0000000000000077 30206d7372203164
        GPR08: 0000000000002000 0000000002002000 800000000280b033 3230303030303030
        GPR12: 0000000000008800 c0000000031d0000 0000000000800050 0000000002000066
        GPR16: 000000000309a1a0 000000000309a4b0 000000000309a2d8 000000000309a890
        GPR20: 00000000030d0098 c00000000264da40 00000000fd620000 c0000000ff798080
        GPR24: c00000000264edf0 c0000001007469f0 00000000fd620000 c0000000020e5e90
        GPR28: c00000000264edf0 c00000000264d200 000000001db60000 c00000000264d200
        NIP [c00000000001a2b4] giveup_all+0xb4/0x110
        LR [c00000000001a29c] giveup_all+0x9c/0x110
        Call Trace:
        [c0000000026d3c20] [c00000000001a264] giveup_all+0x64/0x110 (unreliable)
        [c0000000026d3c90] [c00000000001ae34] __switch_to+0x104/0x480
        [c0000000026d3cf0] [c000000000e0b8a0] __schedule+0x320/0x970
        [c0000000026d3dd0] [c000000000e0c518] schedule_idle+0x38/0x70
        [c0000000026d3df0] [c00000000019c7c8] do_idle+0x248/0x3f0
        [c0000000026d3e70] [c00000000019cbb8] cpu_startup_entry+0x38/0x40
        [c0000000026d3ea0] [c000000000011bb0] rest_init+0xe0/0xf8
        [c0000000026d3ed0] [c000000002004820] start_kernel+0x990/0x9e0
        [c0000000026d3f90] [c00000000000c49c] start_here_common+0x1c/0x400
      
      Which was unexpected. The warning is checking the thread.regs->msr
      value of the task we are switching from:
      
        usermsr = tsk->thread.regs->msr;
        ...
        WARN_ON((usermsr & MSR_VSX) && !((usermsr & MSR_FP) && (usermsr & MSR_VEC)));
      
      ie. if MSR_VSX is set then both of MSR_FP and MSR_VEC are also set.
      
      Dumping tsk->thread.regs->msr we see that it's: 0x1db60000
      
      Which is not a normal looking MSR, in fact the only valid bit is
      MSR_VSX, all the other bits are reserved in the current definition of
      the MSR.
      
      We can see from the oops that it was swapper/0 that we were switching
      from when we hit the warning, ie. init_task. So its thread.regs points
      to the base (high addresses) in init_stack.
      
      Dumping the content of init_task->thread.regs, with the members of
      pt_regs annotated (the 16 bytes larger version), we see:
      
        0000000000000000 c000000002780080    gpr[0]     gpr[1]
        0000000000000000 c000000002666008    gpr[2]     gpr[3]
        c0000000026d3ed0 0000000000000078    gpr[4]     gpr[5]
        c000000000011b68 c000000002780080    gpr[6]     gpr[7]
        0000000000000000 0000000000000000    gpr[8]     gpr[9]
        c0000000026d3f90 0000800000002200    gpr[10]    gpr[11]
        c000000002004820 c0000000026d7200    gpr[12]    gpr[13]
        000000001db60000 c0000000010aabe8    gpr[14]    gpr[15]
        c0000000010aabe8 c0000000010aabe8    gpr[16]    gpr[17]
        c00000000294d598 0000000000000000    gpr[18]    gpr[19]
        0000000000000000 0000000000001ff8    gpr[20]    gpr[21]
        0000000000000000 c00000000206d608    gpr[22]    gpr[23]
        c00000000278e0cc 0000000000000000    gpr[24]    gpr[25]
        000000002fff0000 c000000000000000    gpr[26]    gpr[27]
        0000000002000000 0000000000000028    gpr[28]    gpr[29]
        000000001db60000 0000000004750000    gpr[30]    gpr[31]
        0000000002000000 000000001db60000    nip        msr
        0000000000000000 0000000000000000    orig_r3    ctr
        c00000000000c49c 0000000000000000    link       xer
        0000000000000000 0000000000000000    ccr        softe
        0000000000000000 0000000000000000    trap       dar
        0000000000000000 0000000000000000    dsisr      result
        0000000000000000 0000000000000000    ppr        kuap
        0000000000000000 0000000000000000    pad[2]     pad[3]
      
      This looks suspiciously like stack frames, not a pt_regs. If we look
      closely we can see return addresses from the stack trace above,
      c000000002004820 (start_kernel) and c00000000000c49c (start_here_common).
      
      init_task->thread.regs is setup at build time in processor.h:
      
        #define INIT_THREAD  { \
        	.ksp = INIT_SP, \
        	.regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
      
      The early boot code where we setup the initial stack is:
      
        LOAD_REG_ADDR(r3,init_thread_union)
      
        /* set up a stack pointer */
        LOAD_REG_IMMEDIATE(r1,THREAD_SIZE)
        add	r1,r3,r1
        li	r0,0
        stdu	r0,-STACK_FRAME_OVERHEAD(r1)
      
      Which creates a stack frame of size 112 bytes (STACK_FRAME_OVERHEAD).
      Which is far too small to contain a pt_regs.
      
      So the result is init_task->thread.regs is pointing at some stack
      frames on the init stack, not at a pt_regs.
      
      We have gotten away with this for so long because with pt_regs at its
      current size the MSR happens to point into the first frame, at a
      location that is not written to by the early asm. With the 16 byte
      expansion the MSR falls into the second frame, which is used by the
      compiler, and collides with a saved register that tends to be
      non-zero.
      
      As far as I can see this has been wrong since the original merge of
      64-bit ppc support, back in 2002.
      
      Conceptually swapper should have no regs, it never entered from
      userspace, and in fact that's what we do on 32-bit. It's also
      presumably what the "bogus" comment is referring to.
      
      So I think the right fix is to just not-initialise regs at all. I'm
      slightly worried this will break some code that isn't prepared for a
      NULL regs, but we'll have to see.
      
      Remove the comment in head_64.S which refers to us setting up the
      regs (even though we never did), and is otherwise not really accurate
      any more.
      Reported-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200428123130.73078-1-mpe@ellerman.id.auSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      615e2d0b
    • Rob Herring's avatar
      PCI: Fix pci_register_host_bridge() device_register() error handling · 5d78c4a3
      Rob Herring authored
      [ Upstream commit 1b54ae83 ]
      
      If device_register() has an error, we should bail out of
      pci_register_host_bridge() rather than continuing on.
      
      Fixes: 37d6a0a6 ("PCI: Add pci_register_host_bridge() interface")
      Link: https://lore.kernel.org/r/20200513223859.11295-1-robh@kernel.orgSigned-off-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5d78c4a3
    • Tero Kristo's avatar
      clk: ti: composite: fix memory leak · aee22d36
      Tero Kristo authored
      [ Upstream commit c7c1cbbc ]
      
      The parent_names is never released for a component clock definition,
      causing some memory leak. Fix by releasing it once it is no longer
      needed.
      Reported-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
      Signed-off-by: default avatarTero Kristo <t-kristo@ti.com>
      Link: https://lkml.kernel.org/r/20200429131341.4697-2-t-kristo@ti.comAcked-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aee22d36
    • Arnd Bergmann's avatar
      dlm: remove BUG() before panic() · 68728008
      Arnd Bergmann authored
      [ Upstream commit fe204591 ]
      
      Building a kernel with clang sometimes fails with an objtool error in dlm:
      
      fs/dlm/lock.o: warning: objtool: revert_lock_pc()+0xbd: can't find jump dest instruction at .text+0xd7fc
      
      The problem is that BUG() never returns and the compiler knows
      that anything after it is unreachable, however the panic still
      emits some code that does not get fully eliminated.
      
      Having both BUG() and panic() is really pointless as the BUG()
      kills the current process and the subsequent panic() never hits.
      In most cases, we probably don't really want either and should
      replace the DLM_ASSERT() statements with WARN_ON(), as has
      been done for some of them.
      
      Remove the BUG() here so the user at least sees the panic message
      and we can reliably build randconfig kernels.
      
      Fixes: e7fd4179 ("[DLM] The core of the DLM for GFS2/CLVM")
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: clang-built-linux@googlegroups.com
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      68728008
    • Dafna Hirschfeld's avatar
      pinctrl: rockchip: fix memleak in rockchip_dt_node_to_map · c13d4627
      Dafna Hirschfeld authored
      [ Upstream commit d7faa8ff ]
      
      In function rockchip_dt_node_to_map, a new_map variable is
      allocated by:
      
      new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map),
      		       GFP_KERNEL);
      
      This uses devres and attaches new_map to the pinctrl driver.
      This cause a leak since new_map is not released when the probed
      driver is removed. Fix it by using kcalloc to allocate new_map
      and free it in `rockchip_dt_free_map`
      Signed-off-by: default avatarDafna Hirschfeld <dafna.hirschfeld@collabora.com>
      Reviewed-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Link: https://lore.kernel.org/r/20200506100903.15420-1-dafna.hirschfeld@collabora.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c13d4627
    • Suganath Prabu S's avatar
      scsi: mpt3sas: Fix double free warnings · fc3dce34
      Suganath Prabu S authored
      [ Upstream commit cbbfdb2a ]
      
      Fix following warning from Smatch static analyser:
      
      drivers/scsi/mpt3sas/mpt3sas_base.c:5256 _base_allocate_memory_pools()
      warn: 'ioc->hpr_lookup' double freed
      
      drivers/scsi/mpt3sas/mpt3sas_base.c:5256 _base_allocate_memory_pools()
      warn: 'ioc->internal_lookup' double freed
      
      Link: https://lore.kernel.org/r/20200508110738.30732-1-suganath-prabu.subramani@broadcom.comReported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarSuganath Prabu S <suganath-prabu.subramani@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fc3dce34
    • Dmitry Osipenko's avatar
      power: supply: smb347-charger: IRQSTAT_D is volatile · 99545a11
      Dmitry Osipenko authored
      [ Upstream commit c32ea07a ]
      
      Fix failure when USB cable is connected:
      smb347 2-006a: reading IRQSTAT_D failed
      
      Fixes: 1502cfe1 ("smb347-charger: Fix battery status reporting logic for charger faults")
      Tested-by: default avatarDavid Heidelberg <david@ixit.cz>
      Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Signed-off-by: default avatarDavid Heidelberg <david@ixit.cz>
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      99545a11
    • Christophe JAILLET's avatar
      power: supply: lp8788: Fix an error handling path in 'lp8788_charger_probe()' · 39e09268
      Christophe JAILLET authored
      [ Upstream commit 934ed384 ]
      
      In the probe function, in case of error, resources allocated in
      'lp8788_setup_adc_channel()' must be released.
      
      This can be achieved easily by using the devm_ variant of
      'iio_channel_get()'.
      This has the extra benefit to simplify the remove function and to axe the
      'lp8788_release_adc_channel()' function which is now useless.
      
      Fixes: 98a27664 ("power_supply: Add new lp8788 charger driver")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      39e09268
    • Viacheslav Dubeyko's avatar
      scsi: qla2xxx: Fix warning after FC target reset · 9d10dbdc
      Viacheslav Dubeyko authored
      [ Upstream commit f839544c ]
      
      Currently, FC target reset finishes with the warning message:
      
      [84010.596893] ------------[ cut here ]------------
      [84010.596917] WARNING: CPU: 238 PID: 279973 at ../drivers/scsi/qla2xxx/qla_target.c:6644 qlt_enable_vha+0x1d0/0x260 [qla2xxx]
      [84010.596918] Modules linked in: vrf af_packet 8021q garp mrp stp llc netlink_diag target_tatlin_tblock(OEX) dm_ec(OEX) ttln_rdma(OEX) dm_frontend(OEX) nvme_rdma nvmet tcm_qla2xxx iscsi_target_mod target_core_mod at24 nvmem_core pnv_php ipmi_watchdog ipmi_ssif vmx_crypto gf128mul crct10dif_vpmsum qla2xxx rpcrdma nvme_fc powernv_flash(X) nvme_fabrics uio_pdrv_genirq mtd rtc_opal(X) ibmpowernv(X) opal_prd(X) uio scsi_transport_fc i2c_opal(X) ses enclosure ipmi_poweroff ast i2c_algo_bit ttm bmc_mcu(OEX) drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm drm_panel_orientation_quirks agpgart nfsd auth_rpcgss nfs_acl ipmi_powernv(X) lockd ipmi_devintf ipmi_msghandler grace dummy ext4 crc16 jbd2 mbcache sd_mod rdma_ucm ib_iser rdma_cm ib_umad iw_cm ib_ipoib libiscsi scsi_transport_iscsi ib_cm
      [84010.596975]  configfs mlx5_ib ib_uverbs ib_core mlx5_core crc32c_vpmsum xhci_pci xhci_hcd mpt3sas(OEX) tg3 usbcore mlxfw tls raid_class libphy scsi_transport_sas devlink ptp pps_core nvme nvme_core sunrpc dm_mirror dm_region_hash dm_log sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua scsi_mod autofs4
      [84010.597001] Supported: Yes, External
      [84010.597004] CPU: 238 PID: 279973 Comm: bash Tainted: G           OE      4.12.14-197.29-default #1 SLE15-SP1
      [84010.597006] task: c000000a104c0000 task.stack: c000000b52188000
      [84010.597007] NIP: d00000001ffd7f78 LR: d00000001ffd7f6c CTR: c0000000001676c0
      [84010.597008] REGS: c000000b5218b910 TRAP: 0700   Tainted: G           OE       (4.12.14-197.29-default)
      [84010.597008] MSR: 900000010282b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE,TM[E]>
      [84010.597015]   CR: 48242424  XER: 00000000
      [84010.597016] CFAR: d00000001ff45d08 SOFTE: 1
                     GPR00: d00000001ffd7f6c c000000b5218bb90 d00000002001b228 0000000000000102
                     GPR04: 0000000000000001 0000000000000001 00013d91ed0a5e2d 0000000000000000
                     GPR08: c000000007793300 0000000000000000 0000000000000000 c000000a086e7818
                     GPR12: 0000000000002200 c000000007793300 0000000000000000 000000012bc937c0
                     GPR16: 000000012bbf7ed0 0000000000000000 000000012bc3dd10 0000000000000000
                     GPR20: 000000012bc4db28 0000010036442810 000000012bc97828 000000012bc96c70
                     GPR24: 00000100365b1550 0000000000000000 00000100363f3d80 c000000be20d3080
                     GPR28: c000000bda7eae00 c000000be20db7e8 c000000be20d3778 c000000be20db7e8
      [84010.597042] NIP [d00000001ffd7f78] qlt_enable_vha+0x1d0/0x260 [qla2xxx]
      [84010.597051] LR [d00000001ffd7f6c] qlt_enable_vha+0x1c4/0x260 [qla2xxx]
      [84010.597051] Call Trace:
      [84010.597061] [c000000b5218bb90] [d00000001ffd7f6c] qlt_enable_vha+0x1c4/0x260 [qla2xxx] (unreliable)
      [84010.597064] [c000000b5218bc20] [d000000009820b6c] tcm_qla2xxx_tpg_enable_store+0xc4/0x130 [tcm_qla2xxx]
      [84010.597067] [c000000b5218bcb0] [d0000000185d0e68] configfs_write_file+0xd0/0x190 [configfs]
      [84010.597072] [c000000b5218bd00] [c0000000003d0edc] __vfs_write+0x3c/0x1e0
      [84010.597074] [c000000b5218bd90] [c0000000003d2ea8] vfs_write+0xd8/0x220
      [84010.597076] [c000000b5218bde0] [c0000000003d4ddc] SyS_write+0x6c/0x110
      [84010.597079] [c000000b5218be30] [c00000000000b188] system_call+0x3c/0x130
      [84010.597080] Instruction dump:
      [84010.597082] 7d0050a8 7d084b78 7d0051ad 40c2fff4 7fa3eb78 4bf73965 60000000 7fa3eb78
      [84010.597086] 4bf6dcd9 60000000 2fa30000 419eff40 <0fe00000> 4bffff38 e95f0058 a12a0180
      [84010.597090] ---[ end trace e32abaf6e6fee826 ]---
      
      To reproduce:
      
      echo 0x7fffffff > /sys/module/qla2xxx/parameters/logging
      modprobe target_core_mod
      modprobe tcm_qla2xxx
      mkdir /sys/kernel/config/target/qla2xxx
      mkdir /sys/kernel/config/target/qla2xxx/<port-name>
      mkdir /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1
      echo 1 > /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1/enable
      echo 0 > /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1/enable
      echo 1 > /sys/kernel/config/target/qla2xxx/<port-name>/tpgt_1/enable
      
      SYSTEM START
      kernel: pid 327:drivers/scsi/qla2xxx/qla_init.c:2174 qla2x00_initialize_adapter(): vha->flags.online 0x0
      <...>
      kernel: pid 327:drivers/scsi/qla2xxx/qla_os.c:3444 qla2x00_probe_one(): vha->flags.online 0x1
      
      echo 1 > /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:86:a6:2a/tpgt_1/enable
      kernel: pid 348:drivers/scsi/qla2xxx/qla_init.c:6641 qla2x00_abort_isp_cleanup(): vha->flags.online 0x0, ISP_ABORT_NEEDED 0x0
      <...>
      kernel: pid 348:drivers/scsi/qla2xxx/qla_init.c:6998 qla2x00_restart_isp(): vha->flags.online 0x0
      
      echo 0 > /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:86:a6:2a/tpgt_1/enable
      kernel: pid 348:drivers/scsi/qla2xxx/qla_init.c:6641 qla2x00_abort_isp_cleanup(): vha->flags.online 0x0, ISP_ABORT_NEEDED 0x0
      <...>
      kernel: pid 1404:drivers/scsi/qla2xxx/qla_os.c:1107 qla2x00_wait_for_hba_online(): base_vha->flags.online 0x0
      
      echo 1 > /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:86:a6:2a/tpgt_1/enable
      kernel: pid 1404:drivers/scsi/qla2xxx/qla_os.c:1107 qla2x00_wait_for_hba_online(): base_vha->flags.online 0x0
      kernel: -----------[ cut here ]-----------
      kernel: WARNING: CPU: 1 PID: 1404 at drivers/scsi/qla2xxx/qla_target.c:6654 qlt_enable_vha+0x1e0/0x280 [qla2xxx]
      
      The issue happens because no real ISP reset is executed.  The
      qla2x00_abort_isp(scsi_qla_host_t *vha) function expects that
      vha->flags.online will be not zero for ISP reset procedure.  This patch
      sets vha->flags.online to 1 before calling ->abort_isp() for starting the
      ISP reset.
      
      Link: https://lore.kernel.org/r/1d7b21bf9f7676643239eb3d60eaca7cfa505cf0.camel@yadro.comReviewed-by: default avatarRoman Bolshakov <r.bolshakov@yadro.com>
      Signed-off-by: default avatarViacheslav Dubeyko <v.dubeiko@yadro.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9d10dbdc
    • Kai-Heng Feng's avatar
      PCI/ASPM: Allow ASPM on links to PCIe-to-PCI/PCI-X Bridges · 34d2c84c
      Kai-Heng Feng authored
      [ Upstream commit 66ff14e5 ]
      
      7d715a6c ("PCI: add PCI Express ASPM support") added the ability for
      Linux to enable ASPM, but for some undocumented reason, it didn't enable
      ASPM on links where the downstream component is a PCIe-to-PCI/PCI-X Bridge.
      
      Remove this exclusion so we can enable ASPM on these links.
      
      The Dell OptiPlex 7080 mentioned in the bugzilla has a TI XIO2001
      PCIe-to-PCI Bridge.  Enabling ASPM on the link leading to it allows the
      Intel SoC to enter deeper Package C-states, which is a significant power
      savings.
      
      [bhelgaas: commit log]
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207571
      Link: https://lore.kernel.org/r/20200505173423.26968-1-kai.heng.feng@canonical.comSigned-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      34d2c84c
    • Andrew Murray's avatar
      PCI: rcar: Fix incorrect programming of OB windows · 2b024866
      Andrew Murray authored
      [ Upstream commit 2b9f2174 ]
      
      The outbound windows (PCIEPAUR(x), PCIEPALR(x)) describe a mapping between
      a CPU address (which is determined by the window number 'x') and a
      programmed PCI address - Thus allowing the controller to translate CPU
      accesses into PCI accesses.
      
      However the existing code incorrectly writes the CPU address - lets fix
      this by writing the PCI address instead.
      
      For memory transactions, existing DT users describe a 1:1 identity mapping
      and thus this change should have no effect. However the same isn't true for
      I/O.
      
      Link: https://lore.kernel.org/r/20191004132941.6660-1-andrew.murray@arm.com
      Fixes: c25da477 ("PCI: rcar: Add Renesas R-Car PCIe driver")
      Tested-by: default avatarMarek Vasut <marek.vasut+renesas@gmail.com>
      Signed-off-by: default avatarAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Reviewed-by: default avatarMarek Vasut <marek.vasut+renesas@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b024866
    • Kuppuswamy Sathyanarayanan's avatar
      drivers: base: Fix NULL pointer exception in __platform_driver_probe() if a... · cd74de67
      Kuppuswamy Sathyanarayanan authored
      drivers: base: Fix NULL pointer exception in __platform_driver_probe() if a driver developer is foolish
      
      [ Upstream commit 388bcc6e ]
      
      If platform bus driver registration is failed then, accessing
      platform bus spin lock (&drv->driver.bus->p->klist_drivers.k_lock)
      in __platform_driver_probe() without verifying the return value
      __platform_driver_register() can lead to NULL pointer exception.
      
      So check the return value before attempting the spin lock.
      
      One such example is below:
      
      For a custom usecase, I have intentionally failed the platform bus
      registration and I expected all the platform device/driver
      registrations to fail gracefully. But I came across this panic
      issue.
      
      [    1.331067] BUG: kernel NULL pointer dereference, address: 00000000000000c8
      [    1.331118] #PF: supervisor write access in kernel mode
      [    1.331163] #PF: error_code(0x0002) - not-present page
      [    1.331208] PGD 0 P4D 0
      [    1.331233] Oops: 0002 [#1] PREEMPT SMP
      [    1.331268] CPU: 3 PID: 1 Comm: swapper/0 Tainted: G        W         5.6.0-00049-g670d35fb0144 #165
      [    1.331341] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
      [    1.331406] RIP: 0010:_raw_spin_lock+0x15/0x30
      [    1.331588] RSP: 0000:ffffc9000001be70 EFLAGS: 00010246
      [    1.331632] RAX: 0000000000000000 RBX: 00000000000000c8 RCX: 0000000000000001
      [    1.331696] RDX: 0000000000000001 RSI: 0000000000000092 RDI: 0000000000000000
      [    1.331754] RBP: 00000000ffffffed R08: 0000000000000501 R09: 0000000000000001
      [    1.331817] R10: ffff88817abcc520 R11: 0000000000000670 R12: 00000000ffffffed
      [    1.331881] R13: ffffffff82dbc268 R14: ffffffff832f070a R15: 0000000000000000
      [    1.331945] FS:  0000000000000000(0000) GS:ffff88817bd80000(0000) knlGS:0000000000000000
      [    1.332008] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    1.332062] CR2: 00000000000000c8 CR3: 000000000681e001 CR4: 00000000003606e0
      [    1.332126] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [    1.332189] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [    1.332252] Call Trace:
      [    1.332281]  __platform_driver_probe+0x92/0xee
      [    1.332323]  ? rtc_dev_init+0x2b/0x2b
      [    1.332358]  cmos_init+0x37/0x67
      [    1.332396]  do_one_initcall+0x7d/0x168
      [    1.332428]  kernel_init_freeable+0x16c/0x1c9
      [    1.332473]  ? rest_init+0xc0/0xc0
      [    1.332508]  kernel_init+0x5/0x100
      [    1.332543]  ret_from_fork+0x1f/0x30
      [    1.332579] CR2: 00000000000000c8
      [    1.332616] ---[ end trace 3bd87f12e9010b87 ]---
      [    1.333549] note: swapper/0[1] exited with preempt_count 1
      [    1.333592] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
      [    1.333736] Kernel Offset: disabled
      
      Note, this can only be triggered if a driver errors out from this call,
      which should never happen.  If it does, the driver needs to be fixed.
      Signed-off-by: default avatarKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
      Link: https://lore.kernel.org/r/20200408214003.3356-1-sathyanarayanan.kuppuswamy@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cd74de67
    • John Stultz's avatar
      serial: amba-pl011: Make sure we initialize the port.lock spinlock · 5d2195b7
      John Stultz authored
      [ Upstream commit 8508f4cb ]
      
      Valentine reported seeing:
      
      [    3.626638] INFO: trying to register non-static key.
      [    3.626639] the code is fine but needs lockdep annotation.
      [    3.626640] turning off the locking correctness validator.
      [    3.626644] CPU: 7 PID: 51 Comm: kworker/7:1 Not tainted 5.7.0-rc2-00115-g8c2e9790f196 #116
      [    3.626646] Hardware name: HiKey960 (DT)
      [    3.626656] Workqueue: events deferred_probe_work_func
      [    3.632476] sd 0:0:0:0: [sda] Optimal transfer size 8192 bytes not a multiple of physical block size (16384 bytes)
      [    3.640220] Call trace:
      [    3.640225]  dump_backtrace+0x0/0x1b8
      [    3.640227]  show_stack+0x20/0x30
      [    3.640230]  dump_stack+0xec/0x158
      [    3.640234]  register_lock_class+0x598/0x5c0
      [    3.640235]  __lock_acquire+0x80/0x16c0
      [    3.640236]  lock_acquire+0xf4/0x4a0
      [    3.640241]  _raw_spin_lock_irqsave+0x70/0xa8
      [    3.640245]  uart_add_one_port+0x388/0x4b8
      [    3.640248]  pl011_register_port+0x70/0xf0
      [    3.640250]  pl011_probe+0x184/0x1b8
      [    3.640254]  amba_probe+0xdc/0x180
      [    3.640256]  really_probe+0xe0/0x338
      [    3.640257]  driver_probe_device+0x60/0xf8
      [    3.640259]  __device_attach_driver+0x8c/0xd0
      [    3.640260]  bus_for_each_drv+0x84/0xd8
      [    3.640261]  __device_attach+0xe4/0x140
      [    3.640263]  device_initial_probe+0x1c/0x28
      [    3.640265]  bus_probe_device+0xa4/0xb0
      [    3.640266]  deferred_probe_work_func+0x7c/0xb8
      [    3.640269]  process_one_work+0x2c0/0x768
      [    3.640271]  worker_thread+0x4c/0x498
      [    3.640272]  kthread+0x14c/0x158
      [    3.640275]  ret_from_fork+0x10/0x1c
      
      Which seems to be due to the fact that after allocating the uap
      structure, nothing initializes the spinlock.
      
      Its a little confusing, as uart_port_spin_lock_init() is one
      place where the lock is supposed to be initialized, but it has
      an exception for the case where the port is a console.
      
      This makes it seem like a deeper fix is needed to properly
      register the console, but I'm not sure what that entails, and
      Andy suggested that this approach is less invasive.
      
      Thus, this patch resolves the issue by initializing the spinlock
      in the driver, and resolves the resulting warning.
      
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Jiri Slaby <jslaby@suse.com>
      Cc: linux-serial@vger.kernel.org
      Reported-by: default avatarValentin Schneider <valentin.schneider@arm.com>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Reviewed-and-tested-by: default avatarValentin Schneider <valentin.schneider@arm.com>
      Link: https://lore.kernel.org/r/20200428184050.6501-1-john.stultz@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5d2195b7