Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753418AbcLHNrG (ORCPT ); Thu, 8 Dec 2016 08:47:06 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:45951 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbcLHNqx (ORCPT ); Thu, 8 Dec 2016 08:46:53 -0500 MIME-version: 1.0 Content-type: text/plain; charset=utf-8; format=flowed X-AuditID: cbfec7f4-f791c6d000006eac-48-5849643c5c41 Subject: Re: [BUG 4.9] New led trigger usbport gets the kernel to panic To: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= Cc: Pavel Machek , Ralph Sennhauser , "open list:LED SUBSYSTEM" , Richard Purdie , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , Linux Kernel Mailing List From: Jacek Anaszewski Message-id: <1fa160df-93e9-b86d-12f1-e9de2d758c0b@samsung.com> Date: Thu, 08 Dec 2016 14:46:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-reply-to: Content-transfer-encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPKsWRmVeSWpSXmKPExsWy7djP87o2KZ4RBou2CFk0L17PZnF51xw2 i61v1jFaLFrWymxx99RRNovdaxcxWZy/dJjRYveup6wWa06mOnB67Jx1l91j/9w17B7np3p6 7Jn/g9Vjxerv7B6fN8kFsEVx2aSk5mSWpRbp2yVwZXw4+pap4KNWxbJj31kbGNeodDFyckgI mEgcOXOOCcIWk7hwbz0biC0ksJRR4kWrSRcjF5D9mVHix5r/TDANbxbtYYZILGOUODb7LgtI gldAUOLH5HtgNrOAlcSzf62sEEXPGCUeH/rGDJIQFnCX6JhwiRXEFhEwl3jS94gJpIhZoJ9Z YuKB/2C72QQMJX6+eM0EMdVOouPRVLBmFgFViYnHvwA1c3CIC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ZAkbm VYwiqaXFuem5xYZ6xYm5xaV56XrJ+bmbGIGxt+3Yz807GC9tDD7EKMDBqMTD6yDvESHEmlhW XJl7iFGCg1lJhHdhkmeEEG9KYmVValF+fFFpTmrxIUZToGMnMkuJJucD00JeSbyhiaG5paGR sYWFuZGRkjhvyYcr4UIC6YklqdmpqQWpRTB9TBycUg2MXY27tmUInKk78LD7YI3a/9Ydd5Q2 Zk3aKHFystBujxaTw3u31a+O3rwiPeR+o9D88xdm5kW13WFS03zjO++YW5/P/F9SGlrSVivP zIw3LAp/3//qRpL9wT3tO19lXNud/fyg3TE7dyNrKXOn8EaDh7e4E5rnHpn9rlLUZBrLD8WP x8P6r83NV2Ipzkg01GIuKk4EAHjaOarTAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161208134635eucas1p1517404f28781dd2408ff8180ece1679e X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?SmFjZWsgQW5hc3pld3NraRtTUlBPTC1TeXN0ZW0gRlcgIChN?= =?UTF-8?B?Qikb7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?SmFjZWsgQW5hc3pld3NraRtTUlBPTC1TeXN0ZW0gRlcgIChN?= =?UTF-8?B?QikbU2Ftc3VuZyBFbGVjdHJvbmljcxtTZW5pb3IgU29mdHdhcmUgRW5naW5l?= =?UTF-8?B?ZXI=?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjc1MjY=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161206173007epcas2p23440ee22a8b8c17d27f18774e20239d1 X-RootMTR: 20161206173007epcas2p23440ee22a8b8c17d27f18774e20239d1 References: <20161121094022.30478a37@gmail.com> <43ea90fb-780a-3612-77dd-265e877ac18e@milecki.pl> <20161201152825.3b2686db@gmail.com> <20161202094818.6b9c1ed2@gmail.com> <20161206172619.GB4406@amd> <6c5ea183-4ef8-7524-034d-69fb388a3a7a@samsung.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5362 Lines: 127 On 12/08/2016 12:38 PM, Rafał Miłecki wrote: > On 8 December 2016 at 09:40, Jacek Anaszewski wrote: >> On 12/06/2016 06:29 PM, Rafał Miłecki wrote: >>> >>> On 6 December 2016 at 18:26, Pavel Machek wrote: >>>> >>>> On Fri 2016-12-02 09:48:18, Ralph Sennhauser wrote: >>>>> >>>>> On Thu, 1 Dec 2016 17:56:07 +0100 >>>>> Rafał Miłecki wrote: >>>>> >>>>>> On 12/01/2016 03:28 PM, Ralph Sennhauser wrote: >>>>>>> >>>>>>> Below the oops with your debug patch applied. >>>>>>> >>>>>>> (...) >>>>>>> >>>>>>> root@wrt1900acs:/# cd sys/class/leds/pca963x\:shelby\:white\:usb2/ >>>>>>> >>>>>>> root@wrt1900acs:/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:shelby:white:usb2# >>>>>>> echo usbport > trigger [ 124.727665] leds >>>>>>> pca963x:shelby:white:usb2: [usbport_trig_add_port] port:dd708240 >>>>>>> [ 124.735266] leds pca963x:shelby:white:usb2: >>>>>>> [usbport_trig_add_port] port->port_name:usb1-port1 >>>>>>> port->data:dd708140 [ 124.745671] leds pca963x:shelby:white:usb2: >>>>>>> [usbport_trig_add_port] port:dd7083c0 [ 124.753194] leds >>>>>>> pca963x:shelby:white:usb2: [usbport_trig_add_port] >>>>>>> port->port_name:usb2-port1 port->data:dd708140 [ 124.763594] leds >>>>>>> pca963x:shelby:white:usb2: [usbport_trig_add_port] port:dd708300 >>>>>>> [ 124.771114] leds pca963x:shelby:white:usb2: >>>>>>> [usbport_trig_add_port] port->port_name:usb3-port1 >>>>>>> port->data:dd708140 >>>>>>> >>>>>>> root@wrt1900acs:/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:shelby:white:usb2# >>>>>>> echo 1 > ports/usb2-port1[ 171.649751] leds >>>>>>> pca963x:shelby:white:usb2: [usbport_trig_port_store] buf:1 >>>>>>> [ 171.649751] size:2 >>>>>>> >>>>>>> [ 171.660160] leds pca963x:shelby:white:usb2: >>>>>>> [usbport_trig_port_store] port:dd7083c0 [ 171.668103] leds >>>>>>> pca963x:shelby:white:usb2: [usbport_trig_port_store] >>>>>>> port->port_name:usb2-port1 port->data:dd708140 [ 171.678678] >>>>>>> [usbport_trig_update_count] usbport_data->count:0 [ 171.684457] >>>>>>> [usbport_trig_update_count] usbport_data->count:0 [ 171.690253] >>>>>>> Unable to handle kernel NULL pointer dereference at virtual address >>>>>>> 00000000 >>>>>> >>>>>> >>>>>> Oh, so this happens a bit later than I expected or I could read from >>>>>> the backtrace. Anyway this debugging was still helpful, I think I can >>>>>> see a possible problem. >>>>>> >>>>>> So most likely the crash happens at the: >>>>>> led_cdev->brightness_set(led_cdev, ...); >>>>>> call. I'm not sure what I was thinking when writing that code. It >>>>>> looks wrong. >>>>>> >>>>>> The thing is some LEDs (drivers) don't provide brightness_set op. >>>>>> It's fine, we should just use brightness_set_blocking op when that >>>>>> happens. Of course kernel has proper helpers for that, we don't have >>>>>> to worry about the choice of op or scheduling the work. I have no >>>>>> idea why I didn't use a proper helper in the first place. >>>>>> >>>>>> So we should simply replace above call with one of following ones: >>>>>> 1) led_set_brightness(led_cdev, ...); >>>>>> 2) led_set_brightness_nosleep(led_cdev, ...); >>>>>> 3) led_set_brightness_sync(led_cdev, ...); >>>>>> >>>>>> I still have to check which one is correct. In theory we don't deal >>>>>> blinking at this point so we shouldn't need to use led_set_brightness. >>>>>> >>>>>> led_set_brightness_nosleep looks like the most likely correct choice. >>>>>> >>>>>> led_set_brightness_sync requires brightness_set_blocking which is not >>>>>> always present so most likely we don't want this one. >>>>>> >>>>>> >>>>>> If you have some free time and you want to play with this, please >>>>>> replace led_cdev->brightness_set >>>>>> with >>>>>> led_set_brightness_nosleep >>>>>> and give it a try. This should fix crashes for you. >>>>>> >>>>>> I'll look at this again during next days. >>>>> >>>>> >>>>> Hi Rafał >>>>> >>>>> I just gave 2) led_set_brightness_nosleep a try. The kernel no longer >>>>> crashes and the led does work as expected. >>>> >>>> >>>> Do you have any patch that needs to be applied? >>> >>> >>> Yes, it has been pushed: >>> >>> https://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=89778ba335e302a450932ce5b703c1ee6216e949 >>> >>> When sending it I didn't Cc linux-leds as get_maintainer.pl didn't >>> pick it. Should we add MAINTAINERS entry for ledtrig-usbport.c maybe? >>> >> >> I haven't tested this trigger earlier, probably due to the fact that >> it was targeted for usb subsystem, sorry about that. Nonetheless, >> I've just tried it on exynos4412-trats2 board and it seems not to >> work properly. >> >> I have the board connected through USB (I have an opened ssh session), >> I'm doing "echo usbport > trigger", then I can see the "ports" >> directory, but it is empty. >> >> Any ideas on the possible reasons? Exynos4412-trats2 uses >> Ethernet Gadget (with CDC Ethernet support) USB Gadget Driver >> for USB networking. > > If board has any USB ports you shouldn't have empty directory. What about: > ls /sys/bus/usb/devices/*/*-port* | grep ":" > As Greg noticed my device in this configuration is not a USB host, but gadget, and its /sys/bus/usb/devices/ dir is empty, so it was false alarm. -- Best regards, Jacek Anaszewski