Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4873369imm; Mon, 11 Jun 2018 21:40:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKQ9UzgYwHMHZMaXCBg0+TdTwxRmdG1i48ioPAUXF24eUMagiW11zYJ4OJTkvND651/iktV X-Received: by 2002:a65:63cb:: with SMTP id n11-v6mr1751957pgv.185.1528778414347; Mon, 11 Jun 2018 21:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528778414; cv=none; d=google.com; s=arc-20160816; b=kk0Cq61iygRUEwTq2SS5Yif8Z7Ewg4PxLpb8FkwpWkr0n/dnfxHV61Jl0IM6ubbJRl QWTxkw3Zb7eNpeRF0Q7Q77G3H4uh3B4hVgk3IRWv4EufPGbbS3S8OatRz6TwBvOegumw NbMYQVibRCkDsjIqYBtlHbz4TagsyjdTArTa9V4Xegvv78+hPUd0ki2yNzI0exSZR1fo yoaQ+ztCU/5VB0Vys5vnXkCBvrK1MkVzJWa1zFbteQKdN9lE0eRS1JLM2qEUqSFjyVDZ s2IO0Ek7slwMOZAF9165ZZcGOTz+5TeitS2YcK+1VNAN6O1kmKCoW32juVdeKYKSaFm4 Q7Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:message-id :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject:arc-authentication-results; bh=h+NXAAjVQRi1rQDtZSXVRjA2uW/1x660smD/3jvdnKM=; b=qM5ibfwDiIlThYXRbyLxT52xAueupV5A0bDwD2DxD6SHJF9D5t4FRv7Cfrmz8Vnh0E dXl9YM/JcXJx7RXc2lxo/6G1CIZyStDcoGD46kT1Kz6DBk/AuVbBlSPdmdTju7XyCNrI NUJCiC6lLHN8MP4h4kKfjF/n1AAX490HlCLZrLTJuCl1CHDEKNTyOp94hnjcHTJ4n5MF bXHWd2cSYoJgVZ27+/7MFDfL5Z2RWWqA+lNcivjYvE1M/G9C9TQJtVNM6LaiLrICo/vy DaFEs6hlVZXWLedv3DtAAdn/fJvQX5L8kvbmi7BW94vRDC48/v5rQ1Vtzw/3+1i0Dl1J Q4Lg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21-v6si29847177pgn.262.2018.06.11.21.39.59; Mon, 11 Jun 2018 21:40:14 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754111AbeFLEji (ORCPT + 99 others); Tue, 12 Jun 2018 00:39:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44252 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752832AbeFLEjh (ORCPT ); Tue, 12 Jun 2018 00:39:37 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5C4cudM070151 for ; Tue, 12 Jun 2018 00:39:36 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jj3cf86dm-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 12 Jun 2018 00:39:36 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Jun 2018 05:39:34 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 12 Jun 2018 05:39:31 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5C4dUDq14352400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 12 Jun 2018 04:39:30 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 219EAAE057; Tue, 12 Jun 2018 05:28:22 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 80015AE04D; Tue, 12 Jun 2018 05:28:21 +0100 (BST) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 12 Jun 2018 05:28:21 +0100 (BST) Received: from [10.61.2.125] (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 33CD1A0123; Tue, 12 Jun 2018 14:39:28 +1000 (AEST) Subject: Re: [PATCH] misc: ocxl: Change return type for fault handler To: Souptick Joarder , willy@infradead.org, fbarrat@linux.vnet.ibm.com, arnd@arndb.de, gregkh@linuxfoundation.org Cc: brajeswar.linux@gmail.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, sabyasachi.linux@gmail.com References: <20180611202904.GA25538@jordon-HP-15-Notebook-PC> From: Andrew Donnellan Date: Tue, 12 Jun 2018 14:39:27 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180611202904.GA25538@jordon-HP-15-Notebook-PC> Content-Language: en-AU X-TM-AS-GCONF: 00 x-cbid: 18061204-4275-0000-0000-0000028CB356 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18061204-4276-0000-0000-00003793D58E Message-Id: <86dcb0d4-0539-13e3-1eb2-8e2482e8c07b@au1.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-12_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806120053 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/06/18 06:29, Souptick Joarder wrote: > Use new return type vm_fault_t for fault handler. For > now, this is just documenting that the function returns > a VM_FAULT value rather than an errno. Once all instances > are converted, vm_fault_t will become a distinct type. > > Ref-> commit 1c8f422059ae ("mm: change return type to vm_fault_t") > > There is an existing bug when vm_insert_pfn() can return > ENOMEM which was ignored and VM_FAULT_NOPAGE returned as > default. The new inline vmf_insert_pfn() has removed > this inefficiency by returning correct vm_fault_ type. > > Signed-off-by: Souptick Joarder Looks okay to me Acked-by: Andrew Donnellan > --- > drivers/misc/ocxl/context.c | 22 +++++++++++----------- > drivers/misc/ocxl/sysfs.c | 5 ++--- > 2 files changed, 13 insertions(+), 14 deletions(-) > > diff --git a/drivers/misc/ocxl/context.c b/drivers/misc/ocxl/context.c > index 909e880..98daf91 100644 > --- a/drivers/misc/ocxl/context.c > +++ b/drivers/misc/ocxl/context.c > @@ -83,7 +83,7 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr) > return rc; > } > > -static int map_afu_irq(struct vm_area_struct *vma, unsigned long address, > +static vm_fault_t map_afu_irq(struct vm_area_struct *vma, unsigned long address, > u64 offset, struct ocxl_context *ctx) > { > u64 trigger_addr; > @@ -92,15 +92,15 @@ static int map_afu_irq(struct vm_area_struct *vma, unsigned long address, > if (!trigger_addr) > return VM_FAULT_SIGBUS; > > - vm_insert_pfn(vma, address, trigger_addr >> PAGE_SHIFT); > - return VM_FAULT_NOPAGE; > + return vmf_insert_pfn(vma, address, trigger_addr >> PAGE_SHIFT); > } > > -static int map_pp_mmio(struct vm_area_struct *vma, unsigned long address, > +static vm_fault_t map_pp_mmio(struct vm_area_struct *vma, unsigned long address, > u64 offset, struct ocxl_context *ctx) > { > u64 pp_mmio_addr; > int pasid_off; > + vm_fault_t ret; > > if (offset >= ctx->afu->config.pp_mmio_stride) > return VM_FAULT_SIGBUS; > @@ -118,27 +118,27 @@ static int map_pp_mmio(struct vm_area_struct *vma, unsigned long address, > pasid_off * ctx->afu->config.pp_mmio_stride + > offset; > > - vm_insert_pfn(vma, address, pp_mmio_addr >> PAGE_SHIFT); > + ret = vmf_insert_pfn(vma, address, pp_mmio_addr >> PAGE_SHIFT); > mutex_unlock(&ctx->status_mutex); > - return VM_FAULT_NOPAGE; > + return ret; > } > > -static int ocxl_mmap_fault(struct vm_fault *vmf) > +static vm_fault_t ocxl_mmap_fault(struct vm_fault *vmf) > { > struct vm_area_struct *vma = vmf->vma; > struct ocxl_context *ctx = vma->vm_file->private_data; > u64 offset; > - int rc; > + vm_fault_t ret; > > offset = vmf->pgoff << PAGE_SHIFT; > pr_debug("%s: pasid %d address 0x%lx offset 0x%llx\n", __func__, > ctx->pasid, vmf->address, offset); > > if (offset < ctx->afu->irq_base_offset) > - rc = map_pp_mmio(vma, vmf->address, offset, ctx); > + ret = map_pp_mmio(vma, vmf->address, offset, ctx); > else > - rc = map_afu_irq(vma, vmf->address, offset, ctx); > - return rc; > + ret = map_afu_irq(vma, vmf->address, offset, ctx); > + return ret; > } > > static const struct vm_operations_struct ocxl_vmops = { > diff --git a/drivers/misc/ocxl/sysfs.c b/drivers/misc/ocxl/sysfs.c > index d9753a1..0ab1fd1 100644 > --- a/drivers/misc/ocxl/sysfs.c > +++ b/drivers/misc/ocxl/sysfs.c > @@ -64,7 +64,7 @@ static ssize_t global_mmio_read(struct file *filp, struct kobject *kobj, > return count; > } > > -static int global_mmio_fault(struct vm_fault *vmf) > +static vm_fault_t global_mmio_fault(struct vm_fault *vmf) > { > struct vm_area_struct *vma = vmf->vma; > struct ocxl_afu *afu = vma->vm_private_data; > @@ -75,8 +75,7 @@ static int global_mmio_fault(struct vm_fault *vmf) > > offset = vmf->pgoff; > offset += (afu->global_mmio_start >> PAGE_SHIFT); > - vm_insert_pfn(vma, vmf->address, offset); > - return VM_FAULT_NOPAGE; > + return vmf_insert_pfn(vma, vmf->address, offset); > } > > static const struct vm_operations_struct global_mmio_vmops = { > -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnellan@au1.ibm.com IBM Australia Limited