Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp908464ybl; Thu, 22 Aug 2019 06:44:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrS1HfCIh/Xq88OytOIe7TYgfEuWJw9am9wqAyEXAmNPpy0aZjKQIehbp2Hnpn6N60T3ja X-Received: by 2002:a17:90a:c086:: with SMTP id o6mr5774175pjs.2.1566481491640; Thu, 22 Aug 2019 06:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566481491; cv=none; d=google.com; s=arc-20160816; b=mOuFSshTLRsS0GJ+2Rcu2BB5UV+1ptAhOa+RU42cnlA36XwkFk6m1dqfYs61Dmf5Zq ZMJXgfiNd9zTyzK9klE7z9lr/RDtnIxEAQLp2t8Odnth30qC3TZdZECdKjJmK+ah2cn7 6t0JH3SsuhSuxVDRGvHTuaPOPPIkQWaNBb06/Je6CK8Bolih+lBKkw5xwjf1C5vFrqOG 54CFijwKgLAdsjt8iRUqjZfeZ8pgrhw4vYVb7cFsJG2jE3y8lKvGxHa2ToWvqNiGZfZ8 53kkc7vyfoiXEEF+3VAdHhsOfW9J+9+h82x5vs34e2IvP4qqEWDtSnHJdt8lYV97Q7Dl jbYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=SvM+Jxyh1cgjS3bgz5/a/pv8yKm4o72cLBsOJbVUAWg=; b=OQJcbUVZFK44gcQZyT5W3HatifiizY7fNN0Sl/iYPkaZEYoXX8bz+fec4R13I4YSxd hKEu9wzxnlWT6c6D19XEoD9M8h+6hEt7DcGJ9rf2gtf69I3Seq/OR9kwBbM1ZRopvgit 8CKboD1qPkHDSKavWgcRD9fexp0WdCdPiRLnECqMOiihTEB3UgSaAd6DDiAfyfAloEMj eaoHZnhWZ8Ue0Uy4zZvlh/npv3wbFzL6gpWTA/FEwlFdWnUk3WXyY9B9LAgyLvGict9A jpil0D8+ipdLGSRGlX6Otl0RjiXaSgRFQTc04AtNXNYAjGdFsnX4701h+yImkX0SVGCR uCvA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si16979773pgu.319.2019.08.22.06.44.36; Thu, 22 Aug 2019 06:44:51 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387751AbfHVKix (ORCPT + 99 others); Thu, 22 Aug 2019 06:38:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:32870 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729113AbfHVKis (ORCPT ); Thu, 22 Aug 2019 06:38:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7AD0CB05C; Thu, 22 Aug 2019 10:38:47 +0000 (UTC) Message-ID: <1566470325.8347.35.camel@suse.com> Subject: Re: [PATCH] HID: quirks: Disable runtime suspend on Microsoft Corp. Basic Optical Mouse v2.0 From: Oliver Neukum To: Kai-Heng Feng Cc: jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Date: Thu, 22 Aug 2019 12:38:45 +0200 In-Reply-To: References: <20190822091744.3451-1-kai.heng.feng@canonical.com> <1566467151.8347.23.camel@suse.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Donnerstag, den 22.08.2019, 18:04 +0800 schrieb Kai-Heng Feng: > Hi Oliver, > > at 17:45, Oliver Neukum wrote: > > > Am Donnerstag, den 22.08.2019, 17:17 +0800 schrieb Kai-Heng Feng: > > > The optical sensor of the mouse gets turned off when it's runtime > > > suspended, so moving the mouse can't wake the mouse up, despite that > > > USB remote wakeup is successfully set. > > > > > > Introduce a new quirk to prevent the mouse from getting runtime > > > suspended. > > > > Hi, > > > > I am afraid this is a bad approach in principle. The device > > behaves according to spec. > > Can you please point out which spec it is? Is it USB 2.0 spec? Well, sort of. The USB spec merely states how to enter and exit a suspended state and that device state must not be lost. It does not tell you what a suspended device must be able to do. > > And it behaves like most hardware. > > So seems like most hardware are broken. > Maybe a more appropriate solution is to disable RPM for all USB mice. That is a decision a distro certainly can make. However, the kernel does not, by default, call usb_enable_autosuspend() for HID devices for this very reason. It is enabled by default only for hubs, BT dongles and UVC cameras (and some minor devices) In other words, if on your system it is on, you need to look at udev, not the kernel. > > If you do not want runtime PM for such devices, do not switch > > it on. > > A device should work regardless of runtime PM status. Well, no. Runtime PM is a trade off. You lose something if you use it. If it worked just as well as full power, you would never use full power, would you? Whether the loss of functionality or performance is worth the energy savings is a policy decision. Hence it belongs into udev. Ideally the kernel would tell user space what will work in a suspended state. Unfortunately HID does not provide support for that. This is a deficiency of user space. The kernel has an ioctl() to let user space tell it, whether a device is fully needed. X does not use them. > > The refcounting needs to be done correctly. > > Will do. Well, I am afraid your patch breaks it and if you do not break it, the patch is reduced to nothing. > > > > This patch does something that udev should do and in a > > questionable manner. > > IMO if the device doesn’t support runtime suspend, then it needs to be > disabled in kernel but not workaround in userspace. You switch it on from user space. Of course the kernel default must be safe, as you said. It already is. Regards Oliver