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: 285615 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 863582C012D for ; Wed, 23 Oct 2013 21:26:58 +1100 (EST) 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 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [91.189.89.112 listed in list.dnswl.org] -0.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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)