Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4800513ooa; Tue, 14 Aug 2018 10:43:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyOUDEcm3sz7rXc369tcgu4i7qgjlGvns15arDKzXSf+Dkha/z6B+f+oCI8pJ6Ce+iN0IKe X-Received: by 2002:a63:a1a:: with SMTP id 26-v6mr22186697pgk.221.1534268630850; Tue, 14 Aug 2018 10:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268630; cv=none; d=google.com; s=arc-20160816; b=LkzYh0ax+9Q9gxiaHxIbOH/m/3s2Eg+VjJHgcjQ1K4lUrLf+0GayZak5n6sadkLptb gbrEmkYTrLrQiI8q2niZgZ+pR2PGZqMi0cNAhxifwojU+e1tNDsch6N6g+X9COGZLh2A /NDa0gTqVM2k/4oRqLD+kT2COZUXltB1f/vnIUAlHpDFTPbnUyJP4Ifu/tXT2HfAtydG 2yRiPIsWqryX8nrJy9i+WRwpDmX8/yYHW/pb6icvOh5SWLetJhrFeoVjYer2dvulwpaA VHTY/7484fKFtg9Y8rjR2rQBs5ORJU6jp57wwI+AhJYz9iiW+ookSZ5aKBJ3y03BnRCX LeOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=xhMo8CXCtbzAhj9G6+loIaKEZtwDQ3gw2CfoPfRYpEg=; b=oErI8et0inNnTFieoNpjl1//Mugqf9hW4TYnwmvrhY0RW1cPREhC/2f0ejjHXZmxHb HXtG37Wn8SFpUSsPOkVly2UbXA8xORX6LN+b6e0y6bbiJRGQozaE3XZdUdiaGUGl8/Y9 7x/acoiG8DnPa6IPdGJFrEKEIM1XgiaKww8uno1ZhpnuBip2M0lAD6B51iWTMmz3QQAU 0Fk0uALaooS03aIYIoNm/Zbe59DlZHSc9dDMhabPoG2ErUNZUCWjkhtE3L1GZvJCu3sX xKdW/R9c8syXmqIC+qK7St+02PuN7zR61+Iv3OOfkYeWLAvEVuh9pntsJeykqWh6TZHl gPlA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o20-v6si21452751pgh.319.2018.08.14.10.43.36; Tue, 14 Aug 2018 10:43:50 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390344AbeHNUaT (ORCPT + 99 others); Tue, 14 Aug 2018 16:30:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59582 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390232AbeHNUaS (ORCPT ); Tue, 14 Aug 2018 16:30:18 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 84965C8D; Tue, 14 Aug 2018 17:42:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gunthorpe , Jack Morgenstein , Leon Romanovsky , Sudip Mukherjee Subject: [PATCH 4.9 018/107] IB/core: Make testing MR flags for writability a static inline function Date: Tue, 14 Aug 2018 19:16:41 +0200 Message-Id: <20180814171521.828179164@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171520.883143803@linuxfoundation.org> References: <20180814171520.883143803@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jack Morgenstein commit 08bb558ac11ab944e0539e78619d7b4c356278bd upstream. Make the MR writability flags check, which is performed in umem.c, a static inline function in file ib_verbs.h This allows the function to be used by low-level infiniband drivers. Cc: Signed-off-by: Jason Gunthorpe Signed-off-by: Jack Morgenstein Signed-off-by: Leon Romanovsky Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/umem.c | 11 +---------- include/rdma/ib_verbs.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -122,16 +122,7 @@ struct ib_umem *ib_umem_get(struct ib_uc umem->address = addr; umem->page_size = PAGE_SIZE; umem->pid = get_task_pid(current, PIDTYPE_PID); - /* - * We ask for writable memory if any of the following - * access flags are set. "Local write" and "remote write" - * obviously require write access. "Remote atomic" can do - * things like fetch and add, which will modify memory, and - * "MW bind" can change permissions by binding a window. - */ - umem->writable = !!(access & - (IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE | - IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND)); + umem->writable = ib_access_writable(access); if (access & IB_ACCESS_ON_DEMAND) { put_pid(umem->pid); --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -3308,6 +3308,20 @@ static inline int ib_check_mr_access(int return 0; } +static inline bool ib_access_writable(int access_flags) +{ + /* + * We have writable memory backing the MR if any of the following + * access flags are set. "Local write" and "remote write" obviously + * require write access. "Remote atomic" can do things like fetch and + * add, which will modify memory, and "MW bind" can change permissions + * by binding a window. + */ + return access_flags & + (IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE | + IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND); +} + /** * ib_check_mr_status: lightweight check of MR status. * This routine may provide status checks on a selected