Received: by 10.223.185.116 with SMTP id b49csp27668wrg; Thu, 22 Feb 2018 15:51:56 -0800 (PST) X-Google-Smtp-Source: AH8x227lpHuhJ8Yz2u9I51QOhX1T0hyoHRbZEo3qQwpFRPz7bsjULiJLw3kJmckFSd3f7BcNHniq X-Received: by 10.101.101.204 with SMTP id y12mr7095664pgv.450.1519343516620; Thu, 22 Feb 2018 15:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519343516; cv=none; d=google.com; s=arc-20160816; b=Q47RtNGZ/Rzok/4q/CKIWk28G6BtdoLrcvstoIYbcIhaVqB0pdA5syeILP0VwZCEBg pJ3jxEFqf9ee/RQKODd7aq6as0B/CkUcnPwIOb/ZPXsBab3T00f1+opcx2k3bquNIoib KJunMOCyCEa6iP5mZfYYRMcudzdovlZ7ESXWv9U/iMI845ToQuBewnOlznyVA82fUQ3y lkkb7GvGM8ai92OcB2msSht7Az0q6F+pJlFoaFkf0KzKO1mjaYVx3dXHSo5anBbdtyQe +V/LMJg0Y0Oit6vM8yNlP6CRlZCVsLcLtXuBrdkblKAWzsZMuoWqGhwo032QIqZcr72J u//w== 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=dKPvEzzbbQ02HCcGLAk1HYWQ98nFAEBlVHy75le84o4=; b=oMJ9RLDEvjBU4ubQp34TmQo1/QW9RkABeqxZlNA/fkdLhddgkUQ21WYuWaK/jbN2B4 hEDS48X04Nc+31woRTvnb7uzZIiZQ61OQ/tyUK0JAYBrZ+bIPut8dIDnV7LUI1z8kL+R lm9cRH3+dob8dhgAiSKrpEz/Fad4pkNx2M4rpcij5SnNfP30xIOzoYkfMWz7Tj0uioCa Yvf7AMLCDSwe2tj7f3/dZQ4/DxHsSRLOPWNK3Sg5zKFXPeptjEDi2355IviB69cYLgBO VDtMwBC1riQWDQM/0ICpardofyRcwXACj/KBiEpw1Ifsmn+Q9ce6S6V7MBAz66pTys86 OFsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=jtXBGF7s; 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 i4si674396pgr.266.2018.02.22.15.51.42; Thu, 22 Feb 2018 15:51:56 -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=jtXBGF7s; 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 S1752021AbeBVXuJ (ORCPT + 99 others); Thu, 22 Feb 2018 18:50:09 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:51330 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751345AbeBVXuI (ORCPT ); Thu, 22 Feb 2018 18:50:08 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1MNlKek133284; Thu, 22 Feb 2018 23:49:55 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=dKPvEzzbbQ02HCcGLAk1HYWQ98nFAEBlVHy75le84o4=; b=jtXBGF7s4GgyTqCdWKjucwPt1PdCIcelCayX/OgFo4dl/Abnh6TqMfZeJf5DIcTkuGqc LXKl1onZLBynmMLn0Bb5u2Cp3OidGoLq3tf7MkEMP36E4oNF5ODfPkOY/ZaT8v8QAJT+ hIFQe0SaBjC4q39eK62+NewZRy73GtiCGShYtGnOBZ/KMh7uejcUXBE2UeBWLxGs82as x1Nv8Y30D8ZkUpLwTR4tH7BQIUGNKp9PmBJFZDTcLX3GSaum1t3coV/B2touN59CeOv8 b3ydJT9+JiZM/lzyUJ9KcloafU0+V3KRfwgpy015fTePTFv32OhILcYmLa2lxXuQe6/d NQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2ga7a7g54j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Feb 2018 23:49:55 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1MNnsor010930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2018 23:49:54 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1MNnrZl003577; Thu, 22 Feb 2018 23:49:53 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 15:49:53 -0800 Subject: Re: [PATCH 4/9] drm/xen-front: Implement Xen event channel handling 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-5-git-send-email-andr2000@gmail.com> From: Boris Ostrovsky Message-ID: <395cdaef-db7e-139c-bbf1-28cb33f41f58@oracle.com> Date: Thu, 22 Feb 2018 18:50:32 -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-5-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=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=740 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802220296 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 irqreturn_t evtchnl_interrupt_ctrl(int irq, void *dev_id) > +{ > + struct xen_drm_front_evtchnl *evtchnl = dev_id; > + struct xen_drm_front_info *front_info = evtchnl->front_info; > + struct xendispl_resp *resp; > + RING_IDX i, rp; > + unsigned long flags; > + > + spin_lock_irqsave(&front_info->io_lock, flags); > + > + if (unlikely(evtchnl->state != EVTCHNL_STATE_CONNECTED)) > + goto out; Do you need to check the state under lock? (in other routines too). ... > + > +static void evtchnl_free(struct xen_drm_front_info *front_info, > + struct xen_drm_front_evtchnl *evtchnl) > +{ > + unsigned long page = 0; > + > + if (evtchnl->type == EVTCHNL_TYPE_REQ) > + page = (unsigned long)evtchnl->u.req.ring.sring; > + else if (evtchnl->type == EVTCHNL_TYPE_EVT) > + page = (unsigned long)evtchnl->u.evt.page; > + if (!page) > + return; > + > + evtchnl->state = EVTCHNL_STATE_DISCONNECTED; > + > + if (evtchnl->type == EVTCHNL_TYPE_REQ) { > + /* release all who still waits for response if any */ > + evtchnl->u.req.resp_status = -EIO; > + complete_all(&evtchnl->u.req.completion); > + } > + > + if (evtchnl->irq) > + unbind_from_irqhandler(evtchnl->irq, evtchnl); > + > + if (evtchnl->port) > + xenbus_free_evtchn(front_info->xb_dev, evtchnl->port); > + > + /* end access and free the page */ > + if (evtchnl->gref != GRANT_INVALID_REF) > + gnttab_end_foreign_access(evtchnl->gref, 0, page); > + > + if (evtchnl->type == EVTCHNL_TYPE_REQ) > + evtchnl->u.req.ring.sring = NULL; > + else > + evtchnl->u.evt.page = NULL; > + > + memset(evtchnl, 0, sizeof(*evtchnl)); Since you are zeroing out the structure you don't need to set fields to zero. I also think you need to free the page. -boris