Skip to content
  1. Apr 25, 2018
    • Eric W. Biederman's avatar
      signal/microblaze: Use force_sig_fault where appropriate · 6f467986
      Eric W. Biederman authored
      
      
      Filling in struct siginfo before calling force_sig_info a tedious and
      error prone process, where once in a great while the wrong fields
      are filled out, and siginfo has been inconsistently cleared.
      
      Simplify this process by using the helper force_sig_fault.  Which
      takes as a parameters all of the information it needs, ensures
      all of the fiddly bits of filling in struct siginfo are done properly
      and then calls force_sig_info.
      
      In short about a 5 line reduction in code for every time force_sig_info
      is called, which makes the calling function clearer.
      
      Cc: Michal Simek <monstr@monstr.eu>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      6f467986
    • Eric W. Biederman's avatar
      signal/microblaze: Remove the commented out force_sig_info in do_page_fault · ceb91ed1
      Eric W. Biederman authored
      
      
      Remove the commented out call to force_sig_info right after a call to
      _exception in do_page_fault.  The function _exception does exactly the
      work the commented out code does so there is no reason for the
      commented out code.
      
      Cc: Michal Simek <monstr@monstr.eu>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      ceb91ed1
    • Eric W. Biederman's avatar
      signal/m68k: Use force_sig_fault where appropriate · 3c67075d
      Eric W. Biederman authored
      
      
      Filling in struct siginfo before calling force_sig_info a tedious and
      error prone process, where once in a great while the wrong fields
      are filled out, and siginfo has been inconsistently cleared.
      
      Simplify this process by using the helper force_sig_fault.  Which
      takes as a parameters all of the information it needs, ensures
      all of the fiddly bits of filling in struct siginfo are done properly
      and then calls force_sig_info.
      
      In short about a 5 line reduction in code for every time force_sig_info
      is called, which makes the calling function clearer.
      
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: linux-m68k@lists.linux-m68k.org
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      3c67075d
    • Eric W. Biederman's avatar
      signal/hexagon: Use force_sig_fault as appropriate · 1a4bd979
      Eric W. Biederman authored
      
      
      Filling in struct siginfo before calling force_sig_info a tedious and
      error prone process, where once in a great while the wrong fields
      are filled out, and siginfo has been inconsistently cleared.
      
      Simplify this process by using the helper force_sig_fault.  Which
      takes as a parameters all of the information it needs, ensures
      all of the fiddly bits of filling in struct siginfo are done properly
      and then calls force_sig_info.
      
      In short about a 5 line reduction in code for every time force_sig_info
      is called, which makes the calling function clearer.
      
      Cc: Richard Kuo <rkuo@codeaurora.org>
      Cc: linux-hexagon@vger.kernel.org
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      1a4bd979
    • Eric W. Biederman's avatar
      signal/c6x: Use force_sig_fault where appropriate · 559f9008
      Eric W. Biederman authored
      
      
      Filling in struct siginfo before calling force_sig_info a tedious and
      error prone process, where once in a great while the wrong fields
      are filled out, and siginfo has been inconsistently cleared.
      
      Simplify this process by using the helper force_sig_fault.  Which
      takes as a parameters all of the information it needs, ensures
      all of the fiddly bits of filling in struct siginfo are done properly
      and then calls force_sig_info.
      
      In short about a 5 line reduction in code for every time force_sig_info
      is called, which makes the calling function clearer.
      
      Cc: Mark Salter <msalter@redhat.com>
      Cc: Aurelien Jacquiot <jacquiot.aurelien@gmail.com>
      Cc: linux-c6x-dev@linux-c6x.org
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      559f9008
    • Eric W. Biederman's avatar
      signal/alpha: Use force_sig_fault where appropriate · e4d90ee3
      Eric W. Biederman authored
      
      
      Filling in struct siginfo before calling force_sig_info a tedious and
      error prone process, where once in a great while the wrong fields
      are filled out, and siginfo has been inconsistently cleared.
      
      Simplify this process by using the helper force_sig_fault.  Which
      takes as a parameters all of the information it needs, ensures
      all of the fiddly bits of filling in struct siginfo are done properly
      and then calls force_sig_info.
      
      In short about a 5 line reduction in code for every time force_sig_info
      is called, which makes the calling function clearer.
      
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: linux-alpha@vger.kernel.org
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      e4d90ee3
    • Eric W. Biederman's avatar
      signal/alpha: Use send_sig_fault where appropriate · 5f50245b
      Eric W. Biederman authored
      
      
      Filling in struct siginfo before calling send_sig_info a tedious and
      error prone process, where once in a great while the wrong fields
      are filled out, and siginfo has been inconsistently cleared.
      
      Simplify this process by using the helper send_sig_fault.  Which
      takes as a parameters all of the information it needs, ensures
      all of the fiddly bits of filling in struct siginfo are done properly
      and then calls send_sig_info.
      
      In short about a 5 line reduction in code for every time send_sig_info
      is called, which makes the calling function clearer.
      
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: linux-alpha@vger.kernel.org
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      5f50245b
    • Eric W. Biederman's avatar
      signal/powerpc: Replace TRAP_FIXME with TRAP_UNK · e821fa42
      Eric W. Biederman authored
      Using an si_code of 0 that aliases with SI_USER is clearly the wrong
      thing todo, and causes problems in interesting ways.
      
      For use in unknown_exception the recently defined TRAP_UNK
      semantically is a perfect fit.  For use in RunModeException it looks
      like something more specific than TRAP_UNK could be used.  No one has
      bothered to find a better fit than the broken si_code of 0 in all of
      these years and I don't see an obvious better fit so TRAP_UNK is
      switching RunModeException to return TRAP_UNK is clearly an
      improvement.
      
      Recent history suggests no actually cares about crazy corner
      cases of the kernel behavior like this so I don't expect any
      regressions from changing this.  However if something does
      happen this change is easy to revert.
      
      Though I wonder if SIGKILL might not be a better fit.
      
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Kumar Gala <kumar.gala@freescale.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Fixes: 9bad068c24d7 ("[PATCH] ppc32: support for e500 and 85xx")
      Fixes: 0ed70f6105ef ("PPC32: Provide proper siginfo information on various exceptions.")
      History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
      
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      e821fa42
    • Eric W. Biederman's avatar
      signal/alpha: Replace TRAP_FIXME with TRAP_UNK · 535906c6
      Eric W. Biederman authored
      Using an si_code of 0 that aliases with SI_USER is clearly the wrong
      thing to do, and causes problems in interesting ways.
      
      For it really is not clear to me if using TRAP_UNK bugcheck or
      the default case of gentrap is really the best way to handle
      things.  There is certainly enough information that that a more
      specific si_code could potentially be used.  That said TRAP_UNK
      is definitely an improvement over 0 as it removes the ambiguiuty
      of what si_code of 0 with SIGTRAP means on alpha.
      
      Recent history suggests no actually cares about crazy corner cases of
      the kernel behavior like this so I don't expect any regressions from
      changing this.  However if something does happen this change is easy
      to revert.
      
      Cc: Helge Deller <deller@gmx.de>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: linux-alpha@vger.kernel.org
      Fixes: 0a635c7a84cf ("Fill in siginfo_t.")
      History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
      
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      535906c6
    • Eric W. Biederman's avatar
      signal: Add TRAP_UNK si_code for undiagnosted trap exceptions · db78e6a0
      Eric W. Biederman authored
      
      
      Both powerpc and alpha have cases where they wronly set si_code to 0
      in combination with SIGTRAP and don't mean SI_USER.
      
      About half the time this is because the architecture can not report
      accurately what kind of trap exception triggered the trap exception.
      The other half the time it looks like no one has bothered to
      figure out an appropriate si_code.
      
      For the cases where the architecture does not have enough information
      or is too lazy to figure out exactly what kind of trap exception
      it is define TRAP_UNK.
      
      Cc: linux-api@vger.kernel.org
      Cc: linux-arch@vger.kernel.org
      Cc: linux-alpha@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      db78e6a0
    • Eric W. Biederman's avatar
      signal/unicore32: Use FPE_FLTUNK instead of 0 in ucf64_raise_sigfpe · d8f7f322
      Eric W. Biederman authored
      
      
      The si_code of 0 (aka SI_USER) has fields si_pid and si_uid not
      si_addr so it so only by luck would the appropriate fields by copied
      to userspace by copy_siginfo_to_user.
      
      This is just broken and wrong.
      
      Make it obvious what is happening by moving the si_code from a
      parameter of the one call to ucf64_raise_sigfpe to a constant value
      that info.si_code gets set to.
      
      Explicitly set the si_code to FPE_FLTUNK the newly reserved floating
      point si_code for an unknown floating point exception.
      
      It looks like there is a fair chance that this is a code path that has
      never been used in real life on unicore32.  The bad si_code and the
      print statement that calls it an unhandled exception.  So I really
      don't expect anyone will mind if this just gets fixed.
      
      In similar situations on more popular architectures the conclusion was
      just fix it.
      
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Fixes: d9bc1579 ("unicore32 additional architecture files: float point handling")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      d8f7f322
    • Eric W. Biederman's avatar
      signal/powerpc: Replace FPE_FIXME with FPE_FLTUNK · aeb1c0f6
      Eric W. Biederman authored
      Using an si_code of 0 that aliases with SI_USER is clearly the
      wrong thing todo, and causes problems in interesting ways.
      
      The newly defined FPE_FLTUNK semantically appears to fit the
      bill so use it instead.
      
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Kumar Gala <kumar.gala@freescale.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc:  linuxppc-dev@lists.ozlabs.org
      Fixes: 9bad068c24d7 ("[PATCH] ppc32: support for e500 and 85xx")
      Fixes: 0ed70f6105ef ("PPC32: Provide proper siginfo information on various exceptions.")
      History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
      
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      aeb1c0f6
    • Eric W. Biederman's avatar
      signal/ia64: Replace FPE_FIXME with FPE_FLTUNK · 51dd709f
      Eric W. Biederman authored
      
      
      Using an si_code of 0 that aliases with SI_USER is clearly the wrong
      thing todo, and causes problems in interesting ways.
      
      The newly defined FPE_FLTUNK semantically appears to fit the bill so
      use it instead.
      
      Given recent experience in this area odds are it will not
      break anything.  Fixing it removes a hazard to kernel maintenance.
      
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: linux-ia64@vger.kernel.org
      Fixes: 987159266c45 ("Linux version 2.3.48")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      51dd709f
    • Eric W. Biederman's avatar
      signal/alpha: Replace FPE_FIXME with FPE_FLTUNK · 4cc13e4f
      Eric W. Biederman authored
      Using an si_code of 0 that aliases with SI_USER is clearly the wrong
      thing todo, and causes problems in interesting ways.
      
      The newly defined FPE_FLTUNK semantically appears to fit the bill so
      use it instead.
      
      Given recent experience in this area odds are it will not break
      anything.  Fixing it removes a hazard to kernel maintenance.
      
      Cc: Helge Deller <deller@gmx.de>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: linux-alpha@vger.kernel.org
      History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
      
      
      Fixes: 0a635c7a84cf ("Fill in siginfo_t.")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      4cc13e4f
    • Eric W. Biederman's avatar
      signal: Ensure every siginfo we send has all bits initialized · 3eb0f519
      Eric W. Biederman authored
      
      
      Call clear_siginfo to ensure every stack allocated siginfo is properly
      initialized before being passed to the signal sending functions.
      
      Note: It is not safe to depend on C initializers to initialize struct
      siginfo on the stack because C is allowed to skip holes when
      initializing a structure.
      
      The initialization of struct siginfo in tracehook_report_syscall_exit
      was moved from the helper user_single_step_siginfo into
      tracehook_report_syscall_exit itself, to make it clear that the local
      variable siginfo gets fully initialized.
      
      In a few cases the scope of struct siginfo has been reduced to make it
      clear that siginfo siginfo is not used on other paths in the function
      in which it is declared.
      
      Instances of using memset to initialize siginfo have been replaced
      with calls clear_siginfo for clarity.
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      3eb0f519
    • Eric W. Biederman's avatar
      signal/nds32: Use force_sig(SIGILL) in do_revisn · f6ed1eca
      Eric W. Biederman authored
      
      
      As originally committed do_revisn would deliver a siginfo for SIGILL
      with an si_code composed of random stack contents.  That makes no
      sense and is not something userspace can depend on.  So simplify
      the code and just use "force_sig(SIG_ILL, current)" instead.
      
      Fixes: 2923f5ea ("nds32: Exception handling")
      Cc: Vincent Chen <vincentc@andestech.com>
      Cc: Greentime Hu <greentime@andestech.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      f6ed1eca
    • Eric W. Biederman's avatar
      signal/nds32: Use force_sig in unhandled_interruption and unhandled_exceptions · be5c2ff0
      Eric W. Biederman authored
      
      
      Neither unhandled_interrupt nor unhandled_exceptions fills in any of the
      siginfo fields whend sending SIGKILL.  Further because it is SIGKILL
      even if all of the fields were filled out appropriately it would be impossible
      for the process to read any of the siginfo fields.  So simplfy things and
      just use force_sig instead of force_sig_info.
      
      Fixes: 2923f5ea ("nds32: Exception handling")
      Cc: Vincent Chen <vincentc@andestech.com>
      Cc: Greentime Hu <greentime@andestech.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarVincent Chen <vincentc@andestech.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      be5c2ff0
  2. Apr 19, 2018
    • Eric W. Biederman's avatar
      signal/sh: Use force_sig_fault in hw_breakpoint_handler · 195bce73
      Eric W. Biederman authored
      
      
      The call chain is:
      breakpoint
        notify_die
          hw_breakpoint_exceptions_notify
            hw_breakpoint_handler
      
      So the signal number can only be SIGTRAP.
      
      In hw_breakpoint_handler rc is either NOTIFY_STOP or NOTIF_DONE
      both of which notifier_to_errno converts to 0.  So si_errno is 0.
      
      Historically si_addr was left unitialized in struct siginfo which is a
      bug.  There appears to be no consensus among the various architectures
      which value should be in si_addr.  So since no usable value has
      been returned up to this point return NULL in si_addr.
      
      Fixes: 4352fc1b ("sh: Abstracted SH-4A UBC support on hw-breakpoint core.")
      Fixes: 34d0b5af ("sh: Convert ptrace to hw_breakpoint API.")
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: linux-sh@vger.kernel.org
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      195bce73
    • Dmitry V. Levin's avatar
      sparc: fix compat siginfo ABI regression · 32772c9e
      Dmitry V. Levin authored
      Starting with commit v4.14-rc1~60^2^2~1, a SIGFPE signal sent via kill
      results to wrong values in si_pid and si_uid fields of compat siginfo_t.
      
      This happens due to FPE_FIXME being defined to 0 for sparc, and at the
      same time siginfo_layout() introduced by the same commit returns
      SIL_FAULT for SIGFPE if si_code == SI_USER and FPE_FIXME is defined to 0.
      
      Fix this regression by removing FPE_FIXME macro and changing all its users
      to assign FPE_FLTUNK to si_code instead of FPE_FIXME.
      
      Note that FPE_FLTUNK is a new macro introduced by commit
      266da65e.
      
      Tested with commit v4.16-11958-g16e205cf42da.
      
      This bug was found by strace test suite.
      
      In the discussion about FPE_FLTUNK on sparc David Miller said:
      > Eric, feel free to do something similar on Sparc.
      
      Link: https://github.com/strace/strace/issues/21
      
      
      Fixes: cc731525 ("signal: Remove kernel interal si_code magic")
      Fixes: 2.3.41
      Cc: David Miller <davem@davemloft.net>
      Cc: sparclinux@vger.kernel.org
      Conceptually-Acked-By: default avatarDavid Miller <davem@davemloft.net>
      Thanks-to: Anatoly Pugachev <matorola@gmail.com>
      Signed-off-by: default avatarDmitry V. Levin <ldv@altlinux.org>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      32772c9e
  3. Apr 17, 2018
  4. Apr 14, 2018
  5. Apr 13, 2018
    • Michael Ellerman's avatar
      powerpc/64s: Fix CPU_FTRS_ALWAYS vs DT CPU features · 81b654c2
      Michael Ellerman authored
      
      
      The cpu_has_feature() mechanism has an optimisation where at build
      time we construct a mask of the CPU feature bits that will always be
      true for the given .config, based on the platform/bitness/etc. that we
      are building for.
      
      That is incompatible with DT CPU features, where the set of CPU
      features is dependent on feature flags that are given to us by
      firmware.
      
      The result is that some feature bits can not be *disabled* by DT CPU
      features. Or more accurately, they can be disabled but they will still
      appear in the ALWAYS mask, meaning cpu_has_feature() will always
      return true for them.
      
      In the past this hasn't really been a problem because on Book3S
      64 (where we support DT CPU features), the set of ALWAYS bits has been
      very small. That was because we always built for POWER4 and later,
      meaning the set of common bits was small.
      
      The only bit that could be cleared by DT CPU features that was also in
      the ALWAYS mask was CPU_FTR_NODSISRALIGN, and that was only used in
      the alignment handler to create a fake DSISR. That code was itself
      deleted in 31bfdb03 ("powerpc: Use instruction emulation
      infrastructure to handle alignment faults") (Sep 2017).
      
      However the set of ALWAYS features changed with the recent commit
      db5ae1c1 ("powerpc/64s: Refine feature sets for little endian
      builds") which restricted the set of feature flags when building
      little endian to Power7 or later. That caused the ALWAYS mask to
      become much larger for little endian builds.
      
      The result is that the following feature bits can currently not
      be *disabled* by DT CPU features:
      
        CPU_FTR_REAL_LE, CPU_FTR_MMCRA, CPU_FTR_CTRL, CPU_FTR_SMT,
        CPU_FTR_PURR, CPU_FTR_SPURR, CPU_FTR_DSCR, CPU_FTR_PKEY,
        CPU_FTR_VMX_COPY, CPU_FTR_CFAR, CPU_FTR_HAS_PPR.
      
      To fix it we need to mask the set of ALWAYS features with the base set
      of DT CPU features, ie. the features that are always enabled by DT CPU
      features. That way there are no bits in the ALWAYS mask that are not
      also always set by DT CPU features.
      
      Fixes: db5ae1c1 ("powerpc/64s: Refine feature sets for little endian builds")
      Reviewed-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      81b654c2
  6. Apr 12, 2018
    • Thomas Petazzoni's avatar
      arch/sh: pcie-sh7786: handle non-zero DMA offset · bf9c7e3d
      Thomas Petazzoni authored
      
      
      On SuperH, the base of the physical memory might be different from
      zero. In this case, PCI address zero will map to a non-zero physical
      address. In order to make sure that the DMA mapping API takes care of
      this DMA offset, we must fill in the dev->dma_pfn_offset field for PCI
      devices. This gets done in the pcibios_bus_add_device() hook, called
      for each new PCI device detected.
      
      The dma_pfn_offset global variable is re-calculated for every PCI
      controller available on the platform, but that's not an issue because
      its value will each time be exactly the same, as it only depends on
      the memory start address and memory size.
      
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarRich Felker <dalias@libc.org>
      bf9c7e3d
    • Thomas Petazzoni's avatar
      arch/sh: pcie-sh7786: adjust the memory mapping · 79e1c5e7
      Thomas Petazzoni authored
      
      
      The code setting up the PCI -> SuperHighway mapping doesn't take into
      account the fact that the address stored in PCIELARx must be aligned
      with the size stored in PCIELAMRx.
      
      For example, when your physical memory starts at 0x0800_0000 (128 MB),
      a size of 64 MB or 128 MB is fine. However, if you have 256 MB of
      memory, it doesn't work because the base address is not aligned on the
      size.
      
      In such situation, we have to round down the base address to make sure
      it is aligned on the size of the area. For for a 0x0800_0000 base
      address with 256 MB of memory, we will round down to 0x0, and extend
      the size of the mapping to 512 MB.
      
      This allows the mapping to work on platforms that have 256 MB of
      RAM. The current setup would only work with 128 MB of RAM or less.
      
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarRich Felker <dalias@libc.org>
      79e1c5e7
    • Thomas Petazzoni's avatar
      arch/sh: pcie-sh7786: adjust PCI MEM and IO regions · 5da1bb96
      Thomas Petazzoni authored
      
      
      The current definition of the PCIe IO and MEM resources for SH7786
      doesn't match what the datasheet says. For example, for PCIe0
      0xfe100000 is advertised by the datasheet as a PCI IO region, while
      0xfd000000 is advertised as a PCI MEM region. The code currently
      inverts the two.
      
      The SH4A_PCIEPARL and SH4A_PCIEPTCTLR registers allow to define the
      base address and role of the different regions (including whether it's
      a MEM or IO region). However, practical experience on a SH7786 shows
      that if 0xfe100000 is used for LEL and 0xfd000000 for IO, a PCIe
      device using two MEM BARs cannot be accessed at all. Simply using
      0xfe100000 for IO and 0xfd000000 for MEM makes the PCIe device
      accessible.
      
      It is very likely that this was never seen because there are two other
      PCI MEM region listed in the resources. However, for different
      reasons, none of the two other MEM regions are usable on the specific
      SH7786 platform the problem was encountered. Therefore, the last MEM
      region at 0xfe100000 was used to place the BARs, making the device
      non-functional.
      
      This commit therefore adjusts those PCI MEM and IO resources
      definitions so that they match what the datasheet says. They have only
      been tested with PCIe 0.
      
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarRich Felker <dalias@libc.org>
      5da1bb96
    • Thomas Petazzoni's avatar
      arch/sh: pcie-sh7786: exclude unusable PCI MEM areas · d62e9bf5
      Thomas Petazzoni authored
      
      
      Depending on the physical memory layout, some PCI MEM areas are not
      usable. According to the SH7786 datasheet, the PCI MEM area from
      1000_0000 to 13FF_FFFF is only usable if the physical memory layout
      (in MMSELR) is 1, 2, 5 or 6. In all other configurations, this PCI MEM
      area is not usable (because it overlaps with DRAM).
      
      Therefore, this commit adjusts the PCI SH7786 initialization to mark
      the relevant PCI resource as IORESOURCE_DISABLED if we can't use it.
      
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarRich Felker <dalias@libc.org>
      d62e9bf5
    • Thomas Petazzoni's avatar
      arch/sh: pcie-sh7786: mark unavailable PCI resource as disabled · 7dd7f698
      Thomas Petazzoni authored
      
      
      Some PCI MEM resources are marked as IORESOURCE_MEM_32BIT, which means
      they are only usable when the SH core runs in 32-bit mode. In 29-bit
      mode, such memory regions are not usable.
      
      The existing code for SH7786 properly skips such regions when
      configuring the PCIe controller registers. However, because such
      regions are still described in the resource array, the
      pcibios_scanbus() function in the SuperH pci.c will register them to
      the PCI core. Due to this, the PCI core will allocate MEM areas from
      this resource, and assign BARs pointing to this area, even though it's
      unusable.
      
      In order to prevent this from happening, we mark such regions as
      IORESOURCE_DISABLED, which tells the SuperH pci.c pcibios_scanbus()
      function to skip them.
      
      Note that we separate marking the region as disabled from skipping it,
      because other regions will be marked as disabled in follow-up patches.
      
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarRich Felker <dalias@libc.org>
      7dd7f698
    • Thomas Petazzoni's avatar
      arch/sh: pci: don't use disabled resources · 3aeb93a0
      Thomas Petazzoni authored
      
      
      In pcibios_scanbus(), we provide to the PCI core the usable MEM and IO
      regions using pci_add_resource_offset(). We travel through all
      resources available in the "struct pci_channel".
      
      Also, in register_pci_controller(), we travel through all resources to
      request them, making sure they don't conflict with already requested
      resources.
      
      However, some resources may be disabled, in which case they should not
      be requested nor provided to the PCI core.
      
      In the current situation, none of the resources are disabled. However,
      follow-up patches in this series will make some resources disabled,
      making this preliminary change necessary.
      
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarRich Felker <dalias@libc.org>
      3aeb93a0
    • Thomas Petazzoni's avatar
      arch/sh: make the DMA mapping operations observe dev->dma_pfn_offset · ce883130
      Thomas Petazzoni authored
      
      
      Some devices may have a non-zero DMA offset, i.e an offset between the
      DMA address and the physical address. Such an offset can be encoded
      into the dma_pfn_offset field of "struct device", but the SuperH
      implementation of the DMA mapping API does not observe this
      information.
      
      This commit fixes that by ensuring the DMA address is properly
      calculated depending on this DMA offset.
      
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarRich Felker <dalias@libc.org>
      ce883130
Loading