From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBFB1C433DB for ; Thu, 11 Feb 2021 10:03:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9EB7D64EA1 for ; Thu, 11 Feb 2021 10:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229895AbhBKKDw (ORCPT ); Thu, 11 Feb 2021 05:03:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:48114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbhBKKAL (ORCPT ); Thu, 11 Feb 2021 05:00:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 28C9364E92; Thu, 11 Feb 2021 09:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613037569; bh=Zj8EM5Xx2JdkHBzV0ZcjFswDPawBzyPCgGJvYO+nIu8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AWWZoRuP1RODcWAYJNKCM5+kpL3fmGLyr9DvCV/ZQ2eEJ9z2skeQfz363Q4jD0lYz MpLPk2vG4KdlTlTSuyCCd5cDnCUEfeI0AbHRukiZXBQtUL1zLIkwXtcf/TXrA7psuM wR5GQzW5oQqTSOsmK3tCpvjatd85poXQ9XDi/UOU= Date: Thu, 11 Feb 2021 10:59:26 +0100 From: Greg Kroah-Hartman To: Gustavo Pimentel Cc: "linux-doc@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Andrew Morton , Jonathan Corbet , Bjorn Helgaas Subject: Re: [PATCH v5 1/6] misc: Add Synopsys DesignWare xData IP driver Message-ID: References: <02835da8fc8c9293fecbe666a8db3fb79276fdde.1613034397.git.gustavo.pimentel@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, Feb 11, 2021 at 09:50:33AM +0000, Gustavo Pimentel wrote: > On Thu, Feb 11, 2021 at 9:30:16, Greg Kroah-Hartman > wrote: > > > On Thu, Feb 11, 2021 at 10:08:38AM +0100, Gustavo Pimentel wrote: > > > +static ssize_t write_show(struct device *dev, struct device_attribute *attr, > > > + char *buf) > > > +{ > > > + struct pci_dev *pdev = to_pci_dev(dev); > > > + struct dw_xdata *dw = pci_get_drvdata(pdev); > > > + u64 rate; > > > + > > > + mutex_lock(&dw->mutex); > > > + dw_xdata_perf(dw, &rate, true); > > > + mutex_unlock(&dw->mutex); > > > + > > > + return sysfs_emit(buf, "%llu MB/s\n", rate); > > > > Do not put units in a sysfs file, that should be in the documentation, > > otherwise this forces userspace to "parse" the units which is a mess. > > Okay. > > > > > Same for the other sysfs file. > > > > And why do you need a lock for this show function? > > Maybe I understood it wrongly, please correct me in that case. The > dw_xdata_perf() is called on the write_show() and read_show(), to avoid a > possible race condition between those calls, I have added this mutex. What race? If the value changes with a write right after a read, what does it matter? What exactly are you trying to protect with this lock? thanks, greg k-h