1. 25 8月, 2021 2 次提交
  2. 27 7月, 2021 1 次提交
    • N
      s390: make PCI mio support a machine flag · 3322ba0d
      Niklas Schnelle 提交于
      Kernel support for the newer PCI mio instructions can be toggled off
      with the pci=nomio command line option which needs to integrate with
      common code PCI option parsing. However this option then toggles static
      branches which can't be toggled yet in an early_param() call.
      
      Thus commit 9964f396 ("s390: fix setting of mio addressing control")
      moved toggling the static branches to the PCI init routine.
      
      With this setup however we can't check for mio support outside the PCI
      code during early boot, i.e. before switching the static branches, which
      we need to be able to export this as an ELF HWCAP.
      
      Improve on this by turning mio availability into a machine flag that
      gets initially set based on CONFIG_PCI and the facility bit and gets
      toggled off if pci=nomio is found during PCI option parsing allowing
      simple access to this machine flag after early init.
      Reviewed-by: NHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      3322ba0d
  3. 30 4月, 2021 1 次提交
  4. 12 4月, 2021 4 次提交
    • N
      s390/pci: narrow scope of zpci_configure_device() · 61311e32
      Niklas Schnelle 提交于
      Currently zpci_configure_device() can be called on a zPCI function in
      two completely different states. Either the underlying zPCI function has
      already been configured by the platform and we are only doing the
      scanning to get it usable by Linux drivers. Or the underlying function
      is in Standby and we first do an SCLP to get it configured. This makes
      zpci_configure_device() harder to reason about. Since calling
      zpci_configure_device() on a function in Standby only happens in
      enable_slot() simply pull out the SCLP call and setting of zdev->state
      and thus call zpci_configure_device() under the same circumstances as
      in the event handling code.
      Reviewed-by: NMatthew Rosato <mjrosato@linux.ibm.com>
      Reviewed-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      61311e32
    • N
      s390/pci: separate zbus registration from scanning · 14c87ba8
      Niklas Schnelle 提交于
      Now that the zbus can be created without being scanned we can go one
      step further and make registering a device to a zbus independent from
      scanning it. This way the zbus handling becomes much more natural
      in that functions can be registered on the zbus to be scanned later more
      closely resembling the handling of both real PCI hardware and other
      virtual PCI busses like Hyper-V's virtual PCI bus (see for example
      drivers/pci/controller/pci-hyperv.c:create_root_hv_pci_bus()).
      
      Having zbus registration separate from scanning allows us to return
      fully initialized but still disabled zdevs from zpci_create_device()
      which can then be configured just as we would configure a zdev from
      standby (minus the SCLP Configure already done by the platform).  There
      is still the exception that a PCI function with non-zero devfn can be
      plugged before its PCI bus, which depends on the function with zero
      devfn, is created. In this case the zdev returend from
      zpci_create_device() is still missing its bus, hotplug slot, and
      resources which need to be created later but at least it doesn't wait in
      the enabled state and can otherwise be treated as initialized.
      
      With this we also separate the initial PCI scan using CLP List PCI
      Functions into two phases. In the CLP loop's callback we only register
      each function with a virtual zbus creating the latter as needed. Then,
      after we have built this virtual PCI topology based on our list of
      zbusses, we can make use of the common code functionality to scan each
      complete zbus as a separate child bus.
      Reviewed-by: NMatthew Rosato <mjrosato@linux.ibm.com>
      Acked-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      14c87ba8
    • N
      s390/pci: separate zbus creation from scanning · a50297cf
      Niklas Schnelle 提交于
      In the existing code the creation of the PCI bus and the scanning of
      function zero all happens in zpci_scan_bus(). This in turn requires
      functions to be enabled and their resources to be available before the
      PCI bus is even created.
      
      This not only means that functions are enabled long before they are
      actually made available to the common PCI subsystem. In case of
      functions with non-zero devfn which appeared before the function with
      devfn zero they can wait arbitrarily long in this enabled but not
      scanned state.
      
      Fix this by separating the creation of the PCI bus from scanning it and
      only prepare, that is enable and setup MMIO bus resources, functions
      just before they are scanned. As they may be scanned multiple times
      track if we already created resources in the zdev.
      Reviewed-by: NMatthew Rosato <mjrosato@linux.ibm.com>
      Acked-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      a50297cf
    • N
      s390/pci: introduce zpci_bus_scan_device() · faf29a4d
      Niklas Schnelle 提交于
      To match zpci_bus_scan_device() and the PCI common code terminology and
      to remove some code duplication, we pull the multiple uses of
      pci_scan_single_device() into a function. For now this has the side
      effect of adding each device to the PCI bus separately and locking and
      unlocking the rescan/remove lock for each instead of just once per bus.
      This is clearly less efficient but provides a correct intermediate
      behavior until a follow on change does both the adding and scanning only
      once per bus.
      Reviewed-by: NMatthew Rosato <mjrosato@linux.ibm.com>
      Acked-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      faf29a4d
  5. 22 3月, 2021 4 次提交
  6. 16 3月, 2021 1 次提交
    • N
      s390/pci: fix leak of PCI device structure · 0b13525c
      Niklas Schnelle 提交于
      In commit 05bc1be6 ("s390/pci: create zPCI bus") we removed the
      pci_dev_put() call matching the earlier pci_get_slot() done as part of
      __zpci_event_availability(). This was based on the wrong understanding
      that the device_put() done as part of pci_destroy_device() would counter
      the pci_get_slot() when it only counters the initial reference. This
      same understanding and existing bad example also lead to not doing
      a pci_dev_put() in zpci_remove_device().
      
      Since releasing the PCI devices, unlike releasing the PCI slot, does not
      print any debug message for testing I added one in pci_release_dev().
      This revealed that we are indeed leaking the PCI device on PCI
      hotunplug. Further testing also revealed another missing pci_dev_put() in
      disable_slot().
      
      Fix this by adding the missing pci_dev_put() in disable_slot() and fix
      zpci_remove_device() with the correct pci_dev_put() calls. Also instead
      of calling pci_get_slot() in __zpci_event_availability() to determine if
      a PCI device is registered and then doing the same again in
      zpci_remove_device() do this once in zpci_remove_device() which makes
      sure that the pdev in __zpci_event_availability() is only used for the
      result of pci_scan_single_device() which does not need a reference count
      decremnt as its ownership goes to the PCI bus.
      
      Also move the check if zdev->zbus->bus is set into zpci_remove_device()
      since it may be that we're removing a device with devfn != 0 which never
      had a PCI bus. So we can still set the pdev->error_state to indicate
      that the device is not usable anymore, add a flag to set the error state.
      
      Fixes: 05bc1be6 ("s390/pci: create zPCI bus")
      Cc: <stable@vger.kernel.org> # 5.8+: e1bff843 s390/pci: remove superfluous zdev->zbus check
      Cc: <stable@vger.kernel.org> # 5.8+: ba764dd7 s390/pci: refactor zpci_create_device()
      Cc: <stable@vger.kernel.org> # 5.8+
      Reviewed-by: NMatthew Rosato <mjrosato@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      0b13525c
  7. 09 2月, 2021 1 次提交
    • N
      s390/pci: refactor zpci_create_device() · ba764dd7
      Niklas Schnelle 提交于
      Currently zpci_create_device() is only called in clp_add_pci_device()
      which allocates the memory for the struct zpci_dev being created. There
      is little separation of concerns as only both functions together can
      create a zpci_dev and the only CLP specific code in
      clp_add_pci_device() is a call to clp_query_pci_fn().
      
      Improve this by removing clp_add_pci_device() and refactor
      zpci_create_device() such that it alone creates and initializes the
      zpci_dev given the FID and Function Handle. For this we need to make
      clp_query_pci_fn() non-static. While at it remove the function handle
      parameter since we can just take that from the zpci_dev. Also move
      adding to the zpci_list to after the zdev has been fully created which
      eliminates a window where a partially initialized zdev can be found by
      get_zdev_by_fid().
      Acked-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      ba764dd7
  8. 18 11月, 2020 1 次提交
  9. 14 9月, 2020 4 次提交
    • N
      s390/pci: remove unused function zpci_rescan() · 2bce60b5
      Niklas Schnelle 提交于
      the only caller of this was removed as part of the suspend/resume
      removal so no need to keep this function around.
      Reviewed-by: NMatthew Rosato <mjrosato@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      2bce60b5
    • N
      s390/pci: consolidate SR-IOV specific code · abb95b75
      Niklas Schnelle 提交于
      currently we have multiple #ifdef CONFIG_PCI_IOV blocks spread over
      different compliation units and headers, all dealing with SR-IOV
      specific behavior.
      This violates the style guide which discourages conditionally compiled
      code blocks and hinders maintainability by speading SR-IOV functionality
      over many files.
      
      Let's move all of this into a conditionally compiled pci_iov.c file and
      local header and prefix SR-IOV specific functions with zpci_iov_*.
      Reviewed-by: NMatthew Rosato <mjrosato@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      abb95b75
    • N
      s390/pci: Implement ioremap_wc/prot() with MIO · b02002cc
      Niklas Schnelle 提交于
      With our current support for the new MIO PCI instructions, write
      combining/write back MMIO memory can be obtained via the pci_iomap_wc()
      and pci_iomap_wc_range() functions.
      This is achieved by using the write back address for a specific bar
      as provided in clp_store_query_pci_fn()
      
      These functions are however not widely used and instead drivers often
      rely on ioremap_wc() and ioremap_prot(), which on other platforms enable
      write combining using a PTE flag set through the pgrprot value.
      
      While we do not have a write combining flag in the low order flag bits
      of the PTE like x86_64 does, with MIO support, there is a write back bit
      in the physical address (bit 1 on z15) and thus also the PTE.
      Which bit is used to toggle write back and whether it is available at
      all, is however not fixed in the architecture. Instead we get this
      information from the CLP Store Logical Processor Characteristics for PCI
      command. When the write back bit is not provided we fall back to the
      existing behavior.
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Reviewed-by: NPierre Morel <pmorel@linux.ibm.com>
      Reviewed-by: NGerald Schaefer <gerald.schaefer@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      b02002cc
    • N
      s390/pci: fix leak of DMA tables on hard unplug · afdf9550
      Niklas Schnelle 提交于
      commit f606b3ef ("s390/pci: adapt events for zbus") removed the
      zpci_disable_device() call for a zPCI event with PEC 0x0304 because
      the device is already deconfigured by the platform.
      This however skips the Linux side of the disable in particular it leads
      to leaking the DMA tables and bitmaps because zpci_dma_exit_device() is
      never called on the device.
      
      If the device transitions to the Reserved state we call zpci_zdev_put()
      but zpci_release_device() will not call zpci_disable_device() because
      the state of the zPCI function is already ZPCI_FN_STATE_STANDBY.
      
      If the device is put into the Standby state, zpci_disable_device() is
      not called and the device is assumed to have been put in Standby through
      platform action.
      At this point the device may be removed by a subsequent event with PEC
      0x0308 or 0x0306 which calls zpci_zdev_put() with the same problem
      as above or the device may be configured again in which case
      zpci_disable_device() is also not called.
      
      Fix this by calling zpci_disable_device() explicitly for PEC 0x0304 as
      before. To make it more clear that zpci_disable_device() may be called,
      even if the lower level device has already been disabled by the
      platform, add a comment to zpci_disable_device().
      
      Cc: <stable@vger.kernel.org> # 5.8
      Fixes: f606b3ef ("s390/pci: adapt events for zbus")
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      afdf9550
  10. 17 8月, 2020 2 次提交
    • N
      s390/pci: fix PF/VF linking on hot plug · b97bf44f
      Niklas Schnelle 提交于
      Currently there are four places in which a PCI function is scanned
      and made available to drivers:
       1. In pci_scan_root_bus() as part of the initial zbus
          creation.
       2. In zpci_bus_add_devices() when registering
          a device in configured state on a zbus that has already been
          scanned.
       3. When a function is already known to zPCI (in reserved/standby state)
          and configuration is triggered through firmware by PEC 0x301.
       4. When a device is already known to zPCI (in standby/reserved state)
          and configuration is triggered from within Linux using
          enable_slot().
      
      The PF/VF linking step and setting of pdev->is_virtfn introduced with
      commit e5794cf1 ("s390/pci: create links between PFs and VFs") was
      only triggered for the second case, which is where VFs created through
      sriov_numvfs usually land. However unlike some other platforms but like
      POWER VFs can be individually enabled/disabled through
      /sys/bus/pci/slots.
      
      Fix this by doing VF setup as part of pcibios_bus_add_device() which is
      called in all of the above cases.
      
      Finally to remove the PF/VF links call the common code
      pci_iov_remove_virtfn() function to remove linked VFs.
      This takes care of the necessary sysfs cleanup.
      
      Fixes: e5794cf1 ("s390/pci: create links between PFs and VFs")
      Cc: <stable@vger.kernel.org> # 5.8: 2f0230b2: s390/pci: re-introduce zpci_remove_device()
      Cc: <stable@vger.kernel.org> # 5.8
      Acked-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      b97bf44f
    • N
      s390/pci: re-introduce zpci_remove_device() · 2f0230b2
      Niklas Schnelle 提交于
      For fixing the PF to VF link removal we need to perform some action on
      every removal of a zdev from the common PCI subsystem.
      So in preparation re-introduce zpci_remove_device() and use that instead
      of directly calling the common code functions. This  was actually still
      declared from earlier code but no longer implemented.
      Reviewed-by: NPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <hca@linux.ibm.com>
      2f0230b2
  11. 20 5月, 2020 1 次提交
  12. 28 4月, 2020 3 次提交
    • P
      s390/pci: Handling multifunctions · 44510d6f
      Pierre Morel 提交于
      We allow multiple functions on a single bus.
      We suppress the ZPCI_DEVFN definition and replace its
      occurences with zpci->devfn.
      
      We verify the number of device during the registration.
      
      There can never be more domains in use than existing
      devices, so we do not need to verify the count of domain
      after having verified the count of devices.
      Signed-off-by: NPierre Morel <pmorel@linux.ibm.com>
      Reviewed-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      44510d6f
    • P
      s390/pci: create zPCI bus · 05bc1be6
      Pierre Morel 提交于
      The zPCI bus is in charge to handle common zPCI resources for
      zPCI devices.
      
      Creating the zPCI bus, the PCI bus, the zPCI devices and the
      PCI devices and hotplug slots
      done in a specific order:
      - PCI hotplug slot creation needs a PCI bus
      - PCI bus needs a PCI domain
        which is reported by the pci_domain_nr() when setting up the
        host bridge
      - PCI domain is set from the zPCI with devfn 0
        this is necessary to have a reproducible enumeration
      
      Therefore we can not create devices or hotplug slots for any PCI
      device associated with a zPCI device before having discovered
      the function zero of the bus.
      
      The discovery and initialization of devices can be done at several
      points in the code:
      - On Events, serialized in a thread context
      - On initialization, in the kernel init thread context
      - When powering on the hotplug slot, in a user thread context
      
      The removal of devices and their parent bus may also be done on
      events or for devices when powering down the slot.
      
      To guarantee the existence of the bus and devices until they are
      no more needed we use kref in zPCI bus and introduce a reference
      count in the zPCI devices.
      
      In this patch the zPCI bus still only accept a device with
      a devfn 0.
      Signed-off-by: NPierre Morel <pmorel@linux.ibm.com>
      Reviewed-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      05bc1be6
    • P
      s390/pci: define kernel parameters for PCI multifunction · 6cf17f9a
      Pierre Morel 提交于
      Using PCI multifunctions in S390 is a new feature we may want
      to ignore to continue provide the same topology as in the past
      to userland even if the configuration supports exposing the
      topology of a multi-Function device.
      
      A new boolean parameters allows to overwrite the kernel
      pci configuration:
      
      - pci=norid when on, disallow the use a new firmware field,
        RID, which provides the PCI <bus>:<device>.<function> part
        of the PCI address.
      
      To be used in the following patches and satisfy the checkpatch.pl
      the variable is exposed in pci.h
      Signed-off-by: NPierre Morel <pmorel@linux.ibm.com>
      Reviewed-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      6cf17f9a
  13. 23 3月, 2020 3 次提交
  14. 04 3月, 2020 1 次提交
  15. 22 1月, 2020 1 次提交
    • N
      s390/pci: Recover handle in clp_set_pci_fn() · 17cdec96
      Niklas Schnelle 提交于
      When we try to recover a PCI function using
      
          echo 1 > /sys/bus/pci/devices/<id>/recover
      
      or manually with
      
          echo 1 > /sys/bus/pci/devices/<id>/remove
          echo 0 > /sys/bus/pci/slots/<slot>/power
          echo 1 > /sys/bus/pci/slots/<slot>/power
      
      clp_disable_fn() / clp_enable_fn() call clp_set_pci_fn() to first
      disable and then reenable the function.
      
      When the function is already in the requested state we may be left with
      an invalid function handle.
      
      To get a new valid handle we do a clp_list_pci() call. For this we need
      both the function ID and function handle in clp_set_pci_fn() so pass the
      zdev and get both.
      
      To simplify things also pull setting the refreshed function handle into
      clp_set_pci_fn()
      Signed-off-by: NNiklas Schnelle <schnelle@linux.ibm.com>
      Reviewed-by: NPeter Oberparleiter <oberpar@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      17cdec96
  16. 30 11月, 2019 2 次提交
  17. 14 10月, 2019 1 次提交
  18. 21 8月, 2019 1 次提交
  19. 12 7月, 2019 1 次提交
  20. 04 7月, 2019 1 次提交
  21. 28 5月, 2019 1 次提交
  22. 29 4月, 2019 3 次提交