From patchwork Thu Jun 29 00:22:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Colberg, Peter" X-Patchwork-Id: 114116 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9300019vqr; Wed, 28 Jun 2023 17:33:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7fcUlwkENx9o3d0sdVU8EUOQf3ByGxGtZqlFdElzum+I/WIKOGu8ajMsJJsHm8PGfiud/3 X-Received: by 2002:a17:902:d509:b0:1af:a349:3f31 with SMTP id b9-20020a170902d50900b001afa3493f31mr44186263plg.3.1687998780487; Wed, 28 Jun 2023 17:33:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687998780; cv=none; d=google.com; s=arc-20160816; b=Ez/RgS11l8HPidv4ez59dtPieJV+yjfQz6oiZqHZ7fbQJ2cHYl6LlXCzpCMaVLlSHw WdzZiVMv3ywEbc1fP3ogkUxtU9913zbH+tu9Q2YSgeazXungA83qzdH8WDpt6S4w2tPY nO1fOi84xDO1yusFecFTUidEXPwmxmW4Il6olnidbBHsuHT7+U7bvvZUJJyCmgEAXoXj sOUYxZHNfA88qT/YeiQWaOmXRMpfuVZczBkQa10P7yRuEgDX9Bj4noACJDci7GluOjK/ mCgW+GprUl9/Zoelb8CV3WoD/YT5kJGpxIEmTXfG+UWYIxV8XYJ4T7763hkGgCYx8o8N 84KA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lZo3e76dEaHgYZfhlU/tXGxipJMdkKGbf6WwGGOiFjk=; fh=SVsvpCQvVVJBWrUB/ZYldlZHNt3BTl4I6EY3ltKz2bE=; b=bsYL9EHOjWIIKjYE6VF0bfQ1NVXojs1PPcUA8yBa1wQkaaUEktbdvs0UexBLVrcGAR VrEmud/u3Lf+/ExcF8MIlJydib4dC1tQjwJ1qj5R08j9Bh4f4xkAkmCq+ptr1EiDmicB vLO29C7ayPgCRfpDkatFt4TXV8uMcxQS09wYGpWIlhMZMxNDbj9wPzVzkWfIyVY+odnN 8pYy85SMcJX6zrxNkfBN3WXW+gAiyOcvmRWJ81kaNo6W4MDJme6i93B2pfSSWYeRvi7a Crd0njdIYVzSoAlfjtAKbuo1ZWreo4vya5XDuNcjgVgaP7b3Ry9ZCNRFTCSmYPnPBiMJ YJiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C8uXwh2i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a170902d49100b001a974fc86casi10310520plg.592.2023.06.28.17.32.46; Wed, 28 Jun 2023 17:33:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C8uXwh2i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbjF2AXP (ORCPT + 99 others); Wed, 28 Jun 2023 20:23:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbjF2AXN (ORCPT ); Wed, 28 Jun 2023 20:23:13 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1A091FE5; Wed, 28 Jun 2023 17:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687998192; x=1719534192; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NSIVlTxQFEP8tWo4aGIX3eAE9P84KZXLcEh9LxBzi54=; b=C8uXwh2iJblUjKMu/kVoYCyz48HTuGDMdcUA8nbDV2bZL0jAZz4XyOP1 2gYcHBxyZFJm5GtQ+5SY33tVnRi5NUNiwfjvaG0oOyWcBIYeLKateIes/ vH3qusoxD0sdxhRzWCyxpiU4H1XSGinYVXB6tC/ItqlR+F2vLZnA3q4+f FIVvG4FeBsP37WfslyK9ccgQp4TAC+us3o+F5tJ87TNCaZJRCRVgmbAgT 2z/IciqehnrHHpoAHXRGQ20xmUltJkHRThadCffi/FyWt4svZoUUGxMWq w/xlIpDNfxu6dr47C3MrZd9nI/0WwOtKcUYSgBAOQ9y+RkY9jOoB+PEil g==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="425662788" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="425662788" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 17:23:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="807122983" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="807122983" Received: from scc823097.zsc7.intel.com ([10.148.153.229]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 17:23:11 -0700 From: Peter Colberg To: hao.wu@intel.com, yilun.xu@intel.com, gregkh@linuxfoundation.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: aaron.j.grier@intel.com, tianfei.zhang@intel.com, russell.h.weight@intel.com, matthew.gerlach@linux.intel.com, marpagan@redhat.com, lgoncalv@redhat.com, Peter Colberg , Andy Shevchenko Subject: [PATCH v3] fpga: dfl: afu: use PFN_DOWN() helper macro Date: Wed, 28 Jun 2023 20:22:55 -0400 Message-Id: <20230629002255.25262-1-peter.colberg@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769995009241384079?= X-GMAIL-MSGID: =?utf-8?q?1769995009241384079?= Replace right shifts by PAGE_SHIFT with PFN_DOWN() helper macro to convert from physical addresses to page frame numbers. These changes are cosmetic only; no functional changes. Suggested-by: Andy Shevchenko Signed-off-by: Peter Colberg Reviewed-by: Andy Shevchenko --- v3: - Revert afu_mmap(), which calculates file offsets, not physical pages v2: - Comment in commit message that changes are cosmetic only --- drivers/fpga/dfl-afu-dma-region.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c index 02b60fde0430..e8d54cfbb301 100644 --- a/drivers/fpga/dfl-afu-dma-region.c +++ b/drivers/fpga/dfl-afu-dma-region.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -34,7 +35,7 @@ void afu_dma_region_init(struct dfl_feature_platform_data *pdata) static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata, struct dfl_afu_dma_region *region) { - int npages = region->length >> PAGE_SHIFT; + int npages = PFN_DOWN(region->length); struct device *dev = &pdata->dev->dev; int ret, pinned; @@ -82,7 +83,7 @@ static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata, static void afu_dma_unpin_pages(struct dfl_feature_platform_data *pdata, struct dfl_afu_dma_region *region) { - long npages = region->length >> PAGE_SHIFT; + long npages = PFN_DOWN(region->length); struct device *dev = &pdata->dev->dev; unpin_user_pages(region->pages, npages); @@ -101,7 +102,7 @@ static void afu_dma_unpin_pages(struct dfl_feature_platform_data *pdata, */ static bool afu_dma_check_continuous_pages(struct dfl_afu_dma_region *region) { - int npages = region->length >> PAGE_SHIFT; + int npages = PFN_DOWN(region->length); int i; for (i = 0; i < npages - 1; i++)