mutex_lock(&mode_config->mutex);
drm_connector_list_iter_begin(dev, &iter);
drm_for_each_connector_iter(connector, &iter)
amdgpu_connector_hotplug(connector);
drm_connector_list_iter_end(&iter);
mutex_unlock(&mode_config->mutex); /* Just fire off a uevent and let userspace tell us what to do */
drm_helper_hpd_irq_event(dev);
}
for (i = 0; i < work->shared_count; ++i) if (amdgpu_display_flip_handle_fence(work, &work->shared[i])) return;
/* Wait until we're out of the vertical blank period before the one *targetedbytheflip
*/ if (amdgpu_crtc->enabled &&
(amdgpu_display_get_crtc_scanoutpos(adev_to_drm(adev), work->crtc_id, 0,
&vpos, &hpos, NULL, NULL,
&crtc->hwmode)
& (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK)) ==
(DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK) &&
(int)(work->target_vblank -
amdgpu_get_vblank_counter_kms(crtc)) > 0) {
schedule_delayed_work(&work->flip_work, usecs_to_jiffies(1000)); return;
}
/* We borrow the event spin lock for protecting flip_status */
spin_lock_irqsave(&crtc->dev->event_lock, flags);
/* Do the flip (mmio) */
adev->mode_info.funcs->page_flip(adev, work->crtc_id, work->base, work->async);
/* Set the flip status */
amdgpu_crtc->pflip_status = AMDGPU_FLIP_SUBMITTED;
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
/* unpin of the old buffer */
r = amdgpu_bo_reserve(work->old_abo, true); if (likely(r == 0)) {
amdgpu_bo_unpin(work->old_abo);
amdgpu_bo_unreserve(work->old_abo);
} else
DRM_ERROR("failed to reserve buffer after flip\n");
/* pin the new buffer */
r = amdgpu_bo_reserve(new_abo, false); if (unlikely(r != 0)) {
DRM_ERROR("failed to reserve new abo buffer before flip\n"); goto cleanup;
}
if (!adev->enable_virtual_display) {
new_abo->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
r = amdgpu_bo_pin(new_abo,
amdgpu_display_supported_domains(adev, new_abo->flags)); if (unlikely(r != 0)) {
DRM_ERROR("failed to pin new abo buffer before flip\n"); goto unreserve;
}
}
r = amdgpu_ttm_alloc_gart(&new_abo->tbo); if (unlikely(r != 0)) {
DRM_ERROR("%p bind failed\n", new_abo); goto unpin;
}
r = dma_resv_get_fences(new_abo->tbo.base.resv, DMA_RESV_USAGE_WRITE,
&work->shared_count,
&work->shared); if (unlikely(r != 0)) {
DRM_ERROR("failed to get fences for buffer\n"); goto unpin;
}
pflip_cleanup: if (unlikely(amdgpu_bo_reserve(new_abo, false) != 0)) {
DRM_ERROR("failed to reserve new abo in error path\n"); goto cleanup;
}
unpin: if (!adev->enable_virtual_display)
amdgpu_bo_unpin(new_abo);
unreserve:
amdgpu_bo_unreserve(new_abo);
cleanup:
amdgpu_bo_unref(&work->old_abo); for (i = 0; i < work->shared_count; ++i)
dma_fence_put(work->shared[i]);
kfree(work->shared);
kfree(work);
return r;
}
int amdgpu_display_crtc_set_config(struct drm_mode_set *set, struct drm_modeset_acquire_ctx *ctx)
{ struct drm_device *dev; struct amdgpu_device *adev; struct drm_crtc *crtc; bool active = false; int ret;
if (!set || !set->crtc) return -EINVAL;
dev = set->crtc->dev;
ret = pm_runtime_get_sync(dev->dev); if (ret < 0) goto out;
ret = drm_crtc_helper_set_config(set, ctx);
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) if (crtc->enabled)
active = true;
pm_runtime_mark_last_busy(dev->dev);
adev = drm_to_adev(dev); /* if we have active crtcs and we don't have a power ref, *takethecurrentone
*/ if (active && !adev->have_disp_power_ref) {
adev->have_disp_power_ref = true; return ret;
} /* if we have no active crtcs, then go to *dropthepowerrefwegotbefore
*/ if (!active && adev->have_disp_power_ref)
adev->have_disp_power_ref = false;
out: /* drop the power reference we got coming in here */
pm_runtime_put_autosuspend(dev->dev); return ret;
}
/* on hw with routers, select right port */ if (amdgpu_connector->router.ddc_valid)
amdgpu_i2c_router_select_ddc_port(amdgpu_connector);
if (use_aux)
ret = i2c_transfer(&amdgpu_connector->ddc_bus->aux.ddc, msgs, 2); else
ret = i2c_transfer(&amdgpu_connector->ddc_bus->adapter, msgs, 2);
if (ret != 2) /* Couldn't find an accessible DDC on this connector */ returnfalse; /* Probe also for valid EDID header *EDIDheaderstartswith: *0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00. *Onlythefirst6bytesmustbevalidas *drm_edid_block_valid()canfixthelast2bytes
*/ if (drm_edid_header_is_valid(buf) < 6) { /* Couldn't find an accessible EDID on this *connector
*/ returnfalse;
} returntrue;
}
if (AMD_FMT_MOD_GET(DCC_RETILE, modifier)) return lookup_format_info(dcc_retile_formats,
ARRAY_SIZE(dcc_retile_formats),
format);
if (AMD_FMT_MOD_GET(DCC, modifier)) return lookup_format_info(dcc_formats, ARRAY_SIZE(dcc_formats),
format);
/* returning NULL will cause the default format structs to be used. */ return NULL;
}
/* *TriestoextracttherenderableDCCoffsetfromtheopaquemetadataattached *tothebuffer.
*/ staticint
extract_render_dcc_offset(struct amdgpu_device *adev, struct drm_gem_object *obj,
uint64_t *offset)
{ struct amdgpu_bo *rbo; int r = 0;
uint32_t metadata[10]; /* Something that fits a descriptor + header. */
uint32_t size;
rbo = gem_to_amdgpu_bo(obj);
r = amdgpu_bo_reserve(rbo, false);
if (unlikely(r)) { /* Don't show error message when returning -ERESTARTSYS */ if (r != -ERESTARTSYS)
DRM_ERROR("Unable to reserve buffer: %d\n", r); return r;
}
r = amdgpu_bo_get_metadata(rbo, metadata, sizeof(metadata), &size, NULL);
amdgpu_bo_unreserve(rbo);
if (rfb->base.pitches[plane] % block_pitch) {
drm_dbg_kms(rfb->base.dev, "pitch %d for plane %d is not a multiple of block pitch %d\n",
rfb->base.pitches[plane], plane, block_pitch); return -EINVAL;
} if (rfb->base.pitches[plane] < min_pitch) {
drm_dbg_kms(rfb->base.dev, "pitch %d for plane %d is less than minimum pitch %d\n",
rfb->base.pitches[plane], plane, min_pitch); return -EINVAL;
}
/* Force at least natural alignment. */ if (rfb->base.offsets[plane] % block_size) {
drm_dbg_kms(rfb->base.dev, "offset 0x%x for plane %d is not a multiple of block pitch 0x%x\n",
rfb->base.offsets[plane], plane, block_size); return -EINVAL;
}
if (rfb->base.obj[0]->size < size) {
drm_dbg_kms(rfb->base.dev, "BO size 0x%zx is less than 0x%llx required for plane %d\n",
rfb->base.obj[0]->size, size, plane); return -EINVAL;
}
rbo = gem_to_amdgpu_bo(amdgpu_fb->base.obj[0]);
r = amdgpu_bo_reserve(rbo, false);
if (unlikely(r)) { /* Don't show error message when returning -ERESTARTSYS */ if (r != -ERESTARTSYS)
DRM_ERROR("Unable to reserve buffer: %d\n", r); return r;
}
rfb->base.obj[0] = obj;
drm_helper_mode_fill_fb_struct(dev, &rfb->base, info, mode_cmd); /* Verify that the modifier is supported. */ if (!drm_any_plane_has_format(dev, mode_cmd->pixel_format,
mode_cmd->modifier[0])) {
drm_dbg_kms(dev, "unsupported pixel format %p4cc / modifier 0x%llx\n",
&mode_cmd->pixel_format, mode_cmd->modifier[0]);
ret = -EINVAL; goto err;
}
ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj); if (ret) goto err;
if (drm_drv_uses_atomic_modeset(dev))
ret = drm_framebuffer_init(dev, &rfb->base,
&amdgpu_fb_funcs_atomic); else
ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
if (ret) goto err;
return0;
err:
drm_dbg_kms(dev, "Failed to verify and init gem fb: %d\n", ret);
rfb->base.obj[0] = NULL; return ret;
}
/* *Thisneedstohappenbeforemodifierconversionasthatmightchange *thenumberofplanes.
*/ for (i = 1; i < rfb->base.format->num_planes; ++i) { if (mode_cmd->handles[i] != mode_cmd->handles[0]) {
drm_dbg_kms(dev, "Plane 0 and %d have different BOs: %u vs. %u\n",
i, mode_cmd->handles[0], mode_cmd->handles[i]);
ret = -EINVAL; return ret;
}
}
ret = amdgpu_display_get_fb_info(rfb, &rfb->tiling_flags, &rfb->tmz_surface,
&rfb->gfx12_dcc); if (ret) return ret;
if (dev->mode_config.fb_modifiers_not_supported && !adev->enable_virtual_display) {
drm_WARN_ONCE(dev, adev->family >= AMDGPU_FAMILY_AI, "GFX9+ requires FB check based on format modifier\n");
ret = check_tiling_flags_gfx6(rfb); if (ret) return ret;
}
if (!dev->mode_config.fb_modifiers_not_supported &&
!(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) { if (amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(12, 0, 0))
ret = convert_tiling_flags_to_modifier_gfx12(rfb); else
ret = convert_tiling_flags_to_modifier(rfb);
if (ret) {
drm_dbg_kms(dev, "Failed to convert tiling flags 0x%llX to a modifier",
rfb->tiling_flags); return ret;
}
}
ret = amdgpu_display_verify_sizes(rfb); if (ret) return ret;
for (i = 0; i < rfb->base.format->num_planes; ++i) {
drm_gem_object_get(rfb->base.obj[0]);
rfb->base.obj[i] = rfb->base.obj[0];
}
obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]); if (obj == NULL) {
drm_dbg_kms(dev, "No GEM object associated to handle 0x%08X, can't create framebuffer\n",
mode_cmd->handles[0]);
return ERR_PTR(-ENOENT);
}
/* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
bo = gem_to_amdgpu_bo(obj);
domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags); if (drm_gem_is_imported(obj) && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
drm_gem_object_put(obj); return ERR_PTR(-EINVAL);
}
/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
/* Get optional system timestamp before query. */ if (stime)
*stime = ktime_get();
if (amdgpu_display_page_flip_get_scanoutpos(adev, pipe, &vbl, &position) == 0)
ret |= DRM_SCANOUTPOS_VALID;
/* Get optional system timestamp after query. */ if (etime)
*etime = ktime_get();
/* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */
/* Decode into vertical and horizontal scanout position. */
*vpos = position & 0x1fff;
*hpos = (position >> 16) & 0x1fff;
/* Valid vblank area boundaries from gpu retrieved? */ if (vbl > 0) { /* Yes: Decode. */
ret |= DRM_SCANOUTPOS_ACCURATE;
vbl_start = vbl & 0x1fff;
vbl_end = (vbl >> 16) & 0x1fff;
} else { /* No: Fake something reasonable which gives at least ok results. */
vbl_start = mode->crtc_vdisplay;
vbl_end = 0;
}
/* Called from driver internal vblank counter query code? */ if (flags & GET_DISTANCE_TO_VBLANKSTART) { /* Caller wants distance from real vbl_start in *hpos */
*hpos = *vpos - vbl_start;
}
/* Fudge vblank to start a few scanlines earlier to handle the *problemthatvblankirqsfireafewscanlinesbeforestart *ofvblank.Somedriverinternalcallersneedthetruevblank *starttobeusedandsignalthisviatheUSE_REAL_VBLANKSTARTflag. * *Thecauseofthe"early"vblankirqisthattheirqistriggered *bythelinebufferlogicwhenthelinebufferreadpositionenters *thevblank,whereasourcrtcscanoutpositionnaturallylagsthe *linebufferreadposition.
*/ if (!(flags & USE_REAL_VBLANKSTART))
vbl_start -= adev->mode_info.crtcs[pipe]->lb_vblank_lead_lines;
/* Test scanout position against vblank region. */ if ((*vpos < vbl_start) && (*vpos >= vbl_end))
in_vbl = false;
/* In vblank? */ if (in_vbl)
ret |= DRM_SCANOUTPOS_IN_VBLANK;
/* Called from driver internal vblank counter query code? */ if (flags & GET_DISTANCE_TO_VBLANKSTART) { /* Caller wants distance from fudged earlier vbl_start */
*vpos -= vbl_start; return ret;
}
/* Check if inside vblank area and apply corrective offsets: *vposwillthenbe>=0invideoscanoutarea,butnegative *withinvblankarea,countingdownthenumberoflinesuntil *startofscanout.
*/
/* Inside "upper part" of vblank area? Apply corrective offset if so: */ if (in_vbl && (*vpos >= vbl_start)) {
vtotal = mode->crtc_vtotal;
/* With variable refresh rate displays the vpos can exceed *thevtotalvalue.Clampto0toreturn-vbl_endinstead *ofguessingtheremainingnumberoflinesuntilscanout.
*/
*vpos = (*vpos < vtotal) ? (*vpos - vtotal) : 0;
}
/* Correct for shifted end of vbl at vbl_end. */
*vpos = *vpos - vbl_end;
return ret;
}
int amdgpu_display_crtc_idx_to_irq_type(struct amdgpu_device *adev, int crtc)
{ if (crtc < 0 || crtc >= adev->mode_info.num_crtc) return AMDGPU_CRTC_IRQ_NONE;
/* panic_bo is set in amdgpu_dm_plane_get_scanout_buffer() and only used in amdgpu_dm_set_pixel() *theyarecalledfromthepanichandler,andprotectedbythedrm_panicspinlock.
*/ staticstruct amdgpu_bo *panic_abo;
/* Use the indirect MMIO to write each pixel to the GPU VRAM, *Thisisasimplifiedversionofamdgpu_device_mm_access()
*/ staticvoid amdgpu_display_set_pixel(struct drm_scanout_buffer *sb, unsignedint x, unsignedint y,
u32 color)
{ struct amdgpu_res_cursor cursor; unsignedlong offset; struct amdgpu_bo *abo = panic_abo; struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
uint32_t tmp;
offset = x * 4 + y * sb->pitch[0];
amdgpu_res_first(abo->tbo.resource, offset, 4, &cursor);
abo = gem_to_amdgpu_bo(fb->obj[0]); if (!abo) return -EINVAL;
sb->width = fb->width;
sb->height = fb->height; /* Use the generic linear format, because tiling will be disabled in panic_flush() */
sb->format = drm_format_info(fb->format->format); if (!sb->format) return -EINVAL;
sb->pitch[0] = fb->pitches[0];
if (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) { if (abo->tbo.resource->mem_type != TTM_PL_VRAM) {
drm_warn(plane->dev, "amdgpu panic, framebuffer not in VRAM\n"); return -EINVAL;
} /* Only handle 32bits format, to simplify mmio access */ if (fb->format->cpp[0] != 4) {
drm_warn(plane->dev, "amdgpu panic, pixel format is not 32bits\n"); return -EINVAL;
}
sb->set_pixel = amdgpu_display_set_pixel;
panic_abo = abo; return0;
} if (!abo->kmap.virtual &&
ttm_bo_kmap(&abo->tbo, 0, PFN_UP(abo->tbo.base.size), &abo->kmap)) {
drm_warn(plane->dev, "amdgpu bo map failed, panic won't be displayed\n"); return -ENOMEM;
} if (abo->kmap.bo_kmap_type & TTM_BO_MAP_IOMEM_MASK)
iosys_map_set_vaddr_iomem(&sb->map[0], abo->kmap.virtual); else
iosys_map_set_vaddr(&sb->map[0], abo->kmap.virtual);
return0;
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.41Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-03)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.