From patchwork Mon Mar 11 17:42:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 10847899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 680F86C2 for ; Mon, 11 Mar 2019 17:42:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5236128A1F for ; Mon, 11 Mar 2019 17:42:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 462E128DD0; Mon, 11 Mar 2019 17:42:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 90A1528A1F for ; Mon, 11 Mar 2019 17:42:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 591F089C17; Mon, 11 Mar 2019 17:42:32 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9314B89BF1; Mon, 11 Mar 2019 17:42:31 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:44760 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1h3OwX-0007oa-Qe; Mon, 11 Mar 2019 18:42:29 +0100 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Date: Mon, 11 Mar 2019 18:42:17 +0100 Message-Id: <20190311174218.51899-3-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311174218.51899-1-noralf@tronnes.org> References: <20190311174218.51899-1-noralf@tronnes.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org; s=ds201810; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=xfGPDaGLs2dMQy9308itA4ixzFj6hNKu6TKmzEbpKxw=; b=D9+qfVEwW7mniBMKa/WJFQKFBJamuYuXw0jjHbGixkbdx99kI5Ac/IxRYZePgfF1R7urnZzMdzq9r71Wfq3gLFvzBjlbqslaVTS61XT3RFg957cYugAdlCgiJjfQW6g5BhDMjUllECFWoooYcmEImXbrYoeSYokBo337OP4IPpwZJGIT0dYbSc1t5o4y2R+s9S0pmcf5o2RAQdrjx178IB3zQqr0hylEULm2jWEJRfTEvgYSF3AjR1yVaf1kH7exs+MffpmGf3DU2rpoLvOgE0hiHoeBJtMEL4ZMxmUd7i2LKwyXTPiXaHzS9UqnieMxVy8TmJTB8LvThXP+bcvraQ==; Subject: [Intel-gfx] [PATCH v2 2/3] drm/cma-helper: Add support for panic screen X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org, =?utf-8?q?Noral?= =?utf-8?q?f_Tr=C3=B8nnes?= , darwish.07@gmail.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add drm_fb_cma_fb_create() which creates a framebuffer that supports panic message output. vmap PRIME buffers on import to support panic on those as well. There is no atomic way to get a virtual address on a dma_buf. Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/drm_fb_cma_helper.c | 43 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_gem_cma_helper.c | 3 ++ include/drm/drm_fb_cma_helper.h | 4 ++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 5f8074ffe7d9..9d62dadf5d14 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -56,6 +56,49 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, } EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj); +static void *drm_fb_cma_fb_panic_vmap(struct drm_framebuffer *fb) +{ + return drm_fb_cma_get_gem_obj(fb, 0)->vaddr; +} + +static const struct drm_framebuffer_funcs drm_fb_cma_fb_funcs = { + .destroy = drm_gem_fb_destroy, + .create_handle = drm_gem_fb_create_handle, + .panic_vmap = drm_fb_cma_fb_panic_vmap, +}; + +/** + * drm_fb_cma_fb_create() - &drm_mode_config_funcs.fb_create callback function + * @dev: DRM device + * @file: DRM file that holds the GEM handle(s) backing the framebuffer + * @mode_cmd: Metadata from the userspace framebuffer creation request + * + * This function creates a new framebuffer object described by + * &drm_mode_fb_cmd2. This description includes handles for the buffer(s) + * backing the framebuffer. + * + * If your hardware has special alignment or pitch requirements these should be + * checked before calling this function. The function does buffer size + * validation. + * + * Drivers can use this as their &drm_mode_config_funcs.fb_create callback. + * The ADDFB2 IOCTL calls into this callback. + * + * The &drm_framebuffer_funcs.panic_vmap() callback is set supporting panic + * screen rendering. + * + * Returns: + * Pointer to a &drm_framebuffer on success or an error pointer on failure. + */ +struct drm_framebuffer * +drm_fb_cma_fb_create(struct drm_device *dev, struct drm_file *file, + const struct drm_mode_fb_cmd2 *mode_cmd) +{ + return drm_gem_fb_create_with_funcs(dev, file, mode_cmd, + &drm_fb_cma_fb_funcs); +} +EXPORT_SYMBOL_GPL(drm_fb_cma_fb_create); + /** * drm_fb_cma_get_gem_addr() - Get physical address for framebuffer, for pixel * formats where values are grouped in blocks this will get you the beginning of diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index cc26625b4b33..9a4721b5e26d 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -507,6 +507,9 @@ drm_gem_cma_prime_import_sg_table(struct drm_device *dev, cma_obj->paddr = sg_dma_address(sgt->sgl); cma_obj->sgt = sgt; + /* Try to vmap the buffer to support panic rendering */ + cma_obj->vaddr = dma_buf_vmap(attach->dmabuf); + DRM_DEBUG_PRIME("dma_addr = %pad, size = %zu\n", &cma_obj->paddr, attach->dmabuf->size); return &cma_obj->base; diff --git a/include/drm/drm_fb_cma_helper.h b/include/drm/drm_fb_cma_helper.h index 4becb09975a4..6c9e5da17140 100644 --- a/include/drm/drm_fb_cma_helper.h +++ b/include/drm/drm_fb_cma_helper.h @@ -7,7 +7,9 @@ struct drm_plane_state; struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, unsigned int plane); - +struct drm_framebuffer * +drm_fb_cma_fb_create(struct drm_device *dev, struct drm_file *file, + const struct drm_mode_fb_cmd2 *mode_cmd); dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb, struct drm_plane_state *state, unsigned int plane);