From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932274AbbHMTm0 (ORCPT ); Thu, 13 Aug 2015 15:42:26 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:55278 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752866AbbHMTmW (ORCPT ); Thu, 13 Aug 2015 15:42:22 -0400 MIME-version: 1.0 Content-type: text/plain; charset=utf-8; format=flowed X-AuditID: cbfec7f4-f79c56d0000012ee-ce-55ccf31b3555 Content-transfer-encoding: 8BIT Message-id: <55CCF319.1070604@samsung.com> Date: Thu, 13 Aug 2015 21:42:17 +0200 From: Krzysztof Opasiak User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 To: Amit Pundir , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-api@vger.kernel.org Cc: Mike Lockwood , Benoit Goby , Colin Cross , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Peter Oh , Greg Hackmann , Badhri Jagan Sridharan , Android Kernel Team , Greg Kroah-Hartman , Jonathan Corbet , Felipe Balbi , Andrzej Pietrasiewicz , Laurent Pinchart , Yegor Yefremov , Philippe Reynes , John Stultz , Sumit Semwal Subject: Re: [RFC][PATCH 2/2] usb: gadget: configfs: notify userspace of usb state changes References: <1439493140-22207-1-git-send-email-amit.pundir@linaro.org> <1439493140-22207-3-git-send-email-amit.pundir@linaro.org> In-reply-to: <1439493140-22207-3-git-send-email-amit.pundir@linaro.org> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsVy+t/xK7rSn8+EGiw8ImrxYcUiRotZL9tZ LN7/vc9mcXvqSSaLg/frLTZs3cposX3jN1aLJwfaGS2OL5vNZtG8eD2bxZnfuhY7totYdE5c wm6x+XsHm8XCtiUsFpd3zWGzWLSsldni36Nt7BZtKxuZLE7d/cxucfLORUaLb68fsjmIeWzb vY3VY9b9s2weO2fdZfdYsKnU4+mEyewesztmsnrcubaHzWP/3DXsHov7JrN69G1Zxehx/MZ2 Jo/Pm+QCeKK4bFJSczLLUov07RK4Mg7e72Mp+CNbsf7rTaYGxi8SXYycHBICJhJdW66wQ9hi EhfurWfrYuTiEBJYyijx984WVpAEr4CgxI/J91i6GDk4mAXkJY5cygYJMwuYSXx5eZgVov45 o8SvzyfZQGp4BbQkzi80BqlhEVCVWD/xGTtImE1AX2LeLlGQsKhAhMT8Y6+ZQVpFBGYzStz/ NosJYuYFVom3M9NBbGGBGImvrf1Q85sZJTYv380MkuAUcJe4+GIR6wRGgVlIzpuFcN4sJOct YGRexSiaWppcUJyUnmuoV5yYW1yal66XnJ+7iRESt192MC4+ZnWIUYCDUYmHd8Oj06FCrIll xZW5hxglOJiVRHgfPT8TKsSbklhZlVqUH19UmpNafIhRmoNFSZx37q73IUIC6YklqdmpqQWp RTBZJg5OqQbGtq6vB8W1XPe8Tpm+tZW/mzVOuKf/VoJq/cJVLPsf9bScUt84dXdd6fe7uZmv kmT3mbhWSNkx1bCw7O2SOTdjudjfyHsBRuorMtonpL+Wr+aLX1u2yCD02hbBrBtC6e8Xn96m yr5fhvvQ+hChQL9rbBW3bmaGun8rLlGdZxH3+N3H8FDnad5KLMUZiYZazEXFiQB4UXL+1wIA AA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 08/13/2015 09:12 PM, Amit Pundir wrote: > This is more of an RFC than an actual submission. There are few > scattered #ifdefs..#endifs here and there which still need to be > taken care of before going for actual submission. > > Currently there is no way with the upstream ConfigFS gadget to > communicate state changes (connected, disconnected, configured), at > the gadget level. Instead such state changes are handled function by > function independently I presume. This is problematic, because some > coordination between the functions, across the state changes, may be > desired at the userspace level. Thus to address this issue, this > patch send uevents to allow userspace to be notified of these usb > state changes, allowing userspace to respond and configure the > configfs gadget appropriately. > > This patch is based on an Android patchset originaly authored by > Badhri Jagan Sridharan to send uevent notifications > to Android userpace for USB state changes. I've folded his patches > together and modified it enough that I don't want him to be blamed for > any mistakes I've made condensing his patches down. > > This patch introduces USB_CONFIGFS_UEVENT Kconfig to handle userspace > notifications of usb state changes, and add setup and disconnect > functions to intercept the setup requests from the usb_core. It also > creates a sysfs device class entry and a device attribute (state) to > read and respond to gadget's current state from userspace. As of now > this sysfs device class (/sys/class/android_usb) and gadget device > (/sys/class/android_usb/android0) with state attribute > (/sys/class/android_usb/android0/state) are strictly tied up to > facilitate Android userspace requests. But going forward we may want > to bring all function devices (hid, printer etc) under a unified usb > gadget device class e.g. /sys/class/usb_gadget/g_{func0,func1} etc.. > > Also I think it make sense to add this state attribute to the configfs > usb gadget itself i.e. have something like /config/usb_gadget/g1/state > to read USB gadget's current state. Since it is going to be consistent > throughout all the functions tied up to that gadget. > > Again this is just an initial RFC, thoughts and feedback would be > greatly appreciated. > > Cc: Mike Lockwood > Cc: Benoit Goby > Cc: Colin Cross > Cc: Arve Hjønnevåg > Cc: Peter Oh > Cc: Greg Hackmann > Cc: Badhri Jagan Sridharan > Cc: Android Kernel Team > Cc: Greg Kroah-Hartman > Cc: Jonathan Corbet > Cc: Felipe Balbi > Cc: Andrzej Pietrasiewicz > Cc: Laurent Pinchart > Cc: Yegor Yefremov > Cc: Philippe Reynes > Cc: John Stultz > Cc: Sumit Semwal > Signed-off-by: Amit Pundir Generally I agree that there should be some way of notifying userspace about gadget state but I'm not sure if this is proper way to go. In my opinion gadget-bus which has been discussed some time ago on linux-usb makes much more sense than this. Maybe I will be wrong but I guess that you are adding this feature to make android mtp-responder working properly in Linux (not android). Again if we use FFS instead of adding mtp function we don't need this notification as mtp-responder can get all the required informations about gadget (function) via ep0 using functionfs events. Best regards, -- Krzysztof Opasiak Samsung R&D Institute Poland Samsung Electronics