Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5051663ybi; Sat, 20 Jul 2019 11:48:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhQaVn2nJu7nFUDObiO+BuoGQw7oFACyM1lFk6t0f0VWGruwcMOVWwYN5kKBzSQURpj94T X-Received: by 2002:a63:2cd1:: with SMTP id s200mr57381461pgs.10.1563648518177; Sat, 20 Jul 2019 11:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563648518; cv=none; d=google.com; s=arc-20160816; b=xuqaGuH5k9mtapX36aNCq8vtuNMMmhZ48k0nFaCVXUiIc92YgZywEDdVVFKftYbayU UGNrYWq+UHbpTfJhg2Lyba2wxihlnPwwncWQa2cINb2XU2zjtRcYxFxj50CmkYA1QDdA sfH46LMz1fmMjBuyBR4C76cBzDfO9d6gvL0SDtCpWRKk9jRaLpYqRJ7y5/KK1RNorZor KOkDcC+/JdjEcYZrxQJc5LdLoCTvJIrglbSaRitCFXzvkKqfKdUTm+N3fhHFEHs6MWG0 yXUbi7khRcaG43UuWFI73hp8ZSbpCSFsYKiDGgPNWTx9fg4vtQq4/mfS1g/CFcwGRUuh WWBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=TdusF53r7yLCmYFWdH2/Tx4Y0JTP7HLyZW39DsqTHPo=; b=eRj4dZRCmhYq0AUBm1nm6qDsUmmTlI+yVO4YL2LXQbNUiq73KugnB0fG/faByog8Nz EAl8gK8JZBh3tq3CR2Cgt5OJuQvZQ0c7l/sJWjQZaAxCpg5xZJb+U6kn/5Byc4CxPiuH ERSEqjv6o8Rp1ilPvD4H8b03Pzun7dc7VQhSw7SJRWiaRm0tEfv0MojtdXnT+7R/hbZX PaI19+5UdjaYU3TclmjA5L9xlzIOR7YF/5liCskqB6EOvD1mu14gv7VZ40VO9LwfU8Z+ VDX6YHPrUOSkQ3jNN6DaaEvi1BHjkYG9/5z90ot3VdPDFGmu3vt7TuSPEkrsi6tTcnun x33Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jZwHW5P5; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11si3740140plr.431.2019.07.20.11.48.22; Sat, 20 Jul 2019 11:48:38 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jZwHW5P5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728823AbfGTRcW (ORCPT + 99 others); Sat, 20 Jul 2019 13:32:22 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37158 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbfGTRcW (ORCPT ); Sat, 20 Jul 2019 13:32:22 -0400 Received: by mail-pf1-f193.google.com with SMTP id 19so15504397pfa.4 for ; Sat, 20 Jul 2019 10:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=TdusF53r7yLCmYFWdH2/Tx4Y0JTP7HLyZW39DsqTHPo=; b=jZwHW5P5iF1JlnF80DO5TcIm6+g+ZDUG5S+6/RgtYHw6KLyFLYlVXEl9Z9sEeemBht AYzMVLvL3O1rDCMBLgk5oQsBWzZVN5hNiP1d1yvkc+hIb1SfYyj77grFFke4jf+M89gj gOXjKJddqkWZIG4l07gU+qGnKbvmbTwg7jyMy1DL01btiBLhboZzNa0mKZWxEczosnB7 sQgcWCSGwoPOHdX1Ks41hNOl72N9rUE0sMXRSbhtDPDgbglGRTOaR/Xz9OkRXIvF7k0b Ah/g+c3esfGzqVES5VRKtJ7p4pPfjSTa2Sb5eLncBfFh4LSw1n8fk72XKKx/03e+N6Aa LmGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=TdusF53r7yLCmYFWdH2/Tx4Y0JTP7HLyZW39DsqTHPo=; b=KwRxIL7PmYqg0tcssaSgICAZx07rhESzYlKOsktoQ3ASdi6oq3Dh3Rx2VEhmuixPMy vaJv74pknA99sGlCbyLbKv6fNdwl/Rv8MrzkKGujGUEC42hIHsUnhzsrBjJybOHQwwAg 4A3kSyA9wj9OySLK+AekXE8D91YHbi6wYpjBQcYeFcJcuacUQ2n+Yl9ZjCnMctS57xOq hLN2zX3NM0hvH3E1oNxuG3xFeSYvgvKKAODxTKFypfb9cFWIqD8Gl4oJvdSDoabBMlz/ XuCG+ZtrfrPgF7Q2l/wCys3dOA6kxA2JtpHiC3dvSA2Pz037TXTy15DHYvuHqbK7d7D4 mbSA== X-Gm-Message-State: APjAAAXP/3NRHHXViuvKJHegfzfC1zj6WqHWYEHYSd9lV1+R9pXtEPz6 /peS6RSzButgoI2a10XJsYbRiuVl X-Received: by 2002:a63:3805:: with SMTP id f5mr28163350pga.272.1563643941385; Sat, 20 Jul 2019 10:32:21 -0700 (PDT) Received: from bharath12345-Inspiron-5559 ([103.110.42.33]) by smtp.gmail.com with ESMTPSA id l44sm30570928pje.29.2019.07.20.10.32.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Jul 2019 10:32:20 -0700 (PDT) Date: Sat, 20 Jul 2019 23:02:14 +0530 From: Bharath Vedartham To: ira.weiny@intel.com, jglisse@redhat.com, gregkh@linuxfoundation.org, Matt.Sickler@daktronics.com, jhubbard@nvidia.com Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux.bhar@gmail.com Subject: [PATCH v4] staging: kpc2000: Convert put_page to put_user_page*() Message-ID: <20190720173214.GA4250@bharath12345-Inspiron-5559> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For pages that were retained via get_user_pages*(), release those pages via the new put_user_page*() routines, instead of via put_page(). This is part a tree-wide conversion, as described in commit fc1d8e7cca2d ("mm: introduce put_user_page*(), placeholder versions"). Cc: Ira Weiny Cc: John Hubbard Cc: J?r?me Glisse Cc: Greg Kroah-Hartman Cc: Matt Sickler Cc: devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Reviewed-by: John Hubbard Signed-off-by: Bharath Vedartham --- Changes since v1 - Improved changelog by John's suggestion. - Moved logic to dirty pages below sg_dma_unmap and removed PageReserved check. Changes since v2 - Added back PageResevered check as suggested by John Hubbard. Changes since v3 - Changed the commit log as suggested by John. - Added John's Reviewed-By tag --- drivers/staging/kpc2000/kpc_dma/fileops.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 6166587..75ad263 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -198,9 +198,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned sg_free_table(&acd->sgt); err_dma_map_sg: err_alloc_sg_table: - for (i = 0 ; i < acd->page_count ; i++){ - put_page(acd->user_pages[i]); - } + put_user_pages(acd->user_pages, acd->page_count); err_get_user_pages: kfree(acd->user_pages); err_alloc_userpages: @@ -221,16 +219,13 @@ void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) dev_dbg(&acd->ldev->pldev->dev, "transfer_complete_cb(acd = [%p])\n", acd); - for (i = 0 ; i < acd->page_count ; i++){ - if (!PageReserved(acd->user_pages[i])){ - set_page_dirty(acd->user_pages[i]); - } - } - dma_unmap_sg(&acd->ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, acd->ldev->dir); - for (i = 0 ; i < acd->page_count ; i++){ - put_page(acd->user_pages[i]); + for (i = 0; i < acd->page_count; i++) { + if (!PageReserved(acd->user_pages[i])) + put_user_pages_dirty(&acd->user_pages[i], 1); + else + put_user_page(acd->user_pages[i]); } sg_free_table(&acd->sgt); -- 2.7.4