Received: by 10.192.165.156 with SMTP id m28csp2347254imm; Thu, 12 Apr 2018 12:44:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/rnOcnO2aTMTYEIktx6Rm9lVmVZjaydn10NfMLVDqvlZh9k8ZpzfBj4zMoApOhEhVovbCH X-Received: by 10.99.44.141 with SMTP id s135mr1664840pgs.67.1523562298750; Thu, 12 Apr 2018 12:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523562298; cv=none; d=google.com; s=arc-20160816; b=Re2moxuNwKwYckQxroFqpq+7Y38Q6LMDed5QUW5deI5a8xYeJUd3JCd+bbIUQYJzIn LuYMHNFS8rZGKyRQTcL/UmpbXFLjhiWRetDCH2dbHt4kRVhNQn9oHgGUOGlDIvFQt4Rt gro7EUsGER+zCQSZ3DBu3nl8AziKdpn8od7N7uAfaoUlyX1H/9k8xGtcUgf9GUvEzBv3 dbiw30WYkUOxdyPqqgDN2qmNpjiL9kmUzzHbH3G67beK1AgPmaKxfBKsKQnuhqZxLf1G 20zYaaQDuioAORXbzFhzJshyWVMKkHslV0B1ErTgg4ikxYwP9hxmV1NqGNW8g60upnyM vDrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:cc:to:from :date:arc-authentication-results; bh=YUsakGu9JILhGXvrZ94kDQcquVN0pmVCQVO3W65iyDg=; b=tBv9FuVnAkTkEbeyQqDPl1AMF7YLvWP+RieR09tIbStKI8n2Q19Lp6TMxeKXnj7b0V 8enGel7DoBJQcO0F0s2JEBimTkhaT5iPDzNWls/SXD22mwvsImGR2DhrsFpcbLhCaVkk Jfb4wLh/5MP1qY1BoIZcfsYSlS4+fjuRpNDUZKNAYhpzbXHeHf216LoFMbX5HF0UcTSo 3z0c3ZM3gTdMPDgWdnsiWbdCVjqceyRjOjl0hS8CYmBFAjCsk/Zx2W+0ijgSVX1YKjj8 RwAPpiseURtl5g3C2T/QX+kW6qGoOW7oxnE3Chu+l29v/51VlHFxmo+wAxItvu7SE3/n pwrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si2727540pgn.20.2018.04.12.12.44.45; Thu, 12 Apr 2018 12:44:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752901AbeDLSqP (ORCPT + 99 others); Thu, 12 Apr 2018 14:46:15 -0400 Received: from mail.CARNet.hr ([161.53.123.6]:58187 "EHLO mail.carnet.hr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752561AbeDLSqP (ORCPT ); Thu, 12 Apr 2018 14:46:15 -0400 Received: from cnzgrivvl-t440p.carpriv.carnet.hr ([161.53.12.131]:55916 helo=gavran.carpriv.carnet.hr) by mail.carnet.hr with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1f6hEY-0004gn-IX; Thu, 12 Apr 2018 20:46:11 +0200 Received: by gavran.carpriv.carnet.hr (Postfix, from userid 1000) id A73632390A; Thu, 12 Apr 2018 20:46:08 +0200 (CEST) Date: Thu, 12 Apr 2018 20:46:08 +0200 From: Valentin Vidic To: Marcus Wolf Cc: Greg Kroah-Hartman , Simon =?iso-8859-1?Q?Sandstr=F6m?= , Marcus Wolf , Luca =?iso-8859-1?Q?S=F6the?= , Marcin Ciupak , Michael Panzlaff , Derek Robson , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Message-ID: <20180412184608.GV3257@gavran.carpriv.carnet.hr> References: <20180323094725.4904-1-Valentin.Vidic@CARNet.hr> <20180323114254.GL31333@gavran.carpriv.carnet.hr> <9442615c-5606-328a-f8cc-ad389af55ee3@smarthome-wolf.de> <20180323180027.GM31333@gavran.carpriv.carnet.hr> <20180323221821.GP31333@gavran.carpriv.carnet.hr> <8544b858-673f-0f59-0d8b-0474036068ce@smarthome-wolf.de> <20180325130944.GU31333@gavran.carpriv.carnet.hr> <68bb0145-b144-b442-7ff3-c6080e44f377@smarthome-wolf.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <68bb0145-b144-b442-7ff3-c6080e44f377@smarthome-wolf.de> User-Agent: Mutt/1.9.4 (2018-02-28) X-SA-Exim-Connect-IP: 161.53.12.131 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on rigel.CARNet.hr X-Spam-Level: X-Spam-Status: No, score=-2.9 required=10.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.2 Subject: Re: [PATCH] staging: pi433: add descriptions for mutex locks X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 08, 2018 at 05:22:46PM +0200, Marcus Wolf wrote: > Regarding your patch, I did not understand, why you did not remove > the mutex_lock in pi433_write. Wasn't it the goal to remove it? Is it possible for more than one userspace program to open the pi433 device and send messages? In that case more than one pi433_write could be running and it needs to hold a mutex_lock before calling kfifo_in. > Below find a proposal of pi433_write function, I wrote on base > of my outdated (!), private repo. It is not compiled and not tested. > Since there is no more handling in case of an error (as well in the > propsal as in your patch), I removed the error handling completely. > I only do a test to detect proplems while writing to the tx_fifo, > but (like in your patch) do nothing for solving, just printing a line. > If this unexpected situation will occur (most probably never), > the tx_fifo will be (and stay) out of sync until driver gets unloaded. > We have to decide, whether we can stay with that. Like written above, > I thinkt the benefits are great, the chance of such kind of error > very low. > What do you think? Yes, if there is only one writer and it checks the available size, kfifo_in should not fail. The only problem might be copy_from_user but perhaps that is also quite unlikely. A workaround for that could be to copy the data into a temporary kernel buffer first and than start kfifo writes using only kernel memory. > It could be discussed, whether it is better to return EMSGSIZE or > EAGAIN on the first check. On the one hand, there is a problem with > the message size, on the other hand (if message isn't generally too > big) after a while, there should be some more space available in > fifo, so EAGAIN may be better choice. EAGAIN does seem better unless the message is too big to ever fit in the kfifo. > if (retval != required ) { > dev_dbg(device->dev, "write to fifo failed, reason unknown, non recoverable."); > return -EAGAIN; > } Maybe this should be dev_warn or even dev_crit if the driver is not usable anymore when this happens? The error message should than also be adjusted to EBADF or something similar. -- Valentin