Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Documentation/devicetree/bindings/display/apple,dcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,42 @@ properties:
- iommus
additionalProperties: false

apple,no-shared-display-dart:
type: boolean
description:
The external coprocessor's display DART must stay out of the display
subsystem's IOMMU domain. Framebuffers are mirrored through the fbdma
child instead, which must be present.

apple,t8122-dcpext-firmware-ready:
$ref: /schemas/types.yaml#/definitions/uint32
enum: [1, 2]
description:
Set by the boot loader on a T8122 external coprocessor whose firmware
it has reserved. 2 is the boot loader's default. 1 is set only when
the owner asked for the coprocessor in the boot loader configuration,
because kernels that share the display DART unconditionally accept 1
and nothing else.

fbdma:
type: object
description:
The display DART stream an external coprocessor scans framebuffers
through, with the display subsystem's DVA window.
properties:
iommus:
maxItems: 1
apple,dma-range:
$ref: /schemas/types.yaml#/definitions/uint64-array
description:
Base and size of the display subsystem's DVA window on this stream.
minItems: 2
maxItems: 2
required:
- iommus
- apple,dma-range
additionalProperties: false

panel:
type: object
properties:
Expand Down
88 changes: 88 additions & 0 deletions arch/arm64/boot/dts/apple/t8122-j615.dts
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,91 @@
};

#include "hwmon-laptop.dtsi"

/*
* External display on both USB-C ports, wired as on the J613 (see
* t8122-j613.dts): usb-pd@c is USB-C Left-back (typec0, ATC0) and usb-pd@a is
* USB-C Left-front (typec1, ATC1). Everything stays disabled until the boot
* loader marks the dcpext firmware reserved and the display gate enables it.
*
* fbdma is the display DART stream the dcpext scans framebuffers through,
* with the display subsystem's DVA window: on the J615 the gate must not add
* dispext0_dart to the display subsystem (apple,no-shared-display-dart), so
* appledrm mirrors framebuffers there instead.
*/
/ {
aliases {
dcpext = &dcpext;
};
};

&dcpext {
apple,connector-type = "USB-C";
phys = <&atcphy0 PHY_TYPE_DP>, <&atcphy1 PHY_TYPE_DP>;
phy-names = "typec0", "typec1";
mux-controls = <&atcphy0_xbar 0>, <&atcphy1_xbar 0>;
mux-control-names = "typec0", "typec1";
apple,typec-mux-indices = <2 2>;
apple,typec-dptx-phys = <0 1>;
/* RTKit quirks of AsahiLinux/linux#607 (syslog/ioreport acks, kdebug). */
apple,sync-syslog-ack;
apple,no-shared-display-dart;

fbdma {
iommus = <&dispext0_dart 0>;
apple,dma-range = /bits/ 64 <0x10000000000 0x1000000000>;
};

typec-routes {
#address-cells = <1>;
#size-cells = <0>;

route@0 {
reg = <0>;
mode-switch;
status = "disabled";

port {
dcpext_typec0: endpoint {
remote-endpoint = <&typec0_dcpext>;
};
};
};

route@1 {
reg = <1>;
mode-switch;
status = "disabled";

port {
dcpext_typec1: endpoint {
remote-endpoint = <&typec1_dcpext>;
};
};
};
};
};

&typec0 {
ports {
port@3 {
reg = <3>;

typec0_dcpext: endpoint {
remote-endpoint = <&dcpext_typec0>;
};
};
};
};

&typec1 {
ports {
port@3 {
reg = <3>;

typec1_dcpext: endpoint {
remote-endpoint = <&dcpext_typec1>;
};
};
};
};
34 changes: 34 additions & 0 deletions drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,39 @@ static int apple_drm_gem_dumb_create(struct drm_file *file_priv,
return drm_gem_dma_dumb_create_internal(file_priv, drm, args);
}

/*
* A T8122 dcpext mirrors framebuffers into its own display DART domain.
* Remove a buffer's mirror before its pages and its DVA are released.
*/
static void apple_drm_gem_free(struct drm_gem_object *gem)
{
struct drm_crtc *crtc;

drm_for_each_crtc(crtc, gem->dev)
dcp_fb_unmirror(to_apple_crtc(crtc)->dcp, to_drm_gem_dma_obj(gem));
drm_gem_dma_object_free(gem);
}

static const struct drm_gem_object_funcs apple_drm_gem_funcs = {
.free = apple_drm_gem_free,
.print_info = drm_gem_dma_object_print_info,
.get_sg_table = drm_gem_dma_object_get_sg_table,
.vmap = drm_gem_dma_object_vmap,
.mmap = drm_gem_dma_object_mmap,
.vm_ops = &drm_gem_dma_vm_ops,
};

static struct drm_gem_object *apple_drm_gem_create_object(struct drm_device *drm,
size_t size)
{
struct drm_gem_dma_object *obj = kzalloc_obj(*obj);

if (!obj)
return ERR_PTR(-ENOMEM);
obj->base.funcs = &apple_drm_gem_funcs;
return &obj->base;
}

#ifdef CONFIG_DRM_FBDEV_EMULATION
static int apple_drm_fbdev_probe(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
Expand Down Expand Up @@ -205,6 +238,7 @@ static const struct drm_driver apple_drm_driver = {
DRM_FBDEV_DMA_DRIVER_OPS,
#endif
.postclose = apple_drm_postclose,
.gem_create_object = apple_drm_gem_create_object,
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.major = 1,
Expand Down
13 changes: 13 additions & 0 deletions drivers/gpu/drm/apple/dcp-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/ioport.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/xarray.h>
#include <linux/spinlock.h>
#include <linux/mux/consumer.h>
#include <linux/phy/phy.h>
Expand Down Expand Up @@ -231,6 +232,18 @@ struct apple_dcp {
struct platform_device *piodma;
bool piodma_created;
struct iommu_domain *iommu_dom;
/*
* J615 dcpext: a child device on the display DART stream the external
* pipe scans framebuffers through. Framebuffers are mirrored into its
* domain at the display subsystem's addresses. fb_mirrors holds the
* mapped length of every mirrored GEM object, indexed by the object's
* address, until the object is freed; fb_mirror_lock protects it and
* fb_dom.
*/
struct platform_device *fbdma;
struct iommu_domain *fb_dom;
struct xarray fb_mirrors;
struct mutex fb_mirror_lock;
/* which of the nine cumulative A031 notify-client states to send next */
unsigned int a031_step;
struct apple_rtkit *rtk;
Expand Down
Loading