From patchwork Fri Dec 19 11:59:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 5518891 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1959BEEA8 for ; Fri, 19 Dec 2014 12:00:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B2B820120 for ; Fri, 19 Dec 2014 12:00:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 069DE2011E for ; Fri, 19 Dec 2014 12:00:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752446AbaLSL7r (ORCPT ); Fri, 19 Dec 2014 06:59:47 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:60864 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752432AbaLSL7o (ORCPT ); Fri, 19 Dec 2014 06:59:44 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id sBJBxh2u014964; Fri, 19 Dec 2014 05:59:43 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id sBJBxhJ9008726; Fri, 19 Dec 2014 05:59:43 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Fri, 19 Dec 2014 05:59:43 -0600 Received: from [172.22.232.88] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id sBJBxfRE014580; Fri, 19 Dec 2014 05:59:42 -0600 Message-ID: <5494132D.50204@ti.com> Date: Fri, 19 Dec 2014 13:59:41 +0200 From: Tomi Valkeinen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Martin Jackson , Subject: Re: msync on fbdev References: In-Reply-To: Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, 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 On 18/12/14 15:55, Martin Jackson wrote: > Dear fbdev developers, > > This relates to the core implementation of fbdev with the > CONFIG_FB_DEFERRED_IO option enabled. > > I believe I have found a bug when doing msync(2) on a framebuffer > device. We are using an old (2.6.37) kernel on an embedded plaform, > but if I look at the current torvalds kernel (fbdev kernel looks > rather old!?), the bug seems to still be there. > > When looking at the msync(2) man page, msync is meant to return 0 on > success and -1 on failure, however we are seeing it return 1, which is > undocumented and in my opinion wrong. > > This is because the fb_deferred_io_fsync method returns the code from > 'schedule_delayed_work', which is either 0 or 1 depending on whether > the work was already scheduled, leading to the possibility that msync > returns the value 1 to userland. Indeed, looks broken. schedule_delayed_work() never returns an error, it just returns a bool telling if the work was already scheduled. I guess no one really uses deferred io much =). Here's a patch: From 9cc80b3cf9d6023ede084d024ed8b5c0cb247bc2 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 19 Dec 2014 13:55:41 +0200 Subject: [PATCH] video/fbdev: fix defio's fsync fb_deferred_io_fsync() returns the value of schedule_delayed_work() as an error code, but schedule_delayed_work() does not return an error. It returns true/false depending on whether the work was already queued. Fix this by ignoring the return value of schedule_delayed_work(). Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/core/fb_defio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c index 900aa4ecd617..d6cab1fd9a47 100644 --- a/drivers/video/fbdev/core/fb_defio.c +++ b/drivers/video/fbdev/core/fb_defio.c @@ -83,9 +83,10 @@ int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasy cancel_delayed_work_sync(&info->deferred_work); /* Run it immediately */ - err = schedule_delayed_work(&info->deferred_work, 0); + schedule_delayed_work(&info->deferred_work, 0); mutex_unlock(&inode->i_mutex); - return err; + + return 0; } EXPORT_SYMBOL_GPL(fb_deferred_io_fsync);