Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4224480pxb; Mon, 1 Feb 2021 16:21:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdTc+AqHJDGUV01aIO3I9woGssXNgyfS02HvwSebQ+w5kVYns18RHheS16iRFI7T2P7Qm1 X-Received: by 2002:a17:906:3fc4:: with SMTP id k4mr19763693ejj.137.1612225292889; Mon, 01 Feb 2021 16:21:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612225292; cv=none; d=google.com; s=arc-20160816; b=cLk+LbVstR/33Xxm/FFHif1laB/C6ljsoctsna4yiJzPqMTJBsn6c89yvyrcPHb2aU q9mXW3pDz/MtBpf4Pynv49hgh6aVpxHQBYdhqI5Er9RcvF7pNidqoT9jk2mRL+un2CEU HTGvfY8lc3/shaj4vJIRWihY/E0tbFpm4QYi9/iSk1mAaLnbneMnWz5jxBQ1H2G4n6ja Vvfawttga/1e3pFf3Hn2J+9FhoGVUH1vCXFS3yBhf4Pz3hmDqTmAV5abikbmggoxS31K oJJ2bUJ+1SVMRUvQqc9gkHfXjoRugLunBP1FJNKc8p+aXhMKarTNaCy2qzLh8sA/EX5M AyzQ== 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=mWUYYAd+OTKy9/NTFkCH99lkpKtcER4Pgzkq/fzD2Rw=; b=V0KISxYkn6PJCGXF/QjA1o1eKBWuoCnehS9TKXU3LZCSOBcdAD0YedxDTXLkPHo6rl iinjVe01MmOX/HjEz5v4K02Ji89yX4FoS6usnhH2mRDx+OewJU4AQ4R4qIDqVKwPAT2s 326Cj6WbrB4emr6IhcZ9DD2+44TSa9tBKKz79RfuLvezVSglKutftGKdEgpjVQXoeUGX C1MozWIMhMWHk8E+0uKJQ/ADYnfISaSo7wc1qT4DT5svwSehvAs3wKoe7MvKKDV/R870 99wB4w21C8LcwDfvW4Isz883cFOWVDMSOjpxCazJhFbeQ0E2jsghlZJnbVR26rqUx+Ks nWnA== 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 w1si10877590ejc.6.2021.02.01.16.21.08; Mon, 01 Feb 2021 16:21:32 -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 S230258AbhBBAUM (ORCPT + 99 others); Mon, 1 Feb 2021 19:20:12 -0500 Received: from mga04.intel.com ([192.55.52.120]:27803 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbhBBAUL (ORCPT ); Mon, 1 Feb 2021 19:20:11 -0500 IronPort-SDR: EfTBTZZSfc5TXItJUyEJ7IIWzyoBjPyFd4lVzNwoh6Xkso0YNXPSRRh7ad5hRRJY8qg+/99ClA SLCEs57OzAUA== X-IronPort-AV: E=McAfee;i="6000,8403,9882"; a="178213566" X-IronPort-AV: E=Sophos;i="5.79,393,1602572400"; d="scan'208";a="178213566" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 16:19:28 -0800 IronPort-SDR: 0el/ZUFk2oKZckT92Xih4Vw1AKkdg8qJ1n/L+8UYAMOCSKxgvGMphrbZkj4Mw7Cf38P0W1qH62 VGks2eAzFX6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,393,1602572400"; d="scan'208";a="432589261" Received: from unknown (HELO coxu-arch-shz.sh.intel.com) ([10.239.160.26]) by orsmga001.jf.intel.com with ESMTP; 01 Feb 2021 16:19:26 -0800 From: Colin Xu To: kraxel@redhat.com, mst@redhat.com, jasowang@redhat.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, colin.xu@intel.com Subject: [PATCH V2] virtio_input: Prevent EV_MSC/MSC_TIMESTAMP loop storm for MT. Date: Tue, 2 Feb 2021 08:19:23 +0800 Message-Id: <20210202001923.6227-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. V2: Rebase. 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