1. 28 10月, 2016 1 次提交
    • R
      tty/serial: at91: fix hardware handshake on Atmel platforms · 9bcffe75
      Richard Genoud 提交于
      After commit 1cf6e8fc ("tty/serial: at91: fix RTS line management
      when hardware handshake is enabled"), the hardware handshake wasn't
      functional anymore on Atmel platforms (beside SAMA5D2).
      
      To understand why, one has to understand the flag ATMEL_US_USMODE_HWHS
      first:
      Before commit 1cf6e8fc ("tty/serial: at91: fix RTS line management
      when hardware handshake is enabled"), this flag was never set.
      Thus, the CTS/RTS where only handled by serial_core (and everything
      worked just fine).
      
      This commit introduced the use of the ATMEL_US_USMODE_HWHS flag,
      enabling it for all boards when the user space enables flow control.
      
      When the ATMEL_US_USMODE_HWHS is set, the Atmel USART controller
      handles a part of the flow control job:
      - disable the transmitter when the CTS pin gets high.
      - drive the RTS pin high when the DMA buffer transfer is completed or
        PDC RX buffer full or RX FIFO is beyond threshold. (depending on the
        controller version).
      
      NB: This feature is *not* mandatory for the flow control to work.
      (Nevertheless, it's very useful if low latencies are needed.)
      
      Now, the specifics of the ATMEL_US_USMODE_HWHS flag:
      
      - For platforms with DMAC and no FIFOs (sam9x25, sam9x35, sama5D3,
      sama5D4, sam9g15, sam9g25, sam9g35)* this feature simply doesn't work.
      ( source: https://lkml.org/lkml/2016/9/7/598 )
      Tested it on sam9g35, the RTS pins always stays up, even when RXEN=1
      or a new DMA transfer descriptor is set.
      => ATMEL_US_USMODE_HWHS must not be used for those platforms
      
      - For platforms with a PDC (sam926{0,1,3}, sam9g10, sam9g20, sam9g45,
      sam9g46)*, there's another kind of problem. Once the flag
      ATMEL_US_USMODE_HWHS is set, the RTS pin can't be driven anymore via
      RTSEN/RTSDIS in USART Control Register. The RTS pin can only be driven
      by enabling/disabling the receiver or setting RCR=RNCR=0 in the PDC
      (Receive (Next) Counter Register).
      => Doing this is beyond the scope of this patch and could add other
      bugs, so the original (and working) behaviour should be set for those
      platforms (meaning ATMEL_US_USMODE_HWHS flag should be unset).
      
      - For platforms with a FIFO (sama5d2)*, the RTS pin is driven according
      to the RX FIFO thresholds, and can be also driven by RTSEN/RTSDIS in
      USART Control Register. No problem here.
      (This was the use case of commit 1cf6e8fc ("tty/serial: at91: fix
      RTS line management when hardware handshake is enabled"))
      NB: If the CTS pin declared as a GPIO in the DTS, (for instance
      cts-gpios = <&pioA PIN_PB31 GPIO_ACTIVE_LOW>), the transmitter will be
      disabled.
      => ATMEL_US_USMODE_HWHS flag can be set for this platform ONLY IF the
      CTS pin is not a GPIO.
      
      So, the only case when ATMEL_US_USMODE_HWHS can be enabled is when
      (atmel_use_fifo(port) &&
       !mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS))
      
      Tested on all Atmel USART controller flavours:
      AT91SAM9G35-CM (DMAC flavour), AT91SAM9G20-EK (PDC flavour),
      SAMA5D2xplained (FIFO flavour).
      
      * the list may not be exhaustive
      
      Cc: <stable@vger.kernel.org> #4.4+ (beware, missing atmel_port variable)
      Fixes: 1cf6e8fc ("tty/serial: at91: fix RTS line management when hardware handshake is enabled")
      Signed-off-by: NRichard Genoud <richard.genoud@gmail.com>
      Acked-by: NAlexandre Belloni <alexandre.belloni@free-electrons.com>
      Acked-by: NCyrille Pitchen <cyrille.pitchen@atmel.com>
      Acked-by: NUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Acked-by: NNicolas Ferre <nicolas.ferre@atmel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9bcffe75
  2. 27 10月, 2016 14 次提交
  3. 12 10月, 2016 1 次提交
    • P
      kthread: kthread worker API cleanup · 3989144f
      Petr Mladek 提交于
      A good practice is to prefix the names of functions by the name
      of the subsystem.
      
      The kthread worker API is a mix of classic kthreads and workqueues.  Each
      worker has a dedicated kthread.  It runs a generic function that process
      queued works.  It is implemented as part of the kthread subsystem.
      
      This patch renames the existing kthread worker API to use
      the corresponding name from the workqueues API prefixed by
      kthread_:
      
      __init_kthread_worker()		-> __kthread_init_worker()
      init_kthread_worker()		-> kthread_init_worker()
      init_kthread_work()		-> kthread_init_work()
      insert_kthread_work()		-> kthread_insert_work()
      queue_kthread_work()		-> kthread_queue_work()
      flush_kthread_work()		-> kthread_flush_work()
      flush_kthread_worker()		-> kthread_flush_worker()
      
      Note that the names of DEFINE_KTHREAD_WORK*() macros stay
      as they are. It is common that the "DEFINE_" prefix has
      precedence over the subsystem names.
      
      Note that INIT() macros and init() functions use different
      naming scheme. There is no good solution. There are several
      reasons for this solution:
      
        + "init" in the function names stands for the verb "initialize"
          aka "initialize worker". While "INIT" in the macro names
          stands for the noun "INITIALIZER" aka "worker initializer".
      
        + INIT() macros are used only in DEFINE() macros
      
        + init() functions are used close to the other kthread()
          functions. It looks much better if all the functions
          use the same scheme.
      
        + There will be also kthread_destroy_worker() that will
          be used close to kthread_cancel_work(). It is related
          to the init() function. Again it looks better if all
          functions use the same naming scheme.
      
        + there are several precedents for such init() function
          names, e.g. amd_iommu_init_device(), free_area_init_node(),
          jump_label_init_type(),  regmap_init_mmio_clk(),
      
        + It is not an argument but it was inconsistent even before.
      
      [arnd@arndb.de: fix linux-next merge conflict]
       Link: http://lkml.kernel.org/r/20160908135724.1311726-1-arnd@arndb.de
      Link: http://lkml.kernel.org/r/1470754545-17632-3-git-send-email-pmladek@suse.comSuggested-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NPetr Mladek <pmladek@suse.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3989144f
  4. 10 10月, 2016 1 次提交
    • L
      printk: reinstate KERN_CONT for printing continuation lines · 4bcc595c
      Linus Torvalds 提交于
      Long long ago the kernel log buffer was a buffered stream of bytes, very
      much like stdio in user space.  It supported log levels by scanning the
      stream and noticing the log level markers at the beginning of each line,
      but if you wanted to print a partial line in multiple chunks, you just
      did multiple printk() calls, and it just automatically worked.
      
      Except when it didn't, and you had very confusing output when different
      lines got all mixed up with each other.  Then you got fragment lines
      mixing with each other, or with non-fragment lines, because it was
      traditionally impossible to tell whether a printk() call was a
      continuation or not.
      
      To at least help clarify the issue of continuation lines, we added a
      KERN_CONT marker back in 2007 to mark continuation lines:
      
        47492527 ("printk: add KERN_CONT annotation").
      
      That continuation marker was initially an empty string, and didn't
      actuall make any semantic difference.  But it at least made it possible
      to annotate the source code, and have check-patch notice that a printk()
      didn't need or want a log level marker, because it was a continuation of
      a previous line.
      
      To avoid the ambiguity between a continuation line that had that
      KERN_CONT marker, and a printk with no level information at all, we then
      in 2009 made KERN_CONT be a real log level marker which meant that we
      could now reliably tell the difference between the two cases.
      
        5fd29d6c ("printk: clean up handling of log-levels and newlines")
      
      and we could take advantage of that to make sure we didn't mix up
      continuation lines with lines that just didn't have any loglevel at all.
      
      Then, in 2012, the kernel log buffer was changed to be a "record" based
      log, where each line was a record that has a loglevel and a timestamp.
      
      You can see the beginning of that conversion in commits
      
        e11fea92 ("kmsg: export printk records to the /dev/kmsg interface")
        7ff9554b ("printk: convert byte-buffer to variable-length record buffer")
      
      with a number of follow-up commits to fix some painful fallout from that
      conversion.  Over all, it took a couple of months to sort out most of
      it.  But the upside was that you could have concurrent readers (and
      writers) of the kernel log and not have lines with mixed output in them.
      
      And one particular pain-point for the record-based kernel logging was
      exactly the fragmentary lines that are generated in smaller chunks.  In
      order to still log them as one recrod, the continuation lines need to be
      attached to the previous record properly.
      
      However the explicit continuation record marker that is actually useful
      for this exact case was actually removed in aroundm the same time by commit
      
        61e99ab8 ("printk: remove the now unnecessary "C" annotation for KERN_CONT")
      
      due to the incorrect belief that KERN_CONT wasn't meaningful.  The
      ambiguity between "is this a continuation line" or "is this a plain
      printk with no log level information" was reintroduced, and in fact
      became an even bigger pain point because there was now the whole
      record-level merging of kernel messages going on.
      
      This patch reinstates the KERN_CONT as a real non-empty string marker,
      so that the ambiguity is fixed once again.
      
      But it's not a plain revert of that original removal: in the four years
      since we made KERN_CONT an empty string again, not only has the format
      of the log level markers changed, we've also had some usage changes in
      this area.
      
      For example, some ACPI code seems to use KERN_CONT _together_ with a log
      level, and now uses both the KERN_CONT marker and (for example) a
      KERN_INFO marker to show that it's an informational continuation of a
      line.
      
      Which is actually not a bad idea - if the continuation line cannot be
      attached to its predecessor, without the log level information we don't
      know what log level to assign to it (and we traditionally just assigned
      it the default loglevel).  So having both a log level and the KERN_CONT
      marker is not necessarily a bad idea, but it does mean that we need to
      actually iterate over potentially multiple markers, rather than just a
      single one.
      
      Also, since KERN_CONT was still conceptually needed, and encouraged, but
      didn't actually _do_ anything, we've also had the reverse problem:
      rather than having too many annotations it has too few, and there is bit
      rot with code that no longer marks the continuation lines with the
      KERN_CONT marker.
      
      So this patch not only re-instates the non-empty KERN_CONT marker, it
      also fixes up the cases of bit-rot I noticed in my own logs.
      
      There are probably other cases where KERN_CONT will be needed to be
      added, either because it is new code that never dealt with the need for
      KERN_CONT, or old code that has bitrotted without anybody noticing.
      
      That said, we should strive to avoid the need for KERN_CONT.  It does
      result in real problems for logging, and should generally not be seen as
      a good feature.  If we some day can get rid of the feature entirely,
      because nobody does any fragmented printk calls, that would be lovely.
      
      But until that point, let's at mark the code that relies on the hacky
      multi-fragment kernel printk's.  Not only does it avoid the ambiguity,
      it also annotates code as "maybe this would be good to fix some day".
      
      (That said, particularly during single-threaded bootup, the downsides of
      KERN_CONT are very limited.  Things get much hairier when you have
      multiple threads going on and user level reading and writing logs too).
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4bcc595c
  5. 30 9月, 2016 1 次提交
  6. 28 9月, 2016 4 次提交
  7. 27 9月, 2016 11 次提交
  8. 22 9月, 2016 7 次提交