From patchwork Wed Oct 23 10:26:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 3087641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4E4DD9F2B7 for ; Wed, 23 Oct 2013 10:26:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1256020149 for ; Wed, 23 Oct 2013 10:26:55 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4C03200E6 for ; Wed, 23 Oct 2013 10:26:53 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VYveM-0000Xy-A1; Wed, 23 Oct 2013 10:26:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VYveJ-0002Vb-FW; Wed, 23 Oct 2013 10:26:47 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VYveG-0002Uh-9I for linux-arm-kernel@lists.infradead.org; Wed, 23 Oct 2013 10:26:45 +0000 Received: from [183.49.44.94] (helo=tom-ThinkPad-T410) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1VYvdr-0002x0-BA; Wed, 23 Oct 2013 10:26:19 +0000 Date: Wed, 23 Oct 2013 18:26:09 +0800 From: Ming Lei To: Lothar =?UTF-8?B?V2HDn21hbm4=?= , tj@kernel.org Subject: Re: userspace firmware load fails with current linux-next Message-ID: <20131023182609.6646b5c0@tom-ThinkPad-T410> In-Reply-To: <20131023110618.7bd07899@ipc1.ka-ro> References: <20131023110618.7bd07899@ipc1.ka-ro> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131023_062644_426611_0684C087 X-CRM114-Status: GOOD ( 19.00 ) X-Spam-Score: -4.6 (----) Cc: tom.leiming@gmail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gregkh@linuxfoundation.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On Wed, 23 Oct 2013 11:06:18 +0200 Lothar Waßmann wrote: > 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. Thank you for the report and analysis. > > 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. > > Is this behavioural change intended? I think no. > 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. > 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? --- Thanks, diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 5d818df..366ae8d 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -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)