1. 27 Aug, 2020 6 commits
    • Christophe JAILLET's avatar
      rtw88: switch from 'pci_' to 'dma_' API · 24712ea9
      Christophe JAILLET authored
      The wrappers in include/linux/pci-dma-compat.h should go away.
      
      The patch has been generated with the coccinelle script below and has been
      hand modified to replace GFP_ with a correct flag.
      It has been compile tested.
      
      When memory is allocated in 'rtw_pci_init_tx_ring()' and
      'rtw_pci_init_rx_ring()' GFP_KERNEL can be used because both functions are
      called from a probe function and no spinlock is taken.
      
      The call chain is:
        rtw_pci_probe
          --> rtw_pci_setup_resource
            --> rtw_pci_init
              --> rtw_pci_init_trx_ring
                --> rtw_pci_init_tx_ring
                --> rtw_pci_init_rx_ring
      
      @@
      @@
      -    PCI_DMA_BIDIRECTIONAL
      +    DMA_BIDIRECTIONAL
      
      @@
      @@
      -    PCI_DMA_TODEVICE
      +    DMA_TO_DEVICE
      
      @@
      @@
      -    PCI_DMA_FROMDEVICE
      +    DMA_FROM_DEVICE
      
      @@
      @@
      -    PCI_DMA_NONE
      +    DMA_NONE
      
      @@
      expression e1, e2, e3;
      @@
      -    pci_alloc_consistent(e1, e2, e3)
      +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
      
      @@
      expression e1, e2, e3;
      @@
      -    pci_zalloc_consistent(e1, e2, e3)
      +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_free_consistent(e1, e2, e3, e4)
      +    dma_free_coherent(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_map_single(e1, e2, e3, e4)
      +    dma_map_single(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_unmap_single(e1, e2, e3, e4)
      +    dma_unmap_single(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4, e5;
      @@
      -    pci_map_page(e1, e2, e3, e4, e5)
      +    dma_map_page(&e1->dev, e2, e3, e4, e5)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_unmap_page(e1, e2, e3, e4)
      +    dma_unmap_page(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_map_sg(e1, e2, e3, e4)
      +    dma_map_sg(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_unmap_sg(e1, e2, e3, e4)
      +    dma_unmap_sg(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
      +    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_single_for_device(e1, e2, e3, e4)
      +    dma_sync_single_for_device(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
      +    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
      +    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2;
      @@
      -    pci_dma_mapping_error(e1, e2)
      +    dma_mapping_error(&e1->dev, e2)
      
      @@
      expression e1, e2;
      @@
      -    pci_set_dma_mask(e1, e2)
      +    dma_set_mask(&e1->dev, e2)
      
      @@
      expression e1, e2;
      @@
      -    pci_set_consistent_dma_mask(e1, e2)
      +    dma_set_coherent_mask(&e1->dev, e2)
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200820150643.148219-1-christophe.jaillet@wanadoo.fr
      24712ea9
    • Dinghao Liu's avatar
      wilc1000: Fix memleak in wilc_sdio_probe · 8d95ab34
      Dinghao Liu authored
      When devm_clk_get() returns -EPROBE_DEFER, sdio_priv
      should be freed just like when wilc_cfg80211_init()
      fails.
      
      Fixes: 8692b047 ("staging: wilc1000: look for rtc_clk clock")
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Acked-by: default avatarAjay Singh <ajay.kathat@microchip.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200820054819.23365-1-dinghao.liu@zju.edu.cn
      8d95ab34
    • Tetsuo Handa's avatar
      mwifiex: don't call del_timer_sync() on uninitialized timer · 621a3a8b
      Tetsuo Handa authored
      syzbot is reporting that del_timer_sync() is called from
      mwifiex_usb_cleanup_tx_aggr() from mwifiex_unregister_dev() without
      checking timer_setup() from mwifiex_usb_tx_init() was called [1].
      
      Ganapathi Bhat proposed a possibly cleaner fix, but it seems that
      that fix was forgotten [2].
      
      "grep -FrB1 'del_timer' drivers/ | grep -FA1 '.function)'" says that
      currently there are 28 locations which call del_timer[_sync]() only if
      that timer's function field was initialized (because timer_setup() sets
      that timer's function field). Therefore, let's use same approach here.
      
      [1] https://syzkaller.appspot.com/bug?id=26525f643f454dd7be0078423e3cdb0d57744959
      [2] https://lkml.kernel.org/r/CA+ASDXMHt2gq9Hy+iP_BYkWXsSreWdp3_bAfMkNcuqJ3K+-jbQ@mail.gmail.comReported-by: default avatarsyzbot <syzbot+dc4127f950da51639216@syzkaller.appspotmail.com>
      Cc: Ganapathi Bhat <ganapathi.bhat@nxp.com>
      Cc: Brian Norris <briannorris@chromium.org>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Reviewed-by: default avatarBrian Norris <briannorris@chromium.org>
      Acked-by: default avatarGanapathi Bhat <ganapathi.bhat@nxp.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200821082720.7716-1-penguin-kernel@I-love.SAKURA.ne.jp
      621a3a8b
    • Gustavo A. R. Silva's avatar
      mwifiex: Use fallthrough pseudo-keyword · 32f44730
      Gustavo A. R. Silva authored
      Replace the existing /* fall through */ comments and its variants with
      the new pseudo-keyword macro fallthrough[1].
      
      [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-throughSigned-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200821064720.GA22182@embeddedor
      32f44730
    • Christophe JAILLET's avatar
      mwifiex: Clean up some err and dbg messages · 5f8a3ed3
      Christophe JAILLET authored
      The error message if 'pci_set_consistent_dma_mask()' fails is misleading.
      The function call uses 32 bits, but the error message reports 64.
      
      Moreover, according to the comment above 'dma_set_mask_and_coherent()'
      definition, such an error can never happen.
      
      So, simplify code, axe the misleading message and use
      'dma_set_mask_and_coherent()' instead of 'dma_set_mask()' +
      'dma_set_coherent_mask()'
      
      While at it, make some clean-up:
         - add # when reporting allocated length to be consistent between
           functions
         - s/consistent/coherent/
         - s/unsigned int/u32/ to be consistent between functions
         - align some code
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200819071853.113185-1-christophe.jaillet@wanadoo.fr
      5f8a3ed3
    • Christophe JAILLET's avatar
      mwifiex: switch from 'pci_' to 'dma_' API · 4cf975f6
      Christophe JAILLET authored
      The wrappers in include/linux/pci-dma-compat.h should go away.
      
      The patch has been generated with the coccinelle script below and has been
      hand modified to replace GFP_ with a correct flag.
      It has been compile tested.
      
      When memory is allocated in 'mwifiex_pcie_alloc_buffers()' (see details in
      the call chain below) GFP_KERNEL can be used because both
      'mwifiex_register()' and 'mwifiex_reinit_sw()' already use GFP_KERNEL.
      (for 'mwifiex_reinit_sw()', it is hidden in a call to 'alloc_workqueue()')
      
      The call chain is:
        mwifiex_register
          --> mwifiex_init_pcie        (.init_if function, see mwifiex_if_ops)
         [ or ]
        mwifiex_reinit_sw
          -->mwifiex_pcie_up_dev       (.up_dev function, see mwifiex_if_ops)
      
          [ then in both case ]
            -->mwifiex_pcie_alloc_buffers
              --> mwifiex_pcie_create_txbd_ring
              --> mwifiex_pcie_create_rxbd_ring
              --> mwifiex_pcie_create_evtbd_ring
              --> mwifiex_pcie_alloc_sleep_cookie_buf
      
      @@
      @@
      -    PCI_DMA_BIDIRECTIONAL
      +    DMA_BIDIRECTIONAL
      
      @@
      @@
      -    PCI_DMA_TODEVICE
      +    DMA_TO_DEVICE
      
      @@
      @@
      -    PCI_DMA_FROMDEVICE
      +    DMA_FROM_DEVICE
      
      @@
      @@
      -    PCI_DMA_NONE
      +    DMA_NONE
      
      @@
      expression e1, e2, e3;
      @@
      -    pci_alloc_consistent(e1, e2, e3)
      +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
      
      @@
      expression e1, e2, e3;
      @@
      -    pci_zalloc_consistent(e1, e2, e3)
      +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_free_consistent(e1, e2, e3, e4)
      +    dma_free_coherent(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_map_single(e1, e2, e3, e4)
      +    dma_map_single(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_unmap_single(e1, e2, e3, e4)
      +    dma_unmap_single(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4, e5;
      @@
      -    pci_map_page(e1, e2, e3, e4, e5)
      +    dma_map_page(&e1->dev, e2, e3, e4, e5)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_unmap_page(e1, e2, e3, e4)
      +    dma_unmap_page(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_map_sg(e1, e2, e3, e4)
      +    dma_map_sg(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_unmap_sg(e1, e2, e3, e4)
      +    dma_unmap_sg(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
      +    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_single_for_device(e1, e2, e3, e4)
      +    dma_sync_single_for_device(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
      +    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
      +    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2;
      @@
      -    pci_dma_mapping_error(e1, e2)
      +    dma_mapping_error(&e1->dev, e2)
      
      @@
      expression e1, e2;
      @@
      -    pci_set_dma_mask(e1, e2)
      +    dma_set_mask(&e1->dev, e2)
      
      @@
      expression e1, e2;
      @@
      -    pci_set_consistent_dma_mask(e1, e2)
      +    dma_set_coherent_mask(&e1->dev, e2)
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200819070152.111522-1-christophe.jaillet@wanadoo.fr
      4cf975f6
  2. 18 Aug, 2020 34 commits