From patchwork Fri Jul 31 12:51:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 11694931 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B4BD913 for ; Fri, 31 Jul 2020 12:51:48 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA45E2245C for ; Fri, 31 Jul 2020 12:51:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WgUyGPBf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA45E2245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVL-0001JL-IW; Fri, 31 Jul 2020 12:51:19 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVK-0001HZ-I5 for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 12:51:18 +0000 X-Inumbo-ID: 84af1b9c-d32c-11ea-8e30-bc764e2007e4 Received: from mail-lf1-x142.google.com (unknown [2a00:1450:4864:20::142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 84af1b9c-d32c-11ea-8e30-bc764e2007e4; Fri, 31 Jul 2020 12:51:15 +0000 (UTC) Received: by mail-lf1-x142.google.com with SMTP id j22so10896253lfm.2 for ; Fri, 31 Jul 2020 05:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P8zgpF044pgTW1uK5Q8AXrv/7bel3rEWKcAtjS7WDeo=; b=WgUyGPBfwmJ9bTlFZ1iykzmaC+/eyxO2mETTCyh0EN7DEuu6cfihmRQOfjN0UX17KJ 1XK/aClkr4jouIfR2Uq33SHtLP56E4y8DgZ87NMJDRnE/5HMKnL0qQRmTaRqEurFsoxI D/R3+eHgdIAl42+OdJRKAhPJheLy6IATe2ljDZKS9Ir/9TnHfgeT9ND6Q078g/e5NeAs I2W7ZBR4JYFb7XWCyVQlSdl0Ydv93Ytn/B8SI+DrRwYKxIF7FMjE6FYcroqJuyHyrA1S e7Z785IPUZkU0urptiMhDbgonuN0KgLkpcNKcT+5pvixgh0YZDlTJ29FOCn97utl+t8+ hahQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P8zgpF044pgTW1uK5Q8AXrv/7bel3rEWKcAtjS7WDeo=; b=rv3q0HIgph9RvopwE15MHDPbwNdcwxyW/8MD9y7kG0wdGxSvZyEq9LTD3oNsMmjBdK 3nzYVXiRKX4aTVYg7aDg4YhjPrav2dZdMwOqs3mfIQLcuT7UqhE+6NDDk9PRuHVPpqy8 a2MdvIUZdLX1fFXggRSXH2HjB2Jf9dhqXrOlR3JFCsNqJVYyze04ik+s9+qr5yaT1bHx zPpiQn9af63FnNBoM+1NNf+rIfNpgKZ1lURqAgYB9rMaJHAon4dpg0lsgvtEm2sDLRdV 6lzXbe5buBhfmJqOxxm8xPgr9i1eqYnG5UqcYMTZk33b4x/ewuyeIukwpDESFpToDv8S cSTg== X-Gm-Message-State: AOAM531M4tTvHi68nwPo4T0owXUZV02iETMwvwQpqfrkD7arbrhs7CwJ AXoHVCYoAWB0tuMgYr17A4j0guzb45Y= X-Google-Smtp-Source: ABdhPJzATe0fCD2sbhssHSnUfNXc6kWFAY41kSspFrVQTiQcz0U9VH0isUKE3+W9ohrCIfVkdQXBSg== X-Received: by 2002:ac2:5683:: with SMTP id 3mr1948307lfr.69.1596199873919; Fri, 31 Jul 2020 05:51:13 -0700 (PDT) Received: from a2klaptop.localdomain ([185.199.97.5]) by smtp.gmail.com with ESMTPSA id s2sm1923362lfs.4.2020.07.31.05.51.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:51:13 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, airlied@linux.ie, daniel@ffwll.ch Subject: [PATCH 1/6] xen/gntdev: Fix dmabuf import with non-zero sgt offset Date: Fri, 31 Jul 2020 15:51:04 +0300 Message-Id: <20200731125109.18666-2-andr2000@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731125109.18666-1-andr2000@gmail.com> References: <20200731125109.18666-1-andr2000@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, sstabellini@kernel.org, dan.carpenter@oracle.com, Oleksandr Andrushchenko Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Andrushchenko It is possible that the scatter-gather table during dmabuf import has non-zero offset of the data, but user-space doesn't expect that. Fix this by failing the import, so user-space doesn't access wrong data. Fixes: 37ccb44d0b00 ("xen/gntdev: Implement dma-buf import functionality") Signed-off-by: Oleksandr Andrushchenko Acked-by: Juergen Gross --- drivers/xen/gntdev-dmabuf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c index 75d3bb948bf3..b1b6eebafd5d 100644 --- a/drivers/xen/gntdev-dmabuf.c +++ b/drivers/xen/gntdev-dmabuf.c @@ -613,6 +613,14 @@ dmabuf_imp_to_refs(struct gntdev_dmabuf_priv *priv, struct device *dev, goto fail_detach; } + /* Check that we have zero offset. */ + if (sgt->sgl->offset) { + ret = ERR_PTR(-EINVAL); + pr_debug("DMA buffer has %d bytes offset, user-space expects 0\n", + sgt->sgl->offset); + goto fail_unmap; + } + /* Check number of pages that imported buffer has. */ if (attach->dmabuf->size != gntdev_dmabuf->nr_pages << PAGE_SHIFT) { ret = ERR_PTR(-EINVAL); From patchwork Fri Jul 31 12:51:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 11694933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72879138A for ; Fri, 31 Jul 2020 12:52:01 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E2482177B for ; Fri, 31 Jul 2020 12:52:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WpFdItwL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E2482177B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVQ-0001LN-Rr; Fri, 31 Jul 2020 12:51:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVP-0001HZ-IN for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 12:51:23 +0000 X-Inumbo-ID: 85a1fed4-d32c-11ea-8e30-bc764e2007e4 Received: from mail-lj1-x242.google.com (unknown [2a00:1450:4864:20::242]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 85a1fed4-d32c-11ea-8e30-bc764e2007e4; Fri, 31 Jul 2020 12:51:16 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id w14so2461070ljj.4 for ; Fri, 31 Jul 2020 05:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hf2m1CaACgkl3i0FS0MjmjyDubimZdTD8G//CB5QIMY=; b=WpFdItwLmE1h/jcPKXj3mRmyaF+TKN3FWkbAvN9i01/b/GBnQQrfqTYPD3KkCl+HER 4a3yBnoP8xZ1+beeiIJ9vfMIpoL/Uq0aKjRgj9n3gDAB35PWSD+52cvI8qsbw9MMxnde Ogk+jE2mX/g7LFVkGpGWoSr7sD8Yog+cmIHDyOr5lEBZFzgPS2kU4Fuv8LCiEtAMJi4Y V/MPagzOAVhsCHI/ruYoFU5NgrrL0yQ5Bln8moUVlTyOMw3rTQ7cCkra3lYcATWDogf/ jBRFwFf8eSKHB5WoChdB5jL9GonvtcReyID4iSV0w2pPa3lh5NAPcP/9Jan5UaU8YB8u zvVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hf2m1CaACgkl3i0FS0MjmjyDubimZdTD8G//CB5QIMY=; b=RJZCsqxpB8QfWIPrCYKglcsmcc1xPHjmXRfzyP/iUY3y1jf8roz+bnPSwk6Sdd/Lyc aAe4+GaKQjHmkkIySG1ksaaptDbuUdGR3KUb5QOHU3XDHtU6xx4bLMfoo6OVHYOmkbD6 GTxSsCznE2QB8ZEwhKxwnPUd/lUix0XcpMgXD2Q6zimusCOCiSXwCWNlDA+90uLTbHXR V+IlSYzGY7Bh9mzSKWyAItReYx/7J10Ou3TBWeICmFh0V2nLiqCHfRmOOqvJO5J0k4/O VQHcTD0b3ucIoL2og30CwIhOo+/qDAIxxSK/Eq3SIJQgNIfKmnE/P7aNZgQ6/5C+sJHa Wduw== X-Gm-Message-State: AOAM533zcSdaJZqFa8ZBPpTF1z1MvMH7wxKZAeR1jfrlKU7tCjIuTd45 1+juv/Kzql2JIqWfdXJCo1OlgSJy5pA= X-Google-Smtp-Source: ABdhPJyAr3EgNy6m0bxN5SP4DJ54ompCgY6CBLlI16M8yY4FlCVLhiNPKf3qPH+txZ2PmAgUTW2prA== X-Received: by 2002:a2e:9e43:: with SMTP id g3mr1932560ljk.309.1596199875447; Fri, 31 Jul 2020 05:51:15 -0700 (PDT) Received: from a2klaptop.localdomain ([185.199.97.5]) by smtp.gmail.com with ESMTPSA id s2sm1923362lfs.4.2020.07.31.05.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:51:14 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, airlied@linux.ie, daniel@ffwll.ch Subject: [PATCH 2/6] drm/xen-front: Fix misused IS_ERR_OR_NULL checks Date: Fri, 31 Jul 2020 15:51:05 +0300 Message-Id: <20200731125109.18666-3-andr2000@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731125109.18666-1-andr2000@gmail.com> References: <20200731125109.18666-1-andr2000@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, sstabellini@kernel.org, dan.carpenter@oracle.com, Oleksandr Andrushchenko Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Andrushchenko The patch c575b7eeb89f: "drm/xen-front: Add support for Xen PV display frontend" from Apr 3, 2018, leads to the following static checker warning: drivers/gpu/drm/xen/xen_drm_front_gem.c:140 xen_drm_front_gem_create() warn: passing zero to 'ERR_CAST' drivers/gpu/drm/xen/xen_drm_front_gem.c 133 struct drm_gem_object *xen_drm_front_gem_create(struct drm_device *dev, 134 size_t size) 135 { 136 struct xen_gem_object *xen_obj; 137 138 xen_obj = gem_create(dev, size); 139 if (IS_ERR_OR_NULL(xen_obj)) 140 return ERR_CAST(xen_obj); Fix this and the rest of misused places with IS_ERR_OR_NULL in the driver. Fixes: c575b7eeb89f: "drm/xen-front: Add support for Xen PV display frontend" Signed-off-by: Oleksandr Andrushchenko Reported-by: Dan Carpenter Reviewed-by: Dan Carpenter --- drivers/gpu/drm/xen/xen_drm_front.c | 4 ++-- drivers/gpu/drm/xen/xen_drm_front_gem.c | 8 ++++---- drivers/gpu/drm/xen/xen_drm_front_kms.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c index 3e660fb111b3..88db2726e8ce 100644 --- a/drivers/gpu/drm/xen/xen_drm_front.c +++ b/drivers/gpu/drm/xen/xen_drm_front.c @@ -400,8 +400,8 @@ static int xen_drm_drv_dumb_create(struct drm_file *filp, args->size = args->pitch * args->height; obj = xen_drm_front_gem_create(dev, args->size); - if (IS_ERR_OR_NULL(obj)) { - ret = PTR_ERR_OR_ZERO(obj); + if (IS_ERR(obj)) { + ret = PTR_ERR(obj); goto fail; } diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c index f0b85e094111..4ec8a49241e1 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c @@ -83,7 +83,7 @@ static struct xen_gem_object *gem_create(struct drm_device *dev, size_t size) size = round_up(size, PAGE_SIZE); xen_obj = gem_create_obj(dev, size); - if (IS_ERR_OR_NULL(xen_obj)) + if (IS_ERR(xen_obj)) return xen_obj; if (drm_info->front_info->cfg.be_alloc) { @@ -117,7 +117,7 @@ static struct xen_gem_object *gem_create(struct drm_device *dev, size_t size) */ xen_obj->num_pages = DIV_ROUND_UP(size, PAGE_SIZE); xen_obj->pages = drm_gem_get_pages(&xen_obj->base); - if (IS_ERR_OR_NULL(xen_obj->pages)) { + if (IS_ERR(xen_obj->pages)) { ret = PTR_ERR(xen_obj->pages); xen_obj->pages = NULL; goto fail; @@ -136,7 +136,7 @@ struct drm_gem_object *xen_drm_front_gem_create(struct drm_device *dev, struct xen_gem_object *xen_obj; xen_obj = gem_create(dev, size); - if (IS_ERR_OR_NULL(xen_obj)) + if (IS_ERR(xen_obj)) return ERR_CAST(xen_obj); return &xen_obj->base; @@ -194,7 +194,7 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev, size = attach->dmabuf->size; xen_obj = gem_create_obj(dev, size); - if (IS_ERR_OR_NULL(xen_obj)) + if (IS_ERR(xen_obj)) return ERR_CAST(xen_obj); ret = gem_alloc_pages_array(xen_obj, size); diff --git a/drivers/gpu/drm/xen/xen_drm_front_kms.c b/drivers/gpu/drm/xen/xen_drm_front_kms.c index 78096bbcd226..ef11b1e4de39 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_kms.c +++ b/drivers/gpu/drm/xen/xen_drm_front_kms.c @@ -60,7 +60,7 @@ fb_create(struct drm_device *dev, struct drm_file *filp, int ret; fb = drm_gem_fb_create_with_funcs(dev, filp, mode_cmd, &fb_funcs); - if (IS_ERR_OR_NULL(fb)) + if (IS_ERR(fb)) return fb; gem_obj = fb->obj[0]; From patchwork Fri Jul 31 12:51:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 11694939 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18156913 for ; Fri, 31 Jul 2020 12:52:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4AE82087C for ; Fri, 31 Jul 2020 12:52:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dvGhnctd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4AE82087C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVW-0001OA-5M; Fri, 31 Jul 2020 12:51:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVU-0001HZ-IQ for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 12:51:28 +0000 X-Inumbo-ID: 861a5ecf-d32c-11ea-8e30-bc764e2007e4 Received: from mail-lf1-x142.google.com (unknown [2a00:1450:4864:20::142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 861a5ecf-d32c-11ea-8e30-bc764e2007e4; Fri, 31 Jul 2020 12:51:18 +0000 (UTC) Received: by mail-lf1-x142.google.com with SMTP id k13so16822339lfo.0 for ; Fri, 31 Jul 2020 05:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=in3e/rhynkLwVD5V9PwoaNI3UJD8A73TVa8u/14UsAg=; b=dvGhnctdpY5kxFxb0suRBtGNcio8aozQM9kdwS+Lnwi6/6de1sgC6u7OXXgupL3KX2 CzjQ8fZkjfpjEM8Ct/Rl4YPy3RXEMyiAxnq6w0+TAqibQWiMtXMmRYiVdbWlDCLDExp0 oRSTR1udpBecZD7hP4CuP4fsW1WUZOXMyRpiX52GsPu8zk/CAJpl0Ozg9mQi94llxQ9A YDcTUgBuVLAXdjVPehaqgATExkYwQHpVbPFgQcFFGFYUxffiNQmOCqYF1R34fiJLe/+4 bu77en9ko2W4Qny1ym2XxbQtdj/47CBtRgk9E5QWu0Vo7/i4SQO/zCHjVP+UYAjeOzTP F4rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=in3e/rhynkLwVD5V9PwoaNI3UJD8A73TVa8u/14UsAg=; b=QmFLhNoBDjTQjqzzXUP/v74e5DP5cGalEsXx+iV7PGXHw3wYJ4okx07h2DfbpivTzv Znnufr1NR5eeAZ8yKL6WFug5Tbe3E84LzHinCQHj3s3p0lY/ZanhYc8D3Fg59Z0cw1fa ptDCakWG8cO1EMo5pa0Cq5Z/GqeTmDzetmfN86y7x2tPiDo86GmfcrL3xK0kpZ8aEFaR vyhXLsMP2l3RjadiLa0aZqgqVa/a6/0FqHzUPoanjrGeEvweqL1JpCQ+76k+G9DW9FtC +CCAv/2OMFtj47Y2i8pG+XF/a0YMVdB57j7hOpJE4z6SdFHoj/GUj3goMAMFrN6jk5/h gcpQ== X-Gm-Message-State: AOAM530TTwuVQzhHyJb8GW5QsNCeeWWD7IEFpVsA44yOkK/5KK6MMrOB FU3GPS8yaQxWEQlX6+RR7QsBUeT/yIg= X-Google-Smtp-Source: ABdhPJxYkcBz7mtQ/VNmuWNPBGMmzaqks8S8snreTQ/Yahk5mchXkjcy3WbaQqY4RS/Kt1wg3P3OVw== X-Received: by 2002:a19:ae06:: with SMTP id f6mr1992770lfc.42.1596199876892; Fri, 31 Jul 2020 05:51:16 -0700 (PDT) Received: from a2klaptop.localdomain ([185.199.97.5]) by smtp.gmail.com with ESMTPSA id s2sm1923362lfs.4.2020.07.31.05.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:51:16 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, airlied@linux.ie, daniel@ffwll.ch Subject: [PATCH 3/6] drm/xen-front: Add YUYV to supported formats Date: Fri, 31 Jul 2020 15:51:06 +0300 Message-Id: <20200731125109.18666-4-andr2000@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731125109.18666-1-andr2000@gmail.com> References: <20200731125109.18666-1-andr2000@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, sstabellini@kernel.org, dan.carpenter@oracle.com, Oleksandr Andrushchenko Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Andrushchenko Add YUYV to supported formats, so the frontend can work with the formats used by cameras and other HW. Signed-off-by: Oleksandr Andrushchenko Acked-by: Noralf Trønnes --- drivers/gpu/drm/xen/xen_drm_front_conn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/xen/xen_drm_front_conn.c b/drivers/gpu/drm/xen/xen_drm_front_conn.c index 459702fa990e..44f1f70c0aed 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_conn.c +++ b/drivers/gpu/drm/xen/xen_drm_front_conn.c @@ -33,6 +33,7 @@ static const u32 plane_formats[] = { DRM_FORMAT_ARGB4444, DRM_FORMAT_XRGB1555, DRM_FORMAT_ARGB1555, + DRM_FORMAT_YUYV, }; const u32 *xen_drm_front_conn_get_formats(int *format_count) From patchwork Fri Jul 31 12:51:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 11694941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA316138A for ; Fri, 31 Jul 2020 12:52:37 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B66732087C for ; Fri, 31 Jul 2020 12:52:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oyEx3PKz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B66732087C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVb-0001R2-FS; Fri, 31 Jul 2020 12:51:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVZ-0001HZ-IU for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 12:51:33 +0000 X-Inumbo-ID: 876e36d8-d32c-11ea-8e30-bc764e2007e4 Received: from mail-lf1-x143.google.com (unknown [2a00:1450:4864:20::143]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 876e36d8-d32c-11ea-8e30-bc764e2007e4; Fri, 31 Jul 2020 12:51:19 +0000 (UTC) Received: by mail-lf1-x143.google.com with SMTP id j22so10896360lfm.2 for ; Fri, 31 Jul 2020 05:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OegNMCy7sd4YzoHmkSxRWimW6gQOJebTWr9iC4Yy25M=; b=oyEx3PKzdJIIXSy691f9LlHCTe0UkaNkvc6+33eXGtZ6qb6/BzMUd7PJCNP7erQpQf rAbeFcLX9M5eRkOqb/GN/c1CmRHOAOEOK5r7MRycTck1COq2fLmWvFmyp7oQFEyT/x5j vuUV/B5Ty8I62qWbpcz3LCBAk4v84PQL8J6u1lcQRA35bAkOUPttVTySf5KsWJikvCwr cNSzJTK0NrEEbCN+LFmTzx7MFTTsUCfkWiQ642E7tVODBEXIKg15u6sHbqtHIJyY9Lyw qo9/SrsLoigzUTcYp3I9HK92bM7fEFwbhQKbNXqoKrKVpqVP8iwYAdA7ReON8q1L41Ki 5pFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OegNMCy7sd4YzoHmkSxRWimW6gQOJebTWr9iC4Yy25M=; b=r6cxbrZdh2b5wzDpE5ZDfpqQ6IlORHrasIxUY+I1uIMc8dQHSVxTuSwC6V07yYcLKA oHvB79l2uV/QNQspHOsIjmfM07QnUu6PmKljEodVnj/wAA7tJcBKmiYrfccziP9Mud4O +AjkmSqsdt8v5D+PNLM/FIrRTn/3bPbxLnBsVmejgxinEIjOVeXjJSM9DUzD/e8PWW2P LHWFcqHFI3kOjFgQmjt0NsfKdnW0Hl0SYec3FD1mEj4YZHKdWjg87uI/aEEL3Rdq63Ua S+grVG7eJaOEOmIwKoP5OkJ6zWBJgTg2TTbwGNJ1QUAGcWvOKA2q0DwhMaf/jZPxWyXu 6zZg== X-Gm-Message-State: AOAM533dqH1Kk9oV4v2NUOzbQ4xWFRr2V57VtIvklWoRObF6ItrWp8Mt PqkhIcJOpgqkXde21iD5SsmQ2ZPBMKs= X-Google-Smtp-Source: ABdhPJy9Wqj5+XdlvDNNN+TvI5vrQTMO+5R57ssPhVVE/1YOzNCRvq0qSuixu5RL8ILDT5KUXx2aKg== X-Received: by 2002:a05:6512:3a5:: with SMTP id v5mr1944657lfp.138.1596199878393; Fri, 31 Jul 2020 05:51:18 -0700 (PDT) Received: from a2klaptop.localdomain ([185.199.97.5]) by smtp.gmail.com with ESMTPSA id s2sm1923362lfs.4.2020.07.31.05.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:51:17 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, airlied@linux.ie, daniel@ffwll.ch Subject: [PATCH 4/6] xen: Sync up with the canonical protocol definition in Xen Date: Fri, 31 Jul 2020 15:51:07 +0300 Message-Id: <20200731125109.18666-5-andr2000@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731125109.18666-1-andr2000@gmail.com> References: <20200731125109.18666-1-andr2000@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, sstabellini@kernel.org, dan.carpenter@oracle.com, Oleksandr Andrushchenko Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Andrushchenko This is the sync up with the canonical definition of the display protocol in Xen. 1. Add protocol version as an integer Version string, which is in fact an integer, is hard to handle in the code that supports different protocol versions. To simplify that also add the version as an integer. 2. Pass buffer offset with XENDISPL_OP_DBUF_CREATE There are cases when display data buffer is created with non-zero offset to the data start. Handle such cases and provide that offset while creating a display buffer. 3. Add XENDISPL_OP_GET_EDID command Add an optional request for reading Extended Display Identification Data (EDID) structure which allows better configuration of the display connectors over the configuration set in XenStore. With this change connectors may have multiple resolutions defined with respect to detailed timing definitions and additional properties normally provided by displays. If this request is not supported by the backend then visible area is defined by the relevant XenStore's "resolution" property. If backend provides extended display identification data (EDID) with XENDISPL_OP_GET_EDID request then EDID values must take precedence over the resolutions defined in XenStore. 4. Bump protocol version to 2. Signed-off-by: Oleksandr Andrushchenko Reviewed-by: Juergen Gross --- include/xen/interface/io/displif.h | 91 +++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 3 deletions(-) diff --git a/include/xen/interface/io/displif.h b/include/xen/interface/io/displif.h index fdc279dc4a88..c2d900186883 100644 --- a/include/xen/interface/io/displif.h +++ b/include/xen/interface/io/displif.h @@ -38,7 +38,8 @@ * Protocol version ****************************************************************************** */ -#define XENDISPL_PROTOCOL_VERSION "1" +#define XENDISPL_PROTOCOL_VERSION "2" +#define XENDISPL_PROTOCOL_VERSION_INT 2 /* ****************************************************************************** @@ -202,6 +203,9 @@ * Width and height of the connector in pixels separated by * XENDISPL_RESOLUTION_SEPARATOR. This defines visible area of the * display. + * If backend provides extended display identification data (EDID) with + * XENDISPL_OP_GET_EDID request then EDID values must take precedence + * over the resolutions defined here. * *------------------ Connector Request Transport Parameters ------------------- * @@ -349,6 +353,8 @@ #define XENDISPL_OP_FB_DETACH 0x13 #define XENDISPL_OP_SET_CONFIG 0x14 #define XENDISPL_OP_PG_FLIP 0x15 +/* The below command is available in protocol version 2 and above. */ +#define XENDISPL_OP_GET_EDID 0x16 /* ****************************************************************************** @@ -377,6 +383,10 @@ #define XENDISPL_FIELD_BE_ALLOC "be-alloc" #define XENDISPL_FIELD_UNIQUE_ID "unique-id" +#define XENDISPL_EDID_BLOCK_SIZE 128 +#define XENDISPL_EDID_BLOCK_COUNT 256 +#define XENDISPL_EDID_MAX_SIZE (XENDISPL_EDID_BLOCK_SIZE * XENDISPL_EDID_BLOCK_COUNT) + /* ****************************************************************************** * STATUS RETURN CODES @@ -451,7 +461,9 @@ * +----------------+----------------+----------------+----------------+ * | gref_directory | 40 * +----------------+----------------+----------------+----------------+ - * | reserved | 44 + * | data_ofs | 44 + * +----------------+----------------+----------------+----------------+ + * | reserved | 48 * +----------------+----------------+----------------+----------------+ * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| * +----------------+----------------+----------------+----------------+ @@ -494,6 +506,7 @@ * buffer size (buffer_sz) exceeds what can be addressed by this single page, * then reference to the next page must be supplied (see gref_dir_next_page * below) + * data_ofs - uint32_t, offset of the data in the buffer, octets */ #define XENDISPL_DBUF_FLG_REQ_ALLOC (1 << 0) @@ -506,6 +519,7 @@ struct xendispl_dbuf_create_req { uint32_t buffer_sz; uint32_t flags; grant_ref_t gref_directory; + uint32_t data_ofs; }; /* @@ -731,6 +745,44 @@ struct xendispl_page_flip_req { uint64_t fb_cookie; }; +/* + * Request EDID - request EDID describing current connector: + * 0 1 2 3 octet + * +----------------+----------------+----------------+----------------+ + * | id | _OP_GET_EDID | reserved | 4 + * +----------------+----------------+----------------+----------------+ + * | buffer_sz | 8 + * +----------------+----------------+----------------+----------------+ + * | gref_directory | 12 + * +----------------+----------------+----------------+----------------+ + * | reserved | 16 + * +----------------+----------------+----------------+----------------+ + * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| + * +----------------+----------------+----------------+----------------+ + * | reserved | 64 + * +----------------+----------------+----------------+----------------+ + * + * Notes: + * - This command is not available in protocol version 1 and should be + * ignored. + * - This request is optional and if not supported then visible area + * is defined by the relevant XenStore's "resolution" property. + * - Shared buffer, allocated for EDID storage, must not be less then + * XENDISPL_EDID_MAX_SIZE octets. + * + * buffer_sz - uint32_t, buffer size to be allocated, octets + * gref_directory - grant_ref_t, a reference to the first shared page + * describing EDID buffer references. See XENDISPL_OP_DBUF_CREATE for + * grant page directory structure (struct xendispl_page_directory). + * + * See response format for this request. + */ + +struct xendispl_get_edid_req { + uint32_t buffer_sz; + grant_ref_t gref_directory; +}; + /* *---------------------------------- Responses -------------------------------- * @@ -753,6 +805,35 @@ struct xendispl_page_flip_req { * id - uint16_t, private guest value, echoed from request * status - int32_t, response status, zero on success and -XEN_EXX on failure * + * + * Get EDID response - response for XENDISPL_OP_GET_EDID: + * 0 1 2 3 octet + * +----------------+----------------+----------------+----------------+ + * | id | operation | reserved | 4 + * +----------------+----------------+----------------+----------------+ + * | status | 8 + * +----------------+----------------+----------------+----------------+ + * | edid_sz | 12 + * +----------------+----------------+----------------+----------------+ + * | reserved | 16 + * +----------------+----------------+----------------+----------------+ + * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| + * +----------------+----------------+----------------+----------------+ + * | reserved | 64 + * +----------------+----------------+----------------+----------------+ + * + * Notes: + * - This response is not available in protocol version 1 and should be + * ignored. + * + * edid_sz - uint32_t, size of the EDID, octets + */ + +struct xendispl_get_edid_resp { + uint32_t edid_sz; +}; + +/* *----------------------------------- Events ---------------------------------- * * Events are sent via a shared page allocated by the front and propagated by @@ -804,6 +885,7 @@ struct xendispl_req { struct xendispl_fb_detach_req fb_detach; struct xendispl_set_config_req set_config; struct xendispl_page_flip_req pg_flip; + struct xendispl_get_edid_req get_edid; uint8_t reserved[56]; } op; }; @@ -813,7 +895,10 @@ struct xendispl_resp { uint8_t operation; uint8_t reserved; int32_t status; - uint8_t reserved1[56]; + union { + struct xendispl_get_edid_resp get_edid; + uint8_t reserved1[56]; + } op; }; struct xendispl_evt { From patchwork Fri Jul 31 12:51:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 11694943 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DC861575 for ; Fri, 31 Jul 2020 12:52:38 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3789A2177B for ; Fri, 31 Jul 2020 12:52:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XUpNekSc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3789A2177B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVf-0001UF-TH; Fri, 31 Jul 2020 12:51:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVe-0001HZ-Ic for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 12:51:38 +0000 X-Inumbo-ID: 884136dc-d32c-11ea-8e30-bc764e2007e4 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 884136dc-d32c-11ea-8e30-bc764e2007e4; Fri, 31 Jul 2020 12:51:21 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id v12so1992406ljc.10 for ; Fri, 31 Jul 2020 05:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=802wLPAiJOjYAF20z0XA9+ti0fbeGRnp8uxtEVqZ2cw=; b=XUpNekScbM7pVkILHss15SrZ149Lm5AtQfG+6vzsprcdirumI53ZN4t6VgSMIYCR07 9skaHVlkX7NcNFlcoaIjMIYSSo7VYBaJxeFKKYA+1ThMAmgeCAorx2b8WQDzWH/EGcSL ZACMLyTvq9p49NUdDZQJ+C+6q75OV7U/dPqL0HqWZKTCJ09TgWEz8ZiW5LPhvz2Zln7Y qLR/h+WuI938pTe27pXqjPod/3HJqe4kl8HPpgANJKQL9Fx2Abd50/Qurj9uH4ULNMGa JFm0yWYg0IArPZxrohxFHuEZSdW3ZFfFWjH48CxRSNPSLbf6dahnKvy02/L1oQOkzkQl xcCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=802wLPAiJOjYAF20z0XA9+ti0fbeGRnp8uxtEVqZ2cw=; b=rR1bRC2ZHes9SAnaikUzkWsF0TrgSTMMOFNadGlBd3q/hjBB8Mjfrm5DxfhuEgMf0z j/AxJ2vK8zRcRPWiJk67D+Pb+P1vBTopgUit+a8iT9C3k/72C8guf29xL4m6d2oVdb8y /HIXbYlbLqT5nwhzXePlrIhugQbAdjJ2ae8BYRUnpEXCxW6FrAZr2V3nUAdoFhRZ4cLx aJCVgiUHsmWqPmfZAY8hD/tVAXR6vkSX87t7bPpd7WUimJH6xRQmV8AZKZRkC2zrWPXI S6QJ95/V5bZl5Z3XFj+WR6owbe4puLZHoZBjwyyQyNSSBINEfrLFX7cUBZyzEFtPrvLc o5wA== X-Gm-Message-State: AOAM531EiwbUTuq58ppqHglJhW+Al888ihGtcTHZag1cktO21QJXuuib /kSYmEFTYZZWycSPl50som6iWU4Pcl8= X-Google-Smtp-Source: ABdhPJxCBCQqGvpy9XgTgM7mttEVb5TQWPTSAYYjB8mKwaVorgp/Gu6H2+I5YwJsHP9dUUFce4OPrw== X-Received: by 2002:a2e:b610:: with SMTP id r16mr1841475ljn.439.1596199879842; Fri, 31 Jul 2020 05:51:19 -0700 (PDT) Received: from a2klaptop.localdomain ([185.199.97.5]) by smtp.gmail.com with ESMTPSA id s2sm1923362lfs.4.2020.07.31.05.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:51:19 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, airlied@linux.ie, daniel@ffwll.ch Subject: [PATCH 5/6] drm/xen-front: Pass dumb buffer data offset to the backend Date: Fri, 31 Jul 2020 15:51:08 +0300 Message-Id: <20200731125109.18666-6-andr2000@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731125109.18666-1-andr2000@gmail.com> References: <20200731125109.18666-1-andr2000@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, sstabellini@kernel.org, dan.carpenter@oracle.com, Oleksandr Andrushchenko Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Andrushchenko While importing a dmabuf it is possible that the data of the buffer is put with offset which is indicated by the SGT offset. Respect the offset value and forward it to the backend. Signed-off-by: Oleksandr Andrushchenko Acked-by: Noralf Trønnes --- drivers/gpu/drm/xen/xen_drm_front.c | 6 ++++-- drivers/gpu/drm/xen/xen_drm_front.h | 2 +- drivers/gpu/drm/xen/xen_drm_front_gem.c | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c index 88db2726e8ce..013c9e0e412c 100644 --- a/drivers/gpu/drm/xen/xen_drm_front.c +++ b/drivers/gpu/drm/xen/xen_drm_front.c @@ -157,7 +157,8 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline, int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info, u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct page **pages) + u32 bpp, u64 size, u32 offset, + struct page **pages) { struct xen_drm_front_evtchnl *evtchnl; struct xen_drm_front_dbuf *dbuf; @@ -194,6 +195,7 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info, req->op.dbuf_create.gref_directory = xen_front_pgdir_shbuf_get_dir_start(&dbuf->shbuf); req->op.dbuf_create.buffer_sz = size; + req->op.dbuf_create.data_ofs = offset; req->op.dbuf_create.dbuf_cookie = dbuf_cookie; req->op.dbuf_create.width = width; req->op.dbuf_create.height = height; @@ -408,7 +410,7 @@ static int xen_drm_drv_dumb_create(struct drm_file *filp, ret = xen_drm_front_dbuf_create(drm_info->front_info, xen_drm_front_dbuf_to_cookie(obj), args->width, args->height, args->bpp, - args->size, + args->size, 0, xen_drm_front_gem_get_pages(obj)); if (ret) goto fail_backend; diff --git a/drivers/gpu/drm/xen/xen_drm_front.h b/drivers/gpu/drm/xen/xen_drm_front.h index f92c258350ca..54486d89650e 100644 --- a/drivers/gpu/drm/xen/xen_drm_front.h +++ b/drivers/gpu/drm/xen/xen_drm_front.h @@ -145,7 +145,7 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline, int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info, u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct page **pages); + u32 bpp, u64 size, u32 offset, struct page **pages); int xen_drm_front_fb_attach(struct xen_drm_front_info *front_info, u64 dbuf_cookie, u64 fb_cookie, u32 width, diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c index 4ec8a49241e1..39ff95b75357 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_gem.c +++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c @@ -210,7 +210,8 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev, ret = xen_drm_front_dbuf_create(drm_info->front_info, xen_drm_front_dbuf_to_cookie(&xen_obj->base), - 0, 0, 0, size, xen_obj->pages); + 0, 0, 0, size, sgt->sgl->offset, + xen_obj->pages); if (ret < 0) return ERR_PTR(ret); From patchwork Fri Jul 31 12:51:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Andrushchenko X-Patchwork-Id: 11694945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3243B913 for ; Fri, 31 Jul 2020 12:52:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 03BA52087C for ; Fri, 31 Jul 2020 12:52:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HbWhpWIC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03BA52087C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVl-0001Xg-5R; Fri, 31 Jul 2020 12:51:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k1UVj-0001HZ-Im for xen-devel@lists.xenproject.org; Fri, 31 Jul 2020 12:51:43 +0000 X-Inumbo-ID: 8942e22e-d32c-11ea-8e30-bc764e2007e4 Received: from mail-lj1-x242.google.com (unknown [2a00:1450:4864:20::242]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8942e22e-d32c-11ea-8e30-bc764e2007e4; Fri, 31 Jul 2020 12:51:23 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id h19so32295806ljg.13 for ; Fri, 31 Jul 2020 05:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7zQCi5vRKjnMMexLpqVO1+RGpDeDdG/krrqCxgZp1MI=; b=HbWhpWICAKhm7ouBRWBGEzVp2Ly1gNg+XaeQigbOa3I7JrEoNstXZD9boIMFRnQvp/ NU+kKOCO8ZEkuhIpeiv19FHcfR+LRrWDdBo0BKaYl0w6PuwgkRt+X1aB9Ty3ZT9/RQKD VF0eO+0ytLMLEII2QEMeQrHh3rQQ7nNFNIjdOGFs+D1gtNPbaqMv4NkpMtcalx5ngOxb AVPvGT1YVb+CQmOcyVqg8MZbPt84wROetRpcP+4ExWdPSUcLWzfwHI16QZWgZznhFmFG KGeg8W5vZqv2pTaLQkE2dxca5QdflMYeeUMbxBjnyWO4T6n1vj3pztQ8sYZG5ist3k/Y bmxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7zQCi5vRKjnMMexLpqVO1+RGpDeDdG/krrqCxgZp1MI=; b=RN5hLSZQVhWUXx8KO4KzZfdxu5wiGbRrJFoiFbCprfbkJ/xFNisJXLAS9aOQgCh01v 4cYBQ+nCp3JjMmu0cMOueQMCp2pmrPsuNW+eRk0qqskKYKH0T5AZb9PseSJLpt/nan3n +Pwm8TQB0mVn5BwKOXDkL4dPEwLHEYR9BnyA1usiiYTjgL7wJeKZmlzBmAOkD677KjG9 13P449KhG5M8wVZIT4iH1WszbOiF35AvjsHRTs4bCTlULtSQD/t47Yku14JyKPxnIhco okhvoHEFWG7hjQ87RZQvMPRol6Gg8ml91vYX+/RtV6Z89jB85SIZLzvl19mm+bgrKb1u it/w== X-Gm-Message-State: AOAM530btYiYKHu/SfTjwmYnvx5IWW8hxClHx8hcW+2ZY3RkIh3BQUqP +z5ALtDBxDt1+KTXMYAISwdKsZhvByA= X-Google-Smtp-Source: ABdhPJxMttTK1ZQScjW7rj1U9b/hfyPJlPrb8YWiyNlNA+Bo6ic4x233upQgVSRTdPt8SYImIwdtLg== X-Received: by 2002:a2e:8689:: with SMTP id l9mr388219lji.467.1596199881377; Fri, 31 Jul 2020 05:51:21 -0700 (PDT) Received: from a2klaptop.localdomain ([185.199.97.5]) by smtp.gmail.com with ESMTPSA id s2sm1923362lfs.4.2020.07.31.05.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:51:20 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, boris.ostrovsky@oracle.com, jgross@suse.com, airlied@linux.ie, daniel@ffwll.ch Subject: [PATCH 6/6] drm/xen-front: Add support for EDID based configuration Date: Fri, 31 Jul 2020 15:51:09 +0300 Message-Id: <20200731125109.18666-7-andr2000@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731125109.18666-1-andr2000@gmail.com> References: <20200731125109.18666-1-andr2000@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, sstabellini@kernel.org, dan.carpenter@oracle.com, Oleksandr Andrushchenko Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Andrushchenko Version 2 of the Xen displif protocol adds XENDISPL_OP_GET_EDID request which allows frontends to request EDID structure per connector. This request is optional and if not supported by the backend then visible area is still defined by the relevant XenStore's "resolution" property. If backend provides EDID with XENDISPL_OP_GET_EDID request then its values must take precedence over the resolutions defined in XenStore. Signed-off-by: Oleksandr Andrushchenko Reported-by: kernel test robot --- drivers/gpu/drm/xen/xen_drm_front.c | 62 ++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front.h | 9 ++- drivers/gpu/drm/xen/xen_drm_front_cfg.c | 82 +++++++++++++++++++++ drivers/gpu/drm/xen/xen_drm_front_cfg.h | 7 ++ drivers/gpu/drm/xen/xen_drm_front_conn.c | 26 ++++++- drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 3 + drivers/gpu/drm/xen/xen_drm_front_evtchnl.h | 3 + drivers/gpu/drm/xen/xen_drm_front_kms.c | 5 ++ 8 files changed, 194 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c index 013c9e0e412c..cc5981bdbfb3 100644 --- a/drivers/gpu/drm/xen/xen_drm_front.c +++ b/drivers/gpu/drm/xen/xen_drm_front.c @@ -381,6 +381,59 @@ void xen_drm_front_on_frame_done(struct xen_drm_front_info *front_info, fb_cookie); } +int xen_drm_front_get_edid(struct xen_drm_front_info *front_info, + int conn_idx, struct page **pages, + u32 buffer_sz, u32 *edid_sz) +{ + struct xen_drm_front_evtchnl *evtchnl; + struct xen_front_pgdir_shbuf_cfg buf_cfg; + struct xen_front_pgdir_shbuf shbuf; + struct xendispl_req *req; + unsigned long flags; + int ret; + + if (unlikely(conn_idx >= front_info->num_evt_pairs)) + return -EINVAL; + + memset(&buf_cfg, 0, sizeof(buf_cfg)); + buf_cfg.xb_dev = front_info->xb_dev; + buf_cfg.num_pages = DIV_ROUND_UP(buffer_sz, PAGE_SIZE); + buf_cfg.pages = pages; + buf_cfg.pgdir = &shbuf; + buf_cfg.be_alloc = false; + + ret = xen_front_pgdir_shbuf_alloc(&buf_cfg); + if (ret < 0) + return ret; + + evtchnl = &front_info->evt_pairs[conn_idx].req; + + mutex_lock(&evtchnl->u.req.req_io_lock); + + spin_lock_irqsave(&front_info->io_lock, flags); + req = be_prepare_req(evtchnl, XENDISPL_OP_GET_EDID); + req->op.get_edid.gref_directory = + xen_front_pgdir_shbuf_get_dir_start(&shbuf); + req->op.get_edid.buffer_sz = buffer_sz; + + ret = be_stream_do_io(evtchnl, req); + spin_unlock_irqrestore(&front_info->io_lock, flags); + + if (ret < 0) + goto fail; + + ret = be_stream_wait_io(evtchnl); + if (ret < 0) + goto fail; + + *edid_sz = evtchnl->u.req.resp.get_edid.edid_sz; + +fail: + mutex_unlock(&evtchnl->u.req.req_io_lock); + xen_front_pgdir_shbuf_free(&shbuf); + return ret; +} + static int xen_drm_drv_dumb_create(struct drm_file *filp, struct drm_device *dev, struct drm_mode_create_dumb *args) @@ -466,6 +519,7 @@ static void xen_drm_drv_release(struct drm_device *dev) xenbus_switch_state(front_info->xb_dev, XenbusStateInitialising); + xen_drm_front_cfg_free(front_info, &front_info->cfg); kfree(drm_info); } @@ -562,6 +616,7 @@ static int xen_drm_drv_init(struct xen_drm_front_info *front_info) drm_mode_config_cleanup(drm_dev); drm_dev_put(drm_dev); fail: + xen_drm_front_cfg_free(front_info, &front_info->cfg); kfree(drm_info); return ret; } @@ -622,7 +677,14 @@ static int displback_initwait(struct xen_drm_front_info *front_info) static int displback_connect(struct xen_drm_front_info *front_info) { + int ret; + xen_drm_front_evtchnl_set_state(front_info, EVTCHNL_STATE_CONNECTED); + + /* We are all set to read additional configuration from the backend. */ + ret = xen_drm_front_cfg_tail(front_info, &front_info->cfg); + if (ret < 0) + return ret; return xen_drm_drv_init(front_info); } diff --git a/drivers/gpu/drm/xen/xen_drm_front.h b/drivers/gpu/drm/xen/xen_drm_front.h index 54486d89650e..be0c982f4d82 100644 --- a/drivers/gpu/drm/xen/xen_drm_front.h +++ b/drivers/gpu/drm/xen/xen_drm_front.h @@ -112,9 +112,12 @@ struct xen_drm_front_drm_pipeline { struct drm_simple_display_pipe pipe; struct drm_connector conn; - /* These are only for connector mode checking */ + /* These are only for connector mode checking if no EDID present */ int width, height; + /* Is not NULL if EDID is used for connector configuration. */ + struct edid *edid; + struct drm_pending_vblank_event *pending_event; struct delayed_work pflip_to_worker; @@ -160,4 +163,8 @@ int xen_drm_front_page_flip(struct xen_drm_front_info *front_info, void xen_drm_front_on_frame_done(struct xen_drm_front_info *front_info, int conn_idx, u64 fb_cookie); +int xen_drm_front_get_edid(struct xen_drm_front_info *front_info, + int conn_idx, struct page **pages, + u32 buffer_sz, u32 *edid_sz); + #endif /* __XEN_DRM_FRONT_H_ */ diff --git a/drivers/gpu/drm/xen/xen_drm_front_cfg.c b/drivers/gpu/drm/xen/xen_drm_front_cfg.c index ec53b9cc9e0e..f7c45a2fdab3 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_cfg.c +++ b/drivers/gpu/drm/xen/xen_drm_front_cfg.c @@ -45,6 +45,64 @@ static int cfg_connector(struct xen_drm_front_info *front_info, return 0; } +static void +cfg_connector_free_edid(struct xen_drm_front_cfg_connector *connector) +{ + vfree(connector->edid); + connector->edid = NULL; +} + +static void cfg_connector_edid(struct xen_drm_front_info *front_info, + struct xen_drm_front_cfg_connector *connector, + int index) +{ + struct page **pages; + u32 edid_sz; + int i, npages, ret = -ENOMEM; + + connector->edid = vmalloc(XENDISPL_EDID_MAX_SIZE); + if (!connector->edid) + goto fail; + + npages = DIV_ROUND_UP(XENDISPL_EDID_MAX_SIZE, PAGE_SIZE); + pages = kvmalloc_array(npages, sizeof(struct page *), GFP_KERNEL); + if (!pages) + goto fail_free_edid; + + for (i = 0; i < npages; i++) + pages[i] = vmalloc_to_page((u8 *)connector->edid + + i * PAGE_SIZE); + + ret = xen_drm_front_get_edid(front_info, index, pages, + XENDISPL_EDID_MAX_SIZE, &edid_sz); + + kvfree(pages); + + if (ret < 0) + goto fail_free_edid; + + ret = -EINVAL; + if (!edid_sz || (edid_sz % EDID_LENGTH)) + goto fail_free_edid; + + if (!drm_edid_is_valid(connector->edid)) + goto fail_free_edid; + + DRM_INFO("Connector %s: using EDID for configuration, size %d\n", + connector->xenstore_path, edid_sz); + return; + +fail_free_edid: + cfg_connector_free_edid(connector); +fail: + /* + * If any error this is not critical as we can still read + * connector settings from XenStore, so just warn. + */ + DRM_WARN("Connector %s: cannot read or wrong EDID: %d\n", + connector->xenstore_path, ret); +} + int xen_drm_front_cfg_card(struct xen_drm_front_info *front_info, struct xen_drm_front_cfg *cfg) { @@ -75,3 +133,27 @@ int xen_drm_front_cfg_card(struct xen_drm_front_info *front_info, return 0; } +int xen_drm_front_cfg_tail(struct xen_drm_front_info *front_info, + struct xen_drm_front_cfg *cfg) +{ + int i; + + /* + * Try reading EDID(s) from the backend: it is not an error + * if backend doesn't support or provides no EDID. + */ + for (i = 0; i < cfg->num_connectors; i++) + cfg_connector_edid(front_info, &cfg->connectors[i], i); + + return 0; +} + +void xen_drm_front_cfg_free(struct xen_drm_front_info *front_info, + struct xen_drm_front_cfg *cfg) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(cfg->connectors); i++) + cfg_connector_free_edid(&cfg->connectors[i]); +} + diff --git a/drivers/gpu/drm/xen/xen_drm_front_cfg.h b/drivers/gpu/drm/xen/xen_drm_front_cfg.h index aa8490ba9146..f80f47f14697 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_cfg.h +++ b/drivers/gpu/drm/xen/xen_drm_front_cfg.h @@ -19,6 +19,7 @@ struct xen_drm_front_cfg_connector { int width; int height; char *xenstore_path; + struct edid *edid; }; struct xen_drm_front_cfg { @@ -34,4 +35,10 @@ struct xen_drm_front_cfg { int xen_drm_front_cfg_card(struct xen_drm_front_info *front_info, struct xen_drm_front_cfg *cfg); +int xen_drm_front_cfg_tail(struct xen_drm_front_info *front_info, + struct xen_drm_front_cfg *cfg); + +void xen_drm_front_cfg_free(struct xen_drm_front_info *front_info, + struct xen_drm_front_cfg *cfg); + #endif /* __XEN_DRM_FRONT_CFG_H_ */ diff --git a/drivers/gpu/drm/xen/xen_drm_front_conn.c b/drivers/gpu/drm/xen/xen_drm_front_conn.c index 44f1f70c0aed..c98d989a005f 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_conn.c +++ b/drivers/gpu/drm/xen/xen_drm_front_conn.c @@ -66,6 +66,16 @@ static int connector_get_modes(struct drm_connector *connector) struct videomode videomode; int width, height; + if (pipeline->edid) { + int count; + + drm_connector_update_edid_property(connector, + pipeline->edid); + count = drm_add_edid_modes(connector, pipeline->edid); + if (count) + return count; + } + mode = drm_mode_create(connector->dev); if (!mode) return 0; @@ -103,6 +113,7 @@ int xen_drm_front_conn_init(struct xen_drm_front_drm_info *drm_info, { struct xen_drm_front_drm_pipeline *pipeline = to_xen_drm_pipeline(connector); + int ret; drm_connector_helper_add(connector, &connector_helper_funcs); @@ -111,6 +122,17 @@ int xen_drm_front_conn_init(struct xen_drm_front_drm_info *drm_info, connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; - return drm_connector_init(drm_info->drm_dev, connector, - &connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL); + ret = drm_connector_init(drm_info->drm_dev, connector, + &connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL); + if (ret < 0) + return ret; + + /* + * Virtual connectors do not have EDID property, but we do, + * so add it manually if EDID is present. + */ + if (pipeline->edid) + drm_connector_attach_edid_property(connector); + + return 0; } diff --git a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c index e10d95dddb99..af574ef16d84 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +++ b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c @@ -44,6 +44,9 @@ static irqreturn_t evtchnl_interrupt_ctrl(int irq, void *dev_id) continue; switch (resp->operation) { + case XENDISPL_OP_GET_EDID: + evtchnl->u.req.resp.get_edid = + resp->op.get_edid; case XENDISPL_OP_PG_FLIP: case XENDISPL_OP_FB_ATTACH: case XENDISPL_OP_FB_DETACH: diff --git a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.h b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.h index b0af6994332b..8267f40b6549 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.h +++ b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.h @@ -53,6 +53,9 @@ struct xen_drm_front_evtchnl { struct completion completion; /* latest response status */ int resp_status; + union { + struct xendispl_get_edid_resp get_edid; + } resp; /* serializer for backend IO: request/response */ struct mutex req_io_lock; } req; diff --git a/drivers/gpu/drm/xen/xen_drm_front_kms.c b/drivers/gpu/drm/xen/xen_drm_front_kms.c index ef11b1e4de39..d7ff1a656d40 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_kms.c +++ b/drivers/gpu/drm/xen/xen_drm_front_kms.c @@ -288,6 +288,10 @@ display_mode_valid(struct drm_simple_display_pipe *pipe, container_of(pipe, struct xen_drm_front_drm_pipeline, pipe); + /* We have nothing to check if EDID is present. */ + if (pipeline->edid) + return MODE_OK; + if (mode->hdisplay != pipeline->width) return MODE_ERROR; @@ -319,6 +323,7 @@ static int display_pipe_init(struct xen_drm_front_drm_info *drm_info, pipeline->index = index; pipeline->height = cfg->height; pipeline->width = cfg->width; + pipeline->edid = cfg->edid; INIT_DELAYED_WORK(&pipeline->pflip_to_worker, pflip_to_worker);