Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3857621pxb; Mon, 27 Sep 2021 04:22:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRkQjms0Su09qHqOW7r7Qusfj9QYC2WWvtPLtKLIGpMKgrwnGNqYbM/e0aGcK2HSccvilX X-Received: by 2002:a05:6402:373:: with SMTP id s19mr3944218edw.353.1632741734777; Mon, 27 Sep 2021 04:22:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632741734; cv=none; d=google.com; s=arc-20160816; b=v1OD92g3t8Z8wsngXtVIT9aU7jkP7uOdleIACntiC18KdrqbXq/G22t4eBw1Fv4N07 deaUCpJu7HRh8J7ZotP/9bZJhH/5iOrXAxT29eB6m/0xxFXB4oUTQDgnByw1c4/i6hpy 3kMREXm8WhR14+7rd/sWicYNxguhZk5Ok1gIemUhdvl7ATviA9eKwA3XTHURKz5lBjDd T/F1u4jA4Hljnnl7u409Cw1n+k5OEJ/NcBa1kXE09QgSmelF9sTcJ+m3nKh9AKV4Pj3i AQ6MQ8bYdXOUVrvv2FkRCLdrTwb+Xjp+zlWXOE+sZaOtFaH8i9Hjil4cg7EPyiK5LWIp XXSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=fO57LLfiSTAC22YrBciWyJAwa1JIkbf3+4wdzeRfDq8=; b=q4JBoMC3QB2qkR0ejqIsBMbrMxUADCfOu/mr9oxgIwNZKFOtp5twAkmSP3TUnbov7Y 20biHshDZ3AIvjuucEZSep45gXl6+JfqvdOupg9PW6xyqX00SRb+Qbfp810nhq5DwahG KPElozDrxiM8afj2wrhgQnlocRg3Q+DxeC50c1gZ8Tneo9Ntbq8Z4uXxcbQ2t0mEdAnM cq6AxBpdWtmJTwJ7KwC9msbtWVJfTkA0UCSAvN/9nXv+2yPyCakB+7X35OhCYgicKXmw 1ex1vJxwsSubRqYQds/WOwsHao0lv4Jg05o8cmXNH/Y03/Hotw9qdL1mpAuKkHzYZ0YS 0XhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y97si17906263ede.520.2021.09.27.04.21.50; Mon, 27 Sep 2021 04:22:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234053AbhI0LV4 (ORCPT + 99 others); Mon, 27 Sep 2021 07:21:56 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3880 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234033AbhI0LVz (ORCPT ); Mon, 27 Sep 2021 07:21:55 -0400 Received: from fraeml713-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4HJ0VH71Dnz67nPm; Mon, 27 Sep 2021 19:17:43 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml713-chm.china.huawei.com (10.206.15.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Mon, 27 Sep 2021 13:20:15 +0200 Received: from localhost (10.52.124.219) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Mon, 27 Sep 2021 12:20:14 +0100 Date: Mon, 27 Sep 2021 12:20:00 +0100 From: Jonathan Cameron To: William Breathitt Gray CC: Jonathan Cameron , , , , , , , , , , , , , , , , , , Dan Carpenter Subject: Re: [PATCH v16 07/14] counter: Add character device interface Message-ID: <20210927122000.00007d65@Huawei.com> In-Reply-To: References: <422c765c91d060cdebc4f17f7aeb255d9c1a4e16.1630031207.git.vilhelm.gray@gmail.com> <20210912171821.54af145b@jic23-huawei> <20210926161542.5cf99b58@jic23-huawei> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.52.124.219] X-ClientProxiedBy: lhreml707-chm.china.huawei.com (10.201.108.56) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Sep 2021 19:21:17 +0900 William Breathitt Gray wrote: > On Sun, Sep 26, 2021 at 04:15:42PM +0100, Jonathan Cameron wrote: > > On Mon, 20 Sep 2021 19:09:13 +0900 > > William Breathitt Gray wrote: > > > > > On Sun, Sep 12, 2021 at 05:18:42PM +0100, Jonathan Cameron wrote: > > > > On Fri, 27 Aug 2021 12:47:51 +0900 > > > > William Breathitt Gray wrote: > > > > > > > > > This patch introduces a character device interface for the Counter > > > > > subsystem. Device data is exposed through standard character device read > > > > > operations. Device data is gathered when a Counter event is pushed by > > > > > the respective Counter device driver. Configuration is handled via ioctl > > > > > operations on the respective Counter character device node. > > > > > > > > > > Cc: David Lechner > > > > > Cc: Gwendal Grignou > > > > > Cc: Dan Carpenter > > > > > Cc: Oleksij Rempel > > > > > Signed-off-by: William Breathitt Gray > > > > > > > > Hi William, > > > > > > > > Why the bit based lock? It feels like a mutex_trylock() type approach or > > > > spinlock_trylock() would be a more common solution to this problem. > > > > There is precedence for doing what you have here though so I'm not that > > > > worried about it. > > > > > > Hi Jonathan, > > > > > > We originally used a mutex for this, but Jarkko discovered that this > > > produced a warning because chrdev_lock would be held when returning to > > > user space: > > > https://lore.kernel.org/linux-arm-kernel/YOq19zTsOzKA8v7c@shinobu/T/#m6072133d418d598a5f368bb942c945e46cfab9a5 > > > > > > Following David Lechner's suggestion, I decided to reimplement > > > chrdev_lock as a bitmap using an atomic flag. > > > > Ok. I'm not sure bit lock was quite what was intended (as there is only one of them) > > but I suppose it doesn't greatly matter. > > It didn't cross my mind before, but would declaring chrdev_lock as an > atomic_t be a more appropriate solution here because we have only one > flag? > > William Breathitt Gray > It would be less esoteric. This was the first time I've ever come across the bitlock stuff whereas atomics are an every day thing. Thanks, Jonathan