1. 30 Sep, 2020 23 commits
  2. 29 Sep, 2020 17 commits
    • Armin Wolf's avatar
      lib8390: Replace panic() call with BUILD_BUG_ON · 2b2706aa
      Armin Wolf authored
      Replace panic() call in lib8390.c with BUILD_BUG_ON()
      since checking the size of struct e8390_pkt_hdr should
      happen at compile-time.
      Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2b2706aa
    • David S. Miller's avatar
      Merge branch 'net-in_interrupt-cleanup-and-fixes' · e6b6be53
      David S. Miller authored
      Thomas Gleixner says:
      
      ====================
      net: in_interrupt() cleanup and fixes
      
      in the discussion about preempt count consistency accross kernel configurations:
      
        https://lore.kernel.org/r/20200914204209.256266093@linutronix.de/
      
      Linus clearly requested that code in drivers and libraries which changes
      behaviour based on execution context should either be split up so that
      e.g. task context invocations and BH invocations have different interfaces
      or if that's not possible the context information has to be provided by the
      caller which knows in which context it is executing.
      
      This includes conditional locking, allocation mode (GFP_*) decisions and
      avoidance of code paths which might sleep.
      
      In the long run, usage of 'preemptible, in_*irq etc.' should be banned from
      driver code completely.
      
      This is the second version of the first batch of related changes. V1 can be
      found here:
      
           https://lore.kernel.org/r/20200927194846.045411263@linutronix.de
      
      Changes vs. V1:
      
        - Rebased to net-next
      
        - Fixed the half done rename sillyness in the ENIC patch.
      
        - Fixed the IONIC driver fallout.
      
        - Picked up the SFC fix from Edward and adjusted the GFP_KERNEL change
          accordingly.
      
        - Addressed the review comments vs. BCRFMAC.
      
        - Collected Reviewed/Acked-by tags as appropriate.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e6b6be53
    • Sebastian Andrzej Siewior's avatar
      net: rtlwifi: Replace in_interrupt() for context detection · 920872e0
      Sebastian Andrzej Siewior authored
      rtl_lps_enter() and rtl_lps_leave() are using in_interrupt() to detect
      whether it is safe to acquire a mutex or if it is required to defer to a
      workqueue.
      
      The usage of in_interrupt() in drivers is phased out and Linus clearly
      requested that code which changes behaviour depending on context should
      either be seperated or the context be conveyed in an argument passed by the
      caller, which usually knows the context.
      
      in_interrupt() also is only partially correct because it fails to chose the
      correct code path when just preemption or interrupts are disabled.
      
      Add an argument 'may_block' to both functions and adjust the callers to
      pass the context information.
      
      The following call chains were analyzed to be safe to block:
      
          rtl_watchdog_wq_callback()
            rlf_lps_leave/enter()
      
          rtl_op_suspend()
            rtl_lps_leave()
      
          rtl_op_bss_info_changed()
            rtl_lps_leave()
      
          rtl_op_sw_scan_start()
            rtl_lps_leave()
      
      The following call chains were analyzed to be unsafe to block:
      
          _rtl_pci_interrupt()
            _rtl_pci_rx_interrupt()
      	  rtl_lps_leave()
      
          _rtl_pci_interrupt()
            _rtl_pci_rx_interrupt()
              rtl_is_special_data()
      	  rtl_lps_leave()
      
          _rtl_pci_interrupt()
            _rtl_pci_rx_interrupt()
              rtl_is_special_data()
      	  setup_special_tx()
      	    rtl_lps_leave()
      
          _rtl_pci_interrupt()
            _rtl_pci_tx_isr
              rtl_lps_leave()
      
            halbtc_leave_lps()
              rtl_lps_leave()
      
      This leaves four callers of rtl_lps_enter/leave() where the analyzis
      stopped dead in the maze of several nested pointer based callchains and
      lack of rtlwifi hardware to debug this via tracing:
      
           halbtc_leave_lps(), halbtc_enter_lps(), halbtc_normal_lps(),
           halbtc_pre_normal_lps()
      
      These four have been cautionally marked to be unable to block which is the
      safe option, but the rtwifi wizards should be able to clarify that.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      920872e0
    • Sebastian Andrzej Siewior's avatar
      net: rtlwifi: Remove in_interrupt() from debug macro · e741751b
      Sebastian Andrzej Siewior authored
      The usage of in_interrupt() in drivers in is phased out.
      
      rtl_dbg() a printk based debug aid is using in_interrupt() in the
      underlying C function _rtl_dbg_out() which is almost identical to
      _rtl_dbg_print(). The only difference is the printout of in_interrupt().
      
      The decoding of in_interrupt() as hexvalue is non-trivial and aside of
      being phased out for driver usage the return value is just by chance the
      masked preempt count value and not a boolean.
      
      These home brewn printk debug aids are tedious to work with and provide
      only minimal context.  They should be replaced by trace_printk() or a debug
      tracepoint which automatically records all context information.
      
      To make progress on the in_interrupt() cleanup, make rtl_dbg() use
      _rtl_dbg_print() and remove _rtl_dbg_out().
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e741751b
    • Sebastian Andrzej Siewior's avatar
      net: rtlwifi: Remove void* casts related to delayed work · a3b7b227
      Sebastian Andrzej Siewior authored
      INIT_DELAYED_WORK() takes two arguments: A pointer to the delayed work and
      a function reference for the callback.
      
      The rtl code casts all function references to (void *) because the
      callbacks in use are not matching the required function signature. That's
      error prone and bad pratice.
      
      Some of the callback functions are also global, but only used in a single
      file.
      
      Clean the mess up by:
      
        - Adding the proper arguments to the callback functions and using them in
          the container_of() constructs correctly which removes the hideous
          container_of_dwork_rtl() macro as well.
      
        - Removing the type cast at the initializers
      
        - Making the unnecessary global functions static
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a3b7b227
    • Sebastian Andrzej Siewior's avatar
      net: libertas: Use netif_rx_any_context() · 021b58ef
      Sebastian Andrzej Siewior authored
      The usage of in_interrupt() in non-core code is phased out. Ideally the
      information of the calling context should be passed by the callers or the
      functions be split as appropriate.
      
      libertas uses in_interupt() to select the netif_rx*() variant which matches
      the calling context. The attempt to consolidate the code by passing an
      arguemnt or by distangling it failed due lack of knowledge about this
      driver and because the call chains are hard to follow.
      
      As a stop gap use netif_rx_any_context() which invokes the correct code
      path depending on context and confines the in_interrupt() usage to core
      code.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      021b58ef
    • Sebastian Andrzej Siewior's avatar
      net: libertas libertas_tf: Remove in_interrupt() from debug macro. · 8faee701
      Sebastian Andrzej Siewior authored
      The debug macro prints (INT) when in_interrupt() returns true. The value of
      this information is dubious as it does not distinguish between the various
      contexts which are covered by in_interrupt().
      
      As the usage of in_interrupt() in drivers is phased out and the same
      information can be more precisely obtained with tracing, remove the
      in_interrupt() conditional from this debug printk.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8faee701
    • Sebastian Andrzej Siewior's avatar
      net: mwifiex: Use netif_rx_any_context(). · d36981e0
      Sebastian Andrzej Siewior authored
      The usage of in_interrupt() in non-core code is phased out. Ideally the
      information of the calling context should be passed by the callers or the
      functions be split as appropriate.
      
      mwifiex uses in_interupt() to select the netif_rx*() variant which matches
      the calling context. The attempt to consolidate the code by passing an
      arguemnt or by distangling it failed due lack of knowledge about this
      driver and because the call chains are hard to follow.
      
      As a stop gap use netif_rx_any_context() which invokes the correct code
      path depending on context and confines the in_interrupt() usage to core
      code.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d36981e0
    • Sebastian Andrzej Siewior's avatar
      net: hostap: Remove in_interrupt() usage · 75fd2963
      Sebastian Andrzej Siewior authored
      in_interrupt() is ill defined and does not provide what the name
      suggests. The usage especially in driver code is deprecated and a tree wide
      effort to clean up and consolidate the (ab)usage of in_interrupt() and
      related checks is happening.
      
      hfa384x_cmd() and prism2_hw_reset() check in_interrupt() at function entry
      and if true emit a printk at debug loglevel and return. This is clearly debug
      code.
      
      Both functions invoke functions which can sleep. These functions already
      have appropriate debug checks which cover all invalid contexts, while
      in_interrupt() fails to detect context which just has preemption or
      interrupts disabled.
      
      Remove both checks as they are incomplete, debug only and already covered
      by the subsequently invoked functions properly. If called from invalid
      context the resulting back trace is definitely more helpful to analyze the
      problem than a printk at debug loglevel.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      75fd2963
    • Sebastian Andrzej Siewior's avatar
      net: iwlwifi: Remove in_interrupt() from tracing macro. · bd63bca5
      Sebastian Andrzej Siewior authored
      The usage of in_interrupt) in driver code is phased out.
      
      The iwlwifi_dbg tracepoint records in_interrupt() seperately, but that's
      superfluous because the trace header already records all kind of state and
      context information like hardirq status, softirq status, preemption count
      etc.
      
      Aside of that the recording of in_interrupt() as boolean does not allow to
      distinguish between the possible contexts (hard interrupt, soft interrupt,
      bottom half disabled) while the trace header gives precise information.
      
      Remove the duplicate information from the tracepoint and fixup the caller.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarLuca Coelho <luca@coelho.fi>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bd63bca5
    • Sebastian Andrzej Siewior's avatar
      net: ipw2x00,iwlegacy,iwlwifi: Remove in_interrupt() from debug macros · e4ff7d6b
      Sebastian Andrzej Siewior authored
      The usage of in_interrupt() in non-core code is phased out.
      
      The debugging macros in these drivers use in_interrupt() to print 'I' or
      'U' depending on the return value of in_interrupt(). While 'U' is confusing
      at best and 'I' is not really describing the actual context (hard interupt,
      soft interrupt, bottom half disabled section) these debug macros originate
      from the pre ftrace kernel era and their value today is questionable. They
      probably should be removed completely.
      
      The macros weere added initially for ipw2100 and then spreaded when the
      driver was forked.
      
      Remove the in_interrupt() usage at least..
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e4ff7d6b
    • Sebastian Andrzej Siewior's avatar
      net: brcmfmac: Convey allocation mode as argument · c597ede4
      Sebastian Andrzej Siewior authored
      The usage of in_interrupt() in drivers is phased out and Linus clearly
      requested that code which changes behaviour depending on context should
      either be seperated or the context be conveyed in an argument passed by the
      caller, which usually knows the context.
      
      brcmf_fweh_process_event() uses in_interrupt() to select the allocation
      mode GFP_KERNEL/GFP_ATOMIC. Aside of the above reasons this check is
      incomplete as it cannot detect contexts which just have preemption or
      interrupts disabled.
      
      All callchains leading to brcmf_fweh_process_event() can clearly identify
      the calling context. Convey a 'gfp' argument through the callchains and let
      the callers hand in the appropriate GFP mode.
      
      This has also the advantage that any change of execution context or
      preemption/interrupt state in these callchains will be detected by the
      memory allocator for all GFP_KERNEL allocations.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c597ede4
    • Thomas Gleixner's avatar
      net: brcmfmac: Convey execution context via argument to brcmf_netif_rx() · 687006e2
      Thomas Gleixner authored
      bcrmgf_netif_rx() uses in_interrupt to chose between netif_rx() and
      netif_rx_ni(). in_interrupt() usage in drivers is phased out.
      
      Convey the execution mode via an 'inirq' argument through the various
      callchains leading to brcmf_netif_rx():
      
      brcmf_pcie_isr_thread()		    <- Task context
        brcmf_proto_msgbuf_rx_trigger()
          brcmf_msgbuf_process_rx()
            brcmf_msgbuf_process_msgtype()
              brcmf_msgbuf_process_rx_complete()
      	  brcmf_netif_mon_rx()
      	     brcmf_netif_rx(isirq = false)
      	  brcmf_netif_rx(isirq = false)
      
      brcmf_sdio_readframes()  <- Task context sdio_claim_host() might sleep
        brcmf_rx_frame(isirq = false)
      
      brcmf_sdio_rxglom()      <- Task context sdio_claim_host() might sleep
        brcmf_rx_frame(isirq = false)
      
      brcmf_usb_rx_complete()  <- Interrupt context
        brcmf_rx_frame(isirq = true)
      
      brcmf_rx_frame()
        brcmf_proto_rxreorder()
          brcmf_proto_bcdc_rxreorder()
            brcmf_fws_rxreorder()
              brcmf_netif_rx()
            brcmf_netif_rx()
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
      Cc: Kalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      687006e2
    • Sebastian Andrzej Siewior's avatar
      net: brcmfmac: Replace in_interrupt() · d067c0fa
      Sebastian Andrzej Siewior authored
      brcmf_sdio_isr() is using in_interrupt() to distinguish if it is called
      from a interrupt service routine or from a worker thread.
      
      Passing such information from the calling context is preferred and
      requested by Linus, so add an argument `in_isr' to brcmf_sdio_isr() and let
      the callers pass the information about the calling context.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
      Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d067c0fa
    • Sebastian Andrzej Siewior's avatar
      net: wan/lmc: Remove lmc_trace() · c2f8c900
      Sebastian Andrzej Siewior authored
      lmc_trace() was first introduced in commit e7a392d5 ("Import
      2.3.99pre6-5") and was not touched ever since.
      
      The reason for looking at this was to get rid of the in_interrupt() usage,
      but while looking at it the following observations were made:
      
       - At least lmc_get_stats() (->ndo_get_stats()) is invoked with disabled
         preemption which is not detected by the in_interrupt() check, which
         would cause schedule() to be called from invalid context.
      
       - The code is hidden behind #ifdef LMC_TRACE which is not defined within
         the kernel and wasn't at the time it was introduced.
      
       - Three jiffies don't match 50ms. msleep() would be a better match which
         would also avoid the schedule() invocation. But why have it to begin
         with?
      
       - Nobody would do something like this today. Either netdev_dbg() or
         trace_printk() or a trace event would be used.  If only the functions
         related to this driver are interesting then ftrace can be used with
         filtering.
      
      As it is obviously broken for years, simply remove it.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c2f8c900
    • Sebastian Andrzej Siewior's avatar
      net: usb: net1080: Remove in_interrupt() comment · cfa1b493
      Sebastian Andrzej Siewior authored
      The comment above nc_vendor_write() suggests that the function could become
      async so that is usable in `in_interrupt()' context or that it already is
      safe to be called from such a context.
      
      Eitherway: The function did not become async since v2.4.9.2 (2002) and it
      must be not be called from `in_interrupt()' context because it sleeps on
      mutltiple occations.
      
      Remove the misleading comment.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cfa1b493
    • Sebastian Andrzej Siewior's avatar
      net: usb: kaweth: Remove last user of kaweth_control() · a19c2619
      Sebastian Andrzej Siewior authored
      kaweth_async_set_rx_mode() invokes kaweth_contol() and has two callers:
      
      - kaweth_open() which is invoked from preemptible context
      .
      - kaweth_start_xmit() which holds a spinlock and has bottom halfs disabled.
      
      If called from kaweth_start_xmit() kaweth_async_set_rx_mode() obviously
      cannot block, which means it can't call kaweth_control(). This is detected
      with an in_interrupt() check.
      
      Replace the in_interrupt() check in kaweth_async_set_rx_mode() with an
      argument which is set true by the caller if the context is safe to sleep,
      otherwise false.
      
      Now kaweth_control() is only called from preemptible context which means
      there is no need for GFP_ATOMIC allocations anymore. Replace it with
      usb_control_msg(). Cleanup the code a bit while at it.
      
      Finally remove kaweth_control() since the last user is gone.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a19c2619