From: Ralph Sennhauser <ralph.sennhauser@gmail.com>
To: "Rafał Miłecki" <rafal@milecki.pl>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
"Rafał Miłecki" <zajec5@gmail.com>
Subject: Re: [BUG 4.9] New led trigger usbport gets the kernel to panic
Date: Fri, 2 Dec 2016 09:48:18 +0100 [thread overview]
Message-ID: <20161202094818.6b9c1ed2@gmail.com> (raw)
In-Reply-To: <b7fb9a03-a7aa-97e9-0923-de11b71c1951@milecki.pl>
On Thu, 1 Dec 2016 17:56:07 +0100
Rafał Miłecki <rafal@milecki.pl> 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.
Thanks
Ralph
next prev parent reply other threads:[~2016-12-02 8:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-21 8:40 [BUG 4.9] New led trigger usbport gets the kernel to panic Ralph Sennhauser
2016-11-28 22:20 ` Rafal Milecki
2016-12-01 14:28 ` Ralph Sennhauser
2016-12-01 16:56 ` Rafał Miłecki
2016-12-02 8:48 ` Ralph Sennhauser [this message]
2016-12-06 17:26 ` Pavel Machek
2016-12-06 17:29 ` Rafał Miłecki
2016-12-08 8:40 ` Jacek Anaszewski
2016-12-08 10:43 ` Greg Kroah-Hartman
2016-12-08 11:38 ` Rafał Miłecki
2016-12-08 13:46 ` Jacek Anaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161202094818.6b9c1ed2@gmail.com \
--to=ralph.sennhauser@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rafal@milecki.pl \
--cc=zajec5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).