Received: by 10.223.185.116 with SMTP id b49csp54186wrg; Thu, 22 Feb 2018 16:26:18 -0800 (PST) X-Google-Smtp-Source: AH8x226S6uREzrKoEp0TFOy1VOjcJd0Iw87fb4IBS9Lm5LnW8f9/edAgdTgNbNhmxivAfPnnx5rg X-Received: by 10.101.81.76 with SMTP id g12mr7257789pgq.24.1519345578578; Thu, 22 Feb 2018 16:26:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519345578; cv=none; d=google.com; s=arc-20160816; b=hVq20kEn3ER/cZ3exUizJz+EnH+L/7FpkJvizv35C0FpiCKK5Ynj4SPeF6YF6AcR3C hNe/S0lmQefJPROOt+8S9udWZxLfhrMb5ZnoBc0OjIowLGzMUGjj4ksGr1nKEtAV98ZJ 8zVfOP0GepJSaUid6ET1WJv0v/jubU0P1DNmvvIqzq3yPHJLP6MU2aGGUjqA9xcAKsxR RWlrwXA+tyycP/wmCziN7Hwth4a26IrlM2kBi/bws4FJEwy7AZRWCT7lDzgbYHxMFOIO 1LXSe82NT9bSMVvOwsLuje903YFnAvKESZz+foI2xUxpuTojwWJaEPdBx6xtC3r0rzyE SMng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=pkMjEBk1IuS9LfHsiI/uuSGJB9a0kFWY8A8TSsEZGm0=; b=YN0231GojkDkmSGl4MN1qusd4novg/yqaZ5d8kmaPkSmwA34fX/tGqrBPpM6NKjLoa MS1Mlk1EArx3xfX2xpqoDpd6AMqt/KktW2ZNkoYKcoZkRjY2pOHgkw2L8Fj20/dej2zB j6/pRupBqZLg0aWUZ84Vg/9LlZ+EA0GUugkPadbX2Nn0Xrz2HvJ0aYqdugBtw56n8X4T dkaEBKg3jEBfBW6QpBdQSXkZNgUyC7euKb37zCmy/TzQ8ji0qUQ0ZIzsJZJZixdKosKw aza6Tnd4bCcC5HEYjmHgbhKrH17owiZzaRM+9q5I/boBksP6kwQYpl1v4GrXhjmWXnVK nJrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=EoQY5N3p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f26si695767pgn.650.2018.02.22.16.26.03; Thu, 22 Feb 2018 16:26:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=EoQY5N3p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752076AbeBWAY7 (ORCPT + 99 others); Thu, 22 Feb 2018 19:24:59 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:41586 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751723AbeBWAY6 (ORCPT ); Thu, 22 Feb 2018 19:24:58 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1N0Nvpk090649; Fri, 23 Feb 2018 00:24:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=pkMjEBk1IuS9LfHsiI/uuSGJB9a0kFWY8A8TSsEZGm0=; b=EoQY5N3pkq8NJK4c7lwTKqL6Rcpa/L3dPSf9aOxn+VFsL8DduQ+Qmb3CKeJtGEKX7e3b lAKjFczWPNsXdGhsdoE5lK9m4uzYgWkMJ1/Ir/cjQmCTymkAgTHbuLal4KsulIpZXZTc OCKgx33707nv+/ifa89gmGUXpye2egW9zupxXUEyUpH7dcy7or9qHCMcz49XfV5ynDfj 2vHoi3NFUl2mDk1bsHQttlsxw7hrWWxXYoaenfhZf8bk/GHhS+AG5yjz9hFfzSNrn8eC bcC3UFo5lvCIZvZ4FgVBpzuSmEd6WfPzOKQcH0J13JEbd0qXmoE9o7YsQTpHX2xABtfC 4g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2ga7cjr6kh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Feb 2018 00:24:45 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w1N0OiYC017281 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 23 Feb 2018 00:24:44 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1N0OgPO022380; Fri, 23 Feb 2018 00:24:42 GMT Received: from dhcp-burlington7-2nd-B-east-10-152-55-162.usdhcp.oraclecorp.com (/10.152.32.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Feb 2018 16:24:42 -0800 Subject: Re: [PATCH 5/9] drm/xen-front: Implement handling of shared display buffers To: Oleksandr Andrushchenko , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, airlied@linux.ie, daniel.vetter@intel.com, seanpaul@chromium.org, gustavo@padovan.org, jgross@suse.com, konrad.wilk@oracle.com Cc: Oleksandr Andrushchenko References: <1519200222-20623-1-git-send-email-andr2000@gmail.com> <1519200222-20623-6-git-send-email-andr2000@gmail.com> From: Boris Ostrovsky Message-ID: <11ce6c96-1739-435c-4b6f-c9f5d02a2905@oracle.com> Date: Thu, 22 Feb 2018 19:25:18 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1519200222-20623-6-git-send-email-andr2000@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8812 signatures=668677 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=588 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802230002 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/21/2018 03:03 AM, Oleksandr Andrushchenko wrote: > > static int __init xen_drv_init(void) > { > + /* At the moment we only support case with XEN_PAGE_SIZE == PAGE_SIZE */ > + BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE); Why BUILD_BUG_ON? This should simply not load if page sizes are different. > + ret = gnttab_map_refs(map_ops, NULL, buf->pages, buf->num_pages); > + BUG_ON(ret); We should try not to BUG*(). There are a few in this patch (and possibly others) that I think can be avoided. > + > +static int alloc_storage(struct xen_drm_front_shbuf *buf) > +{ > + if (buf->sgt) { > + buf->pages = kvmalloc_array(buf->num_pages, > + sizeof(struct page *), GFP_KERNEL); > + if (!buf->pages) > + return -ENOMEM; > + > + if (drm_prime_sg_to_page_addr_arrays(buf->sgt, buf->pages, > + NULL, buf->num_pages) < 0) > + return -EINVAL; > + } > + > + buf->grefs = kcalloc(buf->num_grefs, sizeof(*buf->grefs), GFP_KERNEL); > + if (!buf->grefs) > + return -ENOMEM; > + > + buf->directory = kcalloc(get_num_pages_dir(buf), PAGE_SIZE, GFP_KERNEL); > + if (!buf->directory) > + return -ENOMEM; You need to clean up on errors. -boris > + > + return 0; > +}