Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp11260pxb; Thu, 7 Jan 2021 19:44:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxaj9XZKcuXTo5IFI0rLRjTz5DEYiFSqIU4ssaW4k+MqpeS5CbDKBzZh/K51qqUYmWaD1Jq X-Received: by 2002:a17:906:5fc9:: with SMTP id k9mr1328517ejv.70.1610077492398; Thu, 07 Jan 2021 19:44:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610077492; cv=none; d=google.com; s=arc-20160816; b=YlB1kONSrMDjpyLVHeqEleoS31vezOIA5y8R+PSZXZeMy19oLTUCYTQl59qlyyl4QP YZPPSEhPuaRWbs7ED8MK4Vtg8MegTuCTE665rf3eYzizrYMMlff+uqn9N1E/PYe2ifO0 suHLNW6r8MW4NkjUxgduh+y5NdRuCg3ifCHRvFGvjRDcE3akOIWC95zIigjgKNtXgs7J dO7EBOGY4A2tmdi7s4IGlAnh+ppqdAJql2YktbwR1wRdhvJdbO7qv/T2mRiUfjtaU+DZ 1eE6NVNa3jPp7kevobiBUZ0kbwQDkVxquX6KvqoA+/y4tAbJCw8LO+Xew9hpMpFPUQSk fmZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=RWEQk1pO5vEV3ZgW84EPmGa8exSuGcpcO1S44Av33gc=; b=dlYzfsLjZccRwytFGtUy+LEoPOGbjUfVMb4iqGMI4Nby82HvCsDEFK2j73RPnr29zc Gx8O3+5LbT0zSw/Zmlm9U1Yx+Ls3zFn66mZ0/EVgGtyLC0kB7/kPlZfl5/l98uuzqmj/ e18piup8CIM6qpMGoyTOCs6uII1wTT5+NIlKXsUarYx75yba8SU9YOLUCft4LUoSi/7x wpRW28WqmBzufE4jvI09YzMrMAnd0FchVrLtb9KOz77Jmp+bDIe5Nr/ibuyg6wZANXos 0M6QdqnW+KJc9+vjjG+CvCcEYnx9FtYmKaKgMQsODnQeGS/omhdUucvi00o0gnFT4gFP vzrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn20si3380706ejc.189.2021.01.07.19.44.28; Thu, 07 Jan 2021 19:44:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727476AbhAHDmS (ORCPT + 99 others); Thu, 7 Jan 2021 22:42:18 -0500 Received: from mga12.intel.com ([192.55.52.136]:47617 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727236AbhAHDmS (ORCPT ); Thu, 7 Jan 2021 22:42:18 -0500 IronPort-SDR: 3e7xUh+hmmpzmmzNebRbx4lFweDcuBwrS2bCjcJJGqGrlDfm/2aTWQwN0dNZ/CZhAqIx3/TQcD ZwVK1qe59qqg== X-IronPort-AV: E=McAfee;i="6000,8403,9857"; a="156718750" X-IronPort-AV: E=Sophos;i="5.79,330,1602572400"; d="scan'208";a="156718750" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jan 2021 19:41:37 -0800 IronPort-SDR: 3Ps9BcQoldNuUzkLTt/ZDENe5nblFF2iLHxdw9VV0drtLwUtEKx4y+6Cw/0Y+5D0/VnWCsoJHO X+bk1teW0ZYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,330,1602572400"; d="scan'208";a="463270096" Received: from unknown (HELO coxu-arch-shz.sh.intel.com) ([10.239.160.33]) by fmsmga001.fm.intel.com with ESMTP; 07 Jan 2021 19:41:35 -0800 From: Colin Xu To: virtualization@lists.linux-foundation.org Cc: kraxel@redhat.com, mst@redhat.com, jasowang@redhat.com, linux-kernel@vger.kernel.org, colin.xu@intel.com Subject: [PATCH] virtio_input: Prevent EV_MSC/MSC_TIMESTAMP loop storm for MT. Date: Fri, 8 Jan 2021 11:41:30 +0800 Message-Id: <20210108034130.499055-1-colin.xu@intel.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In 'commit 29cc309d8bf1 ("HID: hid-multitouch: forward MSC_TIMESTAMP")', EV_MSC/MSC_TIMESTAMP is added to each before EV_SYN event. EV_MSC is configured as INPUT_PASS_TO_ALL. In case of a touch device which report MSC_TIMESTAMP: BE pass EV_MSC/MSC_TIMESTAMP to FE on receiving event from evdev. FE pass EV_MSC/MSC_TIMESTAMP back to BE. BE writes EV_MSC/MSC_TIMESTAMP to evdev due to INPUT_PASS_TO_ALL. BE receives extra EV_MSC/MSC_TIMESTAMP and pass to FE. >>> Each new frame becomes larger and larger. Disable EV_MSC/MSC_TIMESTAMP forwarding for MT. Signed-off-by: Colin Xu --- drivers/virtio/virtio_input.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c index f1f6208edcf5..244965c20d9b 100644 --- a/drivers/virtio/virtio_input.c +++ b/drivers/virtio/virtio_input.c @@ -64,6 +64,21 @@ static int virtinput_send_status(struct virtio_input *vi, unsigned long flags; int rc; + /* + * Since 29cc309d8bf1 (HID: hid-multitouch: forward MSC_TIMESTAMP), + * EV_MSC/MSC_TIMESTAMP is added to each before EV_SYN event. + * EV_MSC is configured as INPUT_PASS_TO_ALL. + * In case of touch device: + * BE pass EV_MSC/MSC_TIMESTAMP to FE on receiving event from evdev. + * FE pass EV_MSC/MSC_TIMESTAMP back to BE. + * BE writes EV_MSC/MSC_TIMESTAMP to evdev due to INPUT_PASS_TO_ALL. + * BE receives extra EV_MSC/MSC_TIMESTAMP and pass to FE. + * >>> Each new frame becomes larger and larger. + * Disable EV_MSC/MSC_TIMESTAMP forwarding for MT. + */ + if (vi->idev->mt && type == EV_MSC && code == MSC_TIMESTAMP) + return 0; + stsbuf = kzalloc(sizeof(*stsbuf), GFP_ATOMIC); if (!stsbuf) return -ENOMEM; -- 2.30.0