Received: by 10.223.185.116 with SMTP id b49csp340082wrg; Thu, 22 Feb 2018 23:01:11 -0800 (PST) X-Google-Smtp-Source: AH8x225b1O00J27s/Bg0htPMz4ZJkLRlkTHZi/z27jqzmud6kfz2YhOrNTyydXmjmcR68CEcQMnQ X-Received: by 10.99.103.195 with SMTP id b186mr647244pgc.446.1519369271654; Thu, 22 Feb 2018 23:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519369271; cv=none; d=google.com; s=arc-20160816; b=mGvwTeHxZOhhRfhXs+fwIRkYMuvXSRAsVeATnAx18/ssj7721GBCAP+obmN7H31oMm gi1IxkkHXJaqPWnn7S/2T6gM934aBAlBCEF2WNzZSy5RAQFEBZ3wGfcm4bdbZ8Lzxsll 3BtebkSXV3+N1DryrgUL4AlXEZhG0weW1h7WqtqmtrkVbPFfs5xcw15XNJLQF89U/hS/ OfL7EcfMil75F9QkJaj9SALFy971T60HLKcKhHHQ/Ia3dPjwCZWsyWodi8c9rcC28EiL 2bNjjbcJRrq3LN75dBjN3wyLjJJj3KuxnI90HedBp+iubuZRnW2LZhXuBHKCMeQTkzK2 5y3A== 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=+yNZGvMSOqQkBCQxLdDEzSvC3T70EAVKhNBAKfki1Zw=; b=t/Ly4Ada1FnBv8Fdks9ItchMVseNpwFrdkC0VgXyL/eCJ9szXfVqRk6Bo8jV9C0wQu VQwIzZWr9AHijRzYnIU4coNHLVbrym8+j3QpNj7CO+nWm80kIbHZmwljBF8kRVKk5XVP 16cvpPCvs3fiFvXqpsDvXF/3HesRE58Cnm7gNxVazOQTSLnY8vdlUo5OnF6898fMdBV9 cU78ekr3p4Cc95wIS5yTvPJLBW8JKLCPG6cuNb9TDJvOfkAsuVgAU67tN4akEj4hem5t vI6nN+FrsBSweyREfdJApm/DNxn7PomKZkZJogbADJtOZfRF3E/Vh+t7BrftuBGfoH/c xFAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pJ1eeGlA; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si1354642pll.581.2018.02.22.23.00.57; Thu, 22 Feb 2018 23:01:11 -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=@gmail.com header.s=20161025 header.b=pJ1eeGlA; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751515AbeBWHAS (ORCPT + 99 others); Fri, 23 Feb 2018 02:00:18 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:44015 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751353AbeBWHAQ (ORCPT ); Fri, 23 Feb 2018 02:00:16 -0500 Received: by mail-lf0-f67.google.com with SMTP id q69so10925791lfi.10 for ; Thu, 22 Feb 2018 23:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=+yNZGvMSOqQkBCQxLdDEzSvC3T70EAVKhNBAKfki1Zw=; b=pJ1eeGlAo9I0QddGsVUe6jLMXu3E76e/plsO2WVOiQssNcKuPnTgXQcsy+L14UqVGh Q1Kx0jrFG1GKrRpcH+sUDLrr8lM8ztNnJpOpHnB5i+GKmyEKUoH9mMj8R+10wyxyChVW eaZKNfE72AfSQ8SrClL4rp19olP9IPOQ2DLPs52dEshe8NRa4w5KXidyIZOvIUzWV6q2 AwE0x+L/GuJ4ULCw68aSc4hereroLPdi2na0SVBAlGwJMbjDXk0G9VuAMUI/zsa7zkU7 PGgSgFInUG+Vtow8zrMxlLfBrb+JbB4rVSRV+jEpywACvfDMBf5UsUYOCvEMATOl51em RJag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=+yNZGvMSOqQkBCQxLdDEzSvC3T70EAVKhNBAKfki1Zw=; b=jojEdpe0EQ+BzKVYi6JvWkJlfSccKTAyJRJlLY8HHx78cBWNgJ6WcIthFSrANISrO3 JbjsyJtnrGZBQDyKquMg7Hlp+1QgzrwSoUAVNMgyJkulVebDy2d0FxZ3jrqUFvhpqO3S LMXYGOiVS/eMdi+v2wIeSlK/9YvnXRRUDNGjkU8R6KBHy7WSJOqY507ULcI2kz/p08JO KRLaQtjQFuI+rcjhY+8BncEFHp3dleAMx4mAv5EuZ3nO59BMt8GD3iLNVGFjdr+XFjyc qkzLNMBCjH2txyrmT8NOQTpYMgJzdAMUoJo6P9j5U41QSxTemBZqL7xJHtctu0PabfPZ vIBQ== X-Gm-Message-State: APf1xPAMQlzfPVhoXMCnxjh9PW6MGx5njfIkoYPN3ikanNx5IS/V48YM n5+NaTcRnM1sPMF6DfQ/8hM= X-Received: by 10.25.100.21 with SMTP id y21mr549258lfb.135.1519369215175; Thu, 22 Feb 2018 23:00:15 -0800 (PST) Received: from [10.17.182.9] (ll-53.209.223.85.sovam.net.ua. [85.223.209.53]) by smtp.gmail.com with ESMTPSA id g24sm339530lje.97.2018.02.22.23.00.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Feb 2018 23:00:14 -0800 (PST) Subject: Re: [PATCH 4/9] drm/xen-front: Implement Xen event channel handling To: Boris Ostrovsky , 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> <395cdaef-db7e-139c-bbf1-28cb33f41f58@oracle.com> From: Oleksandr Andrushchenko Message-ID: <5145287f-40b0-c8e2-1b37-36d7e8cac908@gmail.com> Date: Fri, 23 Feb 2018 09:00:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <395cdaef-db7e-139c-bbf1-28cb33f41f58@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/23/2018 01:50 AM, Boris Ostrovsky wrote: > 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). not really, will move out of the lock in interrupt handlers other places (I assume you refer to be_stream_do_io) it is set under lock as a part of atomic operation, e.g. we get a new request pointer from the ring and reset completion So, those places still seem to be ok > ... > >> + >> +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. good catch, thank you > I also think you need to free the page. it is freed by gnttab_end_foreign_access, please see [1] > -boris [1] https://elixir.bootlin.com/linux/v4.11-rc1/source/drivers/xen/grant-table.c#L380