linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] Apple M1 (Pro/Max) NVMe driver
@ 2022-03-21 16:50 Sven Peter
  2022-03-21 16:50 ` [PATCH 1/9] dt-bindings: soc: apple: Add Apple SART Sven Peter
                   ` (9 more replies)
  0 siblings, 10 replies; 55+ messages in thread
From: Sven Peter @ 2022-03-21 16:50 UTC (permalink / raw)
  Cc: Sven Peter, Hector Martin, Alyssa Rosenzweig, Rob Herring,
	Arnd Bergmann, Keith Busch, Jens Axboe, Christoph Hellwig,
	Sagi Grimberg, Marc Zyngier, devicetree, linux-arm-kernel,
	linux-kernel, linux-nvme

Hi,

This series includes everything[*] required to get NVMe up and running on
Apple's M1, M1 Pro and M1 Max SoCs.

The NVMe controller on these machines is not attached to a PCI bus and
this driver originally started out when Arnd added platform support to
pci.c and I added the required Apple quirks. Christoph Hellwig stumbled
upon an early version and suggested to instead rewrite it as a
stand-alone driver since some of these quirks are rather awkward to
implement and would affect the hot path otherwise [1].

Here's the first version that creates apple.c to handle these weird NVMe
controllers. The following parts are included:

  - Device tree bindings: Since this is the first and probably only
    SoC that has NVMe outside of a PCIe bus I've put them into
    soc/apple. The same bindings are also used by u-boot and OpenBSD
    already.

  - SART address filter: Some of the buffers required by the NVMe
    controller sit behind a simple DMA address filter Apple calls
    SART. It allows to specify up to 16 physical address ranges
    that are allowed and will reject access to anything else.
    Unlike a real IOMMU there's no way to setup pagetables and
    also not all buffers are subject to this filtering. Most
    buffers used by the NVMe commands themselves use an integrated
    IOMMU instead.

  - RTKit IPC protocol: The NVMe controller is running a proprietary
    RTOS Apple calls RTKit and we need to communicate with it in order
    to bring up and use the NVMe controller. This communication happens
    over a mailbox interface that is already upstream. This protocol
    is also used for various other drivers present on these SoCs
    (SMC, display controller, Thunderbolt/USB4).

  - And finally the NVMe driver itself: The driver registers a platform
    device and is mainly based on pci.c with a few special Apple quirks.
    The biggest difference to normal NVMe (except for the missing PCI
    bus) is that command submission works differently: The SQ is
    replaced with a simple array and a command is triggered by writing
    its tag to a MMIO register. Additionally, the command must also be
    setup in the proprietary NVMMU before it can be submitted.
    There is some code duplication with pci.c for the setup of the PRPs.
    Depending on what you prefer this could be moved to a common file
    shared between pci.c and apple.c.

The hardware here is the same hardware that's already used in T2 Macs.
The only difference is that the T2 chip itself initializes the
controller, disable some quirks (the NVMMU and the weird submission
array) and then exposes it over a PCIe interface.

The driver itself has been successfully used by multiple people as
their daily driver for weeks at this point and no major issues have
been reported.
A smaller issue is that flushes on the devices take *much* longer than
expected. Jens Axboe has a workaround where the flushes are delayed but
that one isn't ready for submission yet.

Best,

Sven

[1] https://lore.kernel.org/linux-nvme/YRE7vCyn9d1ClhRm@infradead.org/
[*] The only missing part in this series are the device tree updates
    but since these will go through arm-soc anyway I haven't included
    them here but will instead submit them once this series is in a shape
    where it can be merged.

Hector Martin (2):
  nvme-apple: Add support for multiple power domains
  nvme-apple: Add support for suspend/resume

Jens Axboe (1):
  nvme-apple: Serialize command issue

Sven Peter (6):
  dt-bindings: soc: apple: Add Apple SART
  dt-bindings: soc: apple: Add ANS NVMe
  soc: apple: Always include Makefile
  soc: apple: Add SART driver
  soc: apple: Add RTKit IPC library
  nvme-apple: Add initial Apple SoC NVMe driver

 .../bindings/soc/apple/apple,nvme-ans.yaml    |   75 +
 .../bindings/soc/apple/apple,sart.yaml        |   52 +
 MAINTAINERS                                   |    3 +
 drivers/nvme/host/Kconfig                     |   12 +
 drivers/nvme/host/Makefile                    |    3 +
 drivers/nvme/host/apple.c                     | 1568 +++++++++++++++++
 drivers/soc/Makefile                          |    2 +-
 drivers/soc/apple/Kconfig                     |   24 +
 drivers/soc/apple/Makefile                    |    6 +
 drivers/soc/apple/rtkit-crashlog.c            |  147 ++
 drivers/soc/apple/rtkit-internal.h            |   76 +
 drivers/soc/apple/rtkit.c                     |  842 +++++++++
 drivers/soc/apple/sart.c                      |  318 ++++
 include/linux/soc/apple/rtkit.h               |  203 +++
 include/linux/soc/apple/sart.h                |   77 +
 15 files changed, 3407 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/soc/apple/apple,nvme-ans.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/apple/apple,sart.yaml
 create mode 100644 drivers/nvme/host/apple.c
 create mode 100644 drivers/soc/apple/rtkit-crashlog.c
 create mode 100644 drivers/soc/apple/rtkit-internal.h
 create mode 100644 drivers/soc/apple/rtkit.c
 create mode 100644 drivers/soc/apple/sart.c
 create mode 100644 include/linux/soc/apple/rtkit.h
 create mode 100644 include/linux/soc/apple/sart.h

-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

end of thread, other threads:[~2022-04-05 22:47 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 16:50 [PATCH 0/9] Apple M1 (Pro/Max) NVMe driver Sven Peter
2022-03-21 16:50 ` [PATCH 1/9] dt-bindings: soc: apple: Add Apple SART Sven Peter
2022-03-31 21:23   ` Rob Herring
2022-04-02 12:58     ` Sven Peter
2022-03-21 16:50 ` [PATCH 2/9] dt-bindings: soc: apple: Add ANS NVMe Sven Peter
2022-03-23 11:14   ` Krzysztof Kozlowski
2022-04-02 13:05     ` Sven Peter
2022-04-02 16:06       ` Krzysztof Kozlowski
2022-03-21 16:50 ` [PATCH 3/9] soc: apple: Always include Makefile Sven Peter
2022-03-21 16:50 ` [PATCH 4/9] soc: apple: Add SART driver Sven Peter
2022-03-21 17:07   ` Arnd Bergmann
2022-04-02 12:38     ` Sven Peter
2022-04-02 19:07       ` Arnd Bergmann
2022-04-04 14:58         ` Rob Herring
2022-04-04 15:01           ` Hector Martin
2022-04-05 15:37           ` Sven Peter
2022-03-21 17:17   ` Alyssa Rosenzweig
2022-04-02 12:40     ` Sven Peter
2022-03-21 16:50 ` [PATCH 5/9] soc: apple: Add RTKit IPC library Sven Peter
2022-03-22 13:13   ` Arnd Bergmann
2022-03-22 17:41     ` Robin Murphy
2022-04-02 12:56     ` Sven Peter
2022-04-02 18:30       ` Arnd Bergmann
2022-04-03 10:45         ` Sven Peter
2022-03-22 17:23   ` Alyssa Rosenzweig
2022-04-02 12:50     ` Sven Peter
2022-03-23 11:19   ` Krzysztof Kozlowski
2022-04-02 13:51     ` Sven Peter
2022-04-02 16:08       ` Krzysztof Kozlowski
2022-04-04 15:02       ` Rob Herring
2022-04-04 15:47         ` Hector Martin
2022-03-21 16:50 ` [PATCH 6/9] nvme-apple: Add initial Apple SoC NVMe driver Sven Peter
2022-03-21 17:01   ` Keith Busch
2022-04-02 13:10     ` Sven Peter
2022-03-22 13:38   ` Arnd Bergmann
2022-04-02 13:34     ` Sven Peter
2022-04-02 13:58       ` Janne Grunau
2022-04-02 14:02         ` Sven Peter
2022-04-02 21:26       ` Arnd Bergmann
2022-03-24  6:16   ` Christoph Hellwig
2022-04-02 12:47     ` Sven Peter
2022-04-04 15:57     ` Hector Martin
2022-04-04 15:59       ` Christoph Hellwig
2022-04-04 16:03         ` Sven Peter
2022-04-04 16:05           ` hch
2022-04-04 16:05         ` Hector Martin
2022-04-04 18:29         ` Jens Axboe
2022-04-05  6:24           ` Christoph Hellwig
2022-03-21 16:50 ` [PATCH 7/9] nvme-apple: Serialize command issue Sven Peter
2022-03-24  6:16   ` Christoph Hellwig
2022-04-02 12:42     ` Sven Peter
2022-03-21 16:50 ` [PATCH 8/9] nvme-apple: Add support for multiple power domains Sven Peter
2022-03-21 16:50 ` [PATCH 9/9] nvme-apple: Add support for suspend/resume Sven Peter
2022-03-24  6:17   ` Christoph Hellwig
2022-03-22 17:26 ` [PATCH 0/9] Apple M1 (Pro/Max) NVMe driver Alyssa Rosenzweig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).