Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1046350ybl; Fri, 10 Jan 2020 11:07:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzNYO5ev/x4jb+E2uRyII2XSeQXFKZR6d2dFxa3DcDIVVz41dxx+IUAd73RhTXty36hEbFe X-Received: by 2002:aca:b3d6:: with SMTP id c205mr3530762oif.67.1578683230965; Fri, 10 Jan 2020 11:07:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578683230; cv=none; d=google.com; s=arc-20160816; b=AgXplmFbuFMU+3cQR713T67wtf3uFOUZkG6KlpcfeEaAAYhjP+yNcFHK4Pz7tVCY67 U03GnuXJ1Cs0Gy7p1PCum93NMoKsOZgHho/gimrOrFv4reCUc8WR89N4FvVz9j4ZenTR 4fOrOX3EO8lHGQ73YRYEbFiNTNAs41DujRfsdDuQalFJDDj+sZkKdc3PfnzrfHXDjG1f VLFS2xpEZEnXYga3AxtuLqGoXgFMDfXbCJjJtOda4MXw+VqZacTuyt/DPdCMsckXCZ3r IWcS5PzOQ7PbES/fJU2zCdtcrExtE5XBCjukrO328w4KMCZizYu7lch5d5S0BqxtJdyn GUEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=MHgz05oZOaycJTUzvHe+/2r6D+V+CAPUNuF1+l0RUqk=; b=pNt3hj72OsPlnCuXD2vNMyQtCp4QIe8SaICruq/ERhHO9ePwx4A294i289C5FG+9IN Vu33xS5WmZndtJ/M+2aojtEe5u1UOmTzum3H/ip8bh+aZvYqOQRyf6Tur9bH2zkJol9s 2vJJqYbIOBQkjXbFyfB3fgbWNftHekOLMTQDdbTh4xjF8FDTfZhp5/8SyrbQMLXS9rBg b7pFGzMvjHZj7qUjGzMLRnJifH47//lTigabeD2uzSgVyJVurWc6n6KZuIEedBLZZjYO axPwKSfMTSo4ewdntwh6X7qaYPdbxaobxpRyjU+fbd5e0eG4WJVcOKpVBuWV4Cc08MBz MaYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=akuQOJ4o; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si1470631oic.140.2020.01.10.11.06.56; Fri, 10 Jan 2020 11:07:10 -0800 (PST) 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; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=akuQOJ4o; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728676AbgAJTFl (ORCPT + 99 others); Fri, 10 Jan 2020 14:05:41 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:53252 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728556AbgAJTFl (ORCPT ); Fri, 10 Jan 2020 14:05:41 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00AJ4GGE101455; Fri, 10 Jan 2020 19:05:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=MHgz05oZOaycJTUzvHe+/2r6D+V+CAPUNuF1+l0RUqk=; b=akuQOJ4oyrHAWCsm1Qeez7Nv1vtW+9n8sxvrA44yFKWjM07BtIuB9c9UCV2ceeiIfhD5 fcXALB3yW5Ym7HofN0nVLwDzwkAhDMLQa2lH+WiYpMQxdXMIiPgKDgKF2nt8IwqmyXfn jx6DbzVey39Sm9YdfSUM77U3azh8MRz7Ru89NkhyOw92HIKtlfX4s48NMcSAFrERCkJQ BzbvVZuCAeFo6IuoNGxV20zPc7LJ5AIxAvRZRuIfyx+8gJASy4gPQ2BL8oaYunc1dQ8J svR8Gbn6/CRGg3c5y0py2nYZycHMISPY5mlPhfDCDB/p3Sx0QvtaowAlxYgcZi9kUGDr mw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2xajnqm1d0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2020 19:05:10 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00AJ3t1e183573; Fri, 10 Jan 2020 19:05:09 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2xedhypum9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jan 2020 19:05:09 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 00AJ59wD014700; Fri, 10 Jan 2020 19:05:09 GMT Received: from paddy.uk.oracle.com (/10.175.192.165) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 10 Jan 2020 11:05:08 -0800 From: Joao Martins To: linux-nvdimm@lists.01.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Alex Williamson , Cornelia Huck , kvm@vger.kernel.org, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Liran Alon , Nikita Leshenko , Barret Rhoden , Boris Ostrovsky , Matthew Wilcox , Konrad Rzeszutek Wilk Subject: [PATCH RFC 06/10] device-dax: Introduce pfn_flags helper Date: Fri, 10 Jan 2020 19:03:09 +0000 Message-Id: <20200110190313.17144-7-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110190313.17144-1-joao.m.martins@oracle.com> References: <20200110190313.17144-1-joao.m.martins@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9496 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=800 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001100154 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9496 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=865 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001100154 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace PFN_DEV|PFN_MAP check call sites with two helper functions dax_is_pfn_dev() and dax_is_pfn_map(). Signed-off-by: Joao Martins --- drivers/dax/device.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index c6a7f5e12c54..113a554de3ee 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -14,6 +14,17 @@ #include "dax-private.h" #include "bus.h" +static int dax_is_pfn_dev(struct dev_dax *dev_dax) +{ + return (dev_dax->region->pfn_flags & (PFN_DEV|PFN_MAP)) == PFN_DEV; +} + +static int dax_is_pfn_map(struct dev_dax *dev_dax) +{ + return (dev_dax->region->pfn_flags & + (PFN_DEV|PFN_MAP)) == (PFN_DEV|PFN_MAP); +} + static int check_vma_mmap(struct dev_dax *dev_dax, struct vm_area_struct *vma, const char *func) { @@ -60,8 +71,7 @@ static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, if (rc < 0) return rc; - if ((dev_dax->region->pfn_flags & (PFN_DEV|PFN_MAP)) == PFN_DEV - && (vma->vm_flags & VM_DONTCOPY) == 0) { + if (dax_is_pfn_dev(dev_dax) && (vma->vm_flags & VM_DONTCOPY) == 0) { dev_info_ratelimited(&dev_dax->dev, "%s: %s: fail, dax range requires MADV_DONTFORK\n", current->comm, func); @@ -140,7 +150,7 @@ static vm_fault_t __dev_dax_pmd_fault(struct dev_dax *dev_dax, } /* dax pmd mappings require pfn_t_devmap() */ - if ((dax_region->pfn_flags & (PFN_DEV|PFN_MAP)) != (PFN_DEV|PFN_MAP)) { + if (!dax_is_pfn_map(dev_dax)) { dev_dbg(dev, "region lacks devmap flags\n"); return VM_FAULT_SIGBUS; } @@ -190,7 +200,7 @@ static vm_fault_t __dev_dax_pud_fault(struct dev_dax *dev_dax, } /* dax pud mappings require pfn_t_devmap() */ - if ((dax_region->pfn_flags & (PFN_DEV|PFN_MAP)) != (PFN_DEV|PFN_MAP)) { + if (!dax_is_pfn_map(dev_dax)) { dev_dbg(dev, "region lacks devmap flags\n"); return VM_FAULT_SIGBUS; } -- 2.17.1