userspace firmware load fails with current linux-next
Hi,
with the current linux-next loading firmware from userspace fails because when writing to /sys/class/firmware/*/data the return code is always 0 (meaning to the userspace too that no data was written). Thus the userspace tool (mdev) keeps writing the same block of data over and over again.
A cursory check of the latest updates to /drivers/base/firmware* didn't reveal anything that could be the cause of this misbehaviour.
Interestingly when changing the .size member of the
struct bin_attribute firmware_attr_data in drivers/base/firmware_class.c (which is now '0') to e.g. PAGE_SIZE firmware loading works again.
Since .size was at '0' since the beginning of the .git universe there must have been a fundamental change in the guts of the kernel handling sysfs attribute files.
Is this behavioural change intended?
Do all sysfs attributes that are created with zero size need to be changed?
Or is it an unintended side effect of some recent change?
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
Hi,
Quoted 8 lines · On Wed, 23 Oct 2013 11:06:18 +0200 Lothar Wa?mann <[email protected]>…
Hi,
with the current linux-next loading firmware from userspace fails because when writing to
/sys/class/firmware/*/datathe return code is always 0 (meaning to the userspace too that no data was written). Thus the userspace tool (mdev) keeps writing the same block of data over and over again.
Quoted 6 lines
A cursory check of the latest updates to /drivers/base/firmware* didn't reveal anything that could be the cause of this misbehaviour.
Interestingly when changing the .size member of the
structbin_attributefirmware_attr_dataindrivers/base/firmware_class.c(which is now '0') to e.g.PAGE_SIZEfirmware loading works again.
Thank you for the report and analysis.
Quoted 4 lines
Since .size was at '0' since the beginning of the .git universe there must have been a fundamental change in the guts of the kernel handling sysfs attribute files.
It may be introduced by Tejun's recent change.
Quoted 2 lines
Is this behavioural change intended?
I think no.
Quoted 2 lines
Do all sysfs attributes that are created with zero size need to be changed?
I think no, since drivers have no idea of size of their firmwares.
Quoted 1 line
Or is it an unintended side effect of some recent change?
Maybe yes, could you test below patch?
Tejun, looks we need to keep special attention on zero size of bin file as before, could you comment at the patch?
--
fs/sysfs/file.c +1 -1
@@ -277,7 +277,7 @@ static ssize_t sysfs_write_file(struct file *file, const char __user *user_buf,ssize_t len =min_t (size_t, count,PAGE_SIZE );char *buf; -if (sysfs_is_bin (of->sd)) { +if (sysfs_is_bin (of->sd) && size) {loff_t size =file_inode (file)->i_size;if (size <= *ppos)
Thanks,
Signature · 1 line
Ming Lei
Hi,
Quoted 3 lines · Ming Lei
On Wed, 23 Oct 2013 11:06:18 +0200
Lothar Wa?mann <[email protected]> wrote:
[...]
Quoted 16 lines
Quoted 1 line
Or is it an unintended side effect of some recent change?
Maybe yes, could you test below patch?
Tejun, looks we need to keep special attention on zero size of bin file as before, could you comment at the patch?
--
fs/sysfs/file.c +0
-0
fs/sysfs/file.c static ssize_t sysfs_write_file(struct file *file, const char __user *user_buf, · line 283
Quoted 8 lines
fs/sysfs/file.c +1
-1@@ -277,7 +277,7 @@ static ssize_t sysfs_write_file(struct file *file, const char __user *user_buf,ssize_t len =min_t (size_t, count,PAGE_SIZE );char *buf; -if (sysfs_is_bin (of->sd)) { +if (sysfs_is_bin (of->sd) && size) {loff_t size =file_inode (file)->i_size;if (size <= *ppos)
The patch as is produces a build error, because 'size' is only defined after the 'if' statement.
The modified patch below works for me.
fs/sysfs/file.c +1 -1
@@ -277,7 +277,7 @@ static ssize_t sysfs_write_file(struct file *file, const char __user *user_buf,ssize_t len =min_t (size_t, count,PAGE_SIZE );char *buf; -if (sysfs_is_bin (of->sd)) { +if (sysfs_is_bin (of->sd) &&file_inode (file)->i_size) {loff_t size =file_inode (file)->i_size;if (size <= *ppos)
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | [email protected] ___________________________________________________________
Quoted 2 lines · Lothar Wa?mann
The patch as is produces a build error, because 'size' is only defined after the 'if' statement.
Sorry for that, :-)
Quoted 8 lines
The modified patch below works for me.
fs/sysfs/file.c +0
-0
fs/sysfs/file.c static ssize_t sysfs_write_file(struct file *file, const char __user *user_buf, · line 283
Quoted 8 lines
fs/sysfs/file.c +1
-1@@ -277,7 +277,7 @@ static ssize_t sysfs_write_file(struct file *file, const char __user *user_buf,ssize_t len =min_t (size_t, count,PAGE_SIZE );char *buf; -if (sysfs_is_bin (of->sd)) { +if (sysfs_is_bin (of->sd) &&file_inode (file)->i_size) {loff_t size =file_inode (file)->i_size;if (size <= *ppos)
OK, thanks for your test, and will prepare a formal one later.
Thanks,
--
Ming Lei