Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1285985pxb; Wed, 20 Oct 2021 01:55:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOwtNEVWC5LNcVjX5ufWtfew3U4VRwttZJlPixFLC7gIby8en80BheLFEFVqkXeraydkBK X-Received: by 2002:a17:90a:3ec2:: with SMTP id k60mr6059813pjc.176.1634720107168; Wed, 20 Oct 2021 01:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634720107; cv=none; d=google.com; s=arc-20160816; b=cP+do9cnptG0XoWr/6uYGFcmyLGcykUVXOhT8Bl3xQPV2kZf3QH9Yh6zgzgel8XWJG c8G/x9pAQCqO3vmyFipaSbssKAAg419/0YQg86vU/4eADWrUPw9U7t5CHeoQqrUqIev1 m2fepUNMQvtcadKHF4RK/0i3hUkZd+h5TkfZIw3cq6CfFJYWl4BuPzrPXkjHJy7OLkks eMRguIvr4O6hkzgjRJCkc+4dYWi+rwEhcQ5SdBMHYj1Y92WzN1zPBWB6/uDGXejXq/+G i+ZDGPSrfbphCcXJqTqwfEBJnBfo8piYpTRh9CLUwOi3z5r/Tj3rBXvaXucDf9WFfvcS Bt+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZnE0AcRg82DVU+U43AJYy2VXt6N77lOD0q+Ez9m4ZHQ=; b=bxpkn808bZjPKQRe70+gr8UEUm/p+LJVhC35AqkTgf8pQbzsgbJTf4tBBoYrgK+Kqx JRPtahSk7dEwhwmGm5rdb167g0HazgBB32lY6UEEbMkNGDT1RZS7iEid560od+LJTKky L1BAJVouMj8e6C53aKRj8BcDXrKxTFN0DYMXbSv7TA2WD0KF1U0hZX9/NxYsZFTXkdNt aVsMpfRjxJc+Hw350eRz87VQ6VxQpqU2ZwRmpX/QJL1wgRpPW8LujSmzXFD0Q0znnKX0 Y9wwBYOH9bqmQe6cC5okS4+cU0yDBtEgWPhb7tUskFXVNloTAcQW8fFMZsOYzHlQ4qYx Yhww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iDLsTZFn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si2097080pgj.19.2021.10.20.01.54.54; Wed, 20 Oct 2021 01:55:07 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iDLsTZFn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbhJTIz2 (ORCPT + 99 others); Wed, 20 Oct 2021 04:55:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:47734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbhJTIz1 (ORCPT ); Wed, 20 Oct 2021 04:55:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A12A86103D; Wed, 20 Oct 2021 08:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634719993; bh=gsHQEAy2iXwhqCCwd80U1OyWDfuz5ks3Q6+JnbpUrTU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iDLsTZFnej0t/d9a9GTCv08jcJfvXYUdigE8URPhvZaK8ykEgrfD7YwbjDPF5RcI2 I4zp6CY+9wVOJ9g+vFvtV5As4CeT+8WBJIRgS4PnWaP1YNC3IZQPShGE5eRwU+u3nN ABuxDQ7aMmnR32vucRTDpgfI/VGteFcNKr4ykW38RiardLMNh4ETxRLocItjUnZ92S T9EE5+XWEJQ/ieiTJBKQG0oDfOG1zVu6EKWjtkoiYv+VlbcgY+67SsZvvfzbsZdOTE vy2q6KrT7eqYBizOcHPkYc40PcM+Hrhf0/aQnmYxiwTTmuPNDqWMx7kn9aSP6ZuxoG OQx0ydAyVFwhg== Date: Wed, 20 Oct 2021 11:53:05 +0300 From: Mike Rapoport To: Greg Kroah-Hartman Cc: Chen Yu , linux-acpi@vger.kernel.org, Ard Biesheuvel , "Rafael J. Wysocki" , Len Brown , linux-kernel@vger.kernel.org, Ashok Raj , Andy Shevchenko , Aubrey Li Subject: Re: [PATCH v4 3/4] drivers/acpi: Introduce Platform Firmware Runtime Update Telemetry Message-ID: References: <838245e376c7e6fd0fe1ef55d004ed53763846a2.1634310710.git.yu.c.chen@intel.com> <20211020082939.GA44221@chenyu-desktop> 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-kernel@vger.kernel.org On Wed, Oct 20, 2021 at 10:27:28AM +0200, Greg Kroah-Hartman wrote: > On Wed, Oct 20, 2021 at 04:29:39PM +0800, Chen Yu wrote: > > > > +ssize_t pfru_log_read(struct file *filp, char __user *ubuf, > > > > + size_t size, loff_t *off) > > > > +{ > > > > + struct pfru_log_data_info info; > > > > + phys_addr_t base_addr; > > > > + int buf_size, ret; > > > > + char *buf_ptr; > > > > + > > > > + if (!pfru_log_dev) > > > > + return -ENODEV; > > > > + > > > > + if (*off < 0) > > > > + return -EINVAL; > > > > + > > > > + ret = get_pfru_log_data_info(&info, pfru_log_dev->info.log_type); > > > > + if (ret) > > > > + return ret; > > > > + > > > > + base_addr = (phys_addr_t)(info.chunk2_addr_lo | (info.chunk2_addr_hi << 32)); > > > > + /* pfru update has not been launched yet.*/ > > > > + if (!base_addr) > > > > + return -EBUSY; > > > > + > > > > + buf_size = info.max_data_size; > > > > + if (*off >= buf_size) > > > > + return 0; > > > > + > > > > + buf_ptr = memremap(base_addr, buf_size, MEMREMAP_WB); > > > > + if (IS_ERR(buf_ptr)) > > > > + return PTR_ERR(buf_ptr); > > > > + > > > > + size = min_t(size_t, size, buf_size - *off); > > > > + if (copy_to_user(ubuf, buf_ptr + *off, size)) > > > > + ret = -EFAULT; > > > > + else > > > > + ret = 0; > > > > > > As all you are doing is mapping some memory and reading from it, why do > > > you need a read() file operation at all? Why not just use mmap? > > > > > In the beginning mmap() interface was provided to the user. Then it was > > realized that there is no guarantee in the spec that, the physical address > > provided by the BIOS would remain unchanged. So instead of asking the user > > to mmap the file each time before reading the log, the read() is leveraged > > here to always memremap() the latest address. > > So you are forced to memremap on _EVERY_ read call because the BIOS can > change things underneath us without the kernel knowing about it? How > does the chunk2_addr_lo and _hi values change while the system is > running? Where does that happen, and isn't this going to be a very slow > and expensive read call all the time? And maybe it is something that can be fixed in the spec so that the address will remain constant? (I realise it's wishful thinking, but sill...) -- Sincerely yours, Mike.