From patchwork Fri Nov 30 22:59:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10707395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CF5914BD for ; Fri, 30 Nov 2018 22:59:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EC452FDA0 for ; Fri, 30 Nov 2018 22:59:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 632952FDC4; Fri, 30 Nov 2018 22:59:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F165C2FDA0 for ; Fri, 30 Nov 2018 22:59:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B8F66B5AA3; Fri, 30 Nov 2018 17:59:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 668036B5AA4; Fri, 30 Nov 2018 17:59:21 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52F656B5AA5; Fri, 30 Nov 2018 17:59:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) by kanga.kvack.org (Postfix) with ESMTP id 2C6816B5AA3 for ; Fri, 30 Nov 2018 17:59:21 -0500 (EST) Received: by mail-it1-f197.google.com with SMTP id 135so714796itk.5 for ; Fri, 30 Nov 2018 14:59:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :date:message-id:mime-version:content-transfer-encoding:subject; bh=qUedMcA0hO2nH8FABN8B6/9gZ8xCE9n+8QgqkKzyaWk=; b=g/xI4hHjq9N3TWVBVunray33Nr8lmUgszsBdno4dkKPQbZmtE2x+C97yrfhBY4dxqI v9tBYyoWt/+dRCRnVKAE+xTgX3mdDY0yh75EBe+9Um3kbpLwVeU3ONbBumssUzpdcw8u UoZbOWYlSJjnIr3D0tgpePIo/kvu0Eba4ZPNJs0bEp3dMiKAeCT8frfSQfDkM0ThOBl2 THL/eUjnVtPNLSlMLlG726TOjC2CGyekwrcdODX99ANndaxZzD0NSfuO/uh3JEp2XtoH WjPmxk/04hckQxkcKzZ+VIQra24OMXu31LkzTbBi4N9FaNHaEpebg8SWkbn3gHliEjtA 8deQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com X-Gm-Message-State: AA+aEWaQoH/jlqiHGQde6d6o+p8+i1xuI3C1o2sNenK2UG3uCt+iaq+F FwCqemJOcy4fLTqw4MvvUmxxS3OOkHYSLWOSl9d3im6STPy09zE9kfsO0OXQISwis3Uf6GzMLBx znyrjVcewwhhhgPS4ck78mCwfhcMQm3JqoSeWDASxZTRapV96DQnJvdhUPSRvdIOpqw== X-Received: by 2002:a24:1fc7:: with SMTP id d190mr619034itd.126.1543618760884; Fri, 30 Nov 2018 14:59:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/Va0VY8Afw27Q7EgZRe0v2sZYp+eGN90CsEDyyc/u0fsRkiX1e5fPP0F40PrvW+DmsPpo5a X-Received: by 2002:a24:1fc7:: with SMTP id d190mr619012itd.126.1543618760190; Fri, 30 Nov 2018 14:59:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543618760; cv=none; d=google.com; s=arc-20160816; b=HcWHECLqzK1SS6W9uIXxNYBogUSh3uHQ/ypmCYpXtgD/luYDPwVB+UXcVhx+HdFAjC XTKCHOTYqwPAr9sdXKr2bwRRcCpQ1ojGB/ZDC1CGLhYvu9Xmw55kzC83caUoCbjSqP5c f2odF+8IkjT+W1cgfHGDgs15cAFtyXa5r19wP7RsxtjCmuDQRF0QW/I50GbJjJCpLbJK xmVgcoVHwmmMwgKQV1ljS/+IRfx6X7TuLiVA5DCslMAUZgPqEuNBIk20xMjRt8gAfK2d CGLd8tPKioNfd6WZVoVm3lJVRV7AlQH/Xv0k2hk6COyHkQesaodG/0F398Sghbxtsb/m DdGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:message-id:date:cc :to:from; bh=qUedMcA0hO2nH8FABN8B6/9gZ8xCE9n+8QgqkKzyaWk=; b=GUAM9OB4bB6y/wsVCaKizL1hKdVw2ROdbaJphgUYo9EHzCZlQNl028bRXvItTAWUCo 5u1I9Ievaf/QRivq0ZSiJpL2yhD/ACaBpUAlo6ZuLnpHZBHBuDGENgH8debqNwCfwmtH ALETacsma8XIY/lBU55Ed6USm2z/5IiZzsKEKYbm48v+IknFdt76qCINtCimmvwDXwil 3bVqFSerXYyrvfyFc2DybXyfqDnBLKR5XbtZlawe+W9kfeMb3M3U/qv7B4/ImyUWNqXT WEDfSucW2p/u5kdOUkDhP0cIZUOfIZinpnxaH8IKwumqJ9EM9d3yxdpXZwzcL0s8YvCf zEXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com Received: from ale.deltatee.com (ale.deltatee.com. [207.54.116.67]) by mx.google.com with ESMTPS id x65si334109itf.28.2018.11.30.14.59.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 14:59:17 -0800 (PST) Received-SPF: pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) client-ip=207.54.116.67; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gSrkh-00061c-Cb; Fri, 30 Nov 2018 15:59:16 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gSrkg-0000lU-IU; Fri, 30 Nov 2018 15:59:14 -0700 From: Logan Gunthorpe To: Andrew Morton Cc: Linux MM , linux-pci@vger.kernel.org, Linux Kernel Mailing List , Logan Gunthorpe , Dan Williams , Bjorn Helgaas Date: Fri, 30 Nov 2018 15:59:11 -0700 Message-Id: <20181130225911.2900-1-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, logang@deltatee.com, dan.j.williams@intel.com, bhelgaas@google.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH] PCI/P2PDMA: Match interface changes to devm_memremap_pages() X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP "mm-hmm-mark-hmm_devmem_add-add_resource-export_symbol_gpl.patch" in the mm tree breaks p2pdma. The patch was written and reviewed before p2pdma was merged so the necessary changes were not done to the call site in that code. Without this patch, all drivers will fail to register P2P resources because devm_memremap_pages() will return -EINVAL due to the 'kill' member of the pagemap structure not yet being set. Signed-off-by: Logan Gunthorpe Cc: Andrew Morton Cc: Dan Williams Cc: Bjorn Helgaas Reviewed-by: Dan Williams --- Ideally this patch should be squashed with the one mentioned above to avoid a bisect regression point. drivers/pci/p2pdma.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) -- 2.19.0 diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index ae3c5b25dcc7..a2eb25271c96 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -82,10 +82,8 @@ static void pci_p2pdma_percpu_release(struct percpu_ref *ref) complete_all(&p2p->devmap_ref_done); } -static void pci_p2pdma_percpu_kill(void *data) +static void pci_p2pdma_percpu_kill(struct percpu_ref *ref) { - struct percpu_ref *ref = data; - /* * pci_p2pdma_add_resource() may be called multiple times * by a driver and may register the percpu_kill devm action multiple @@ -198,6 +196,7 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, pgmap->type = MEMORY_DEVICE_PCI_P2PDMA; pgmap->pci_p2pdma_bus_offset = pci_bus_address(pdev, bar) - pci_resource_start(pdev, bar); + pgmap->kill = pci_p2pdma_percpu_kill; addr = devm_memremap_pages(&pdev->dev, pgmap); if (IS_ERR(addr)) { @@ -211,11 +210,6 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, if (error) goto pgmap_free; - error = devm_add_action_or_reset(&pdev->dev, pci_p2pdma_percpu_kill, - &pdev->p2pdma->devmap_ref); - if (error) - goto pgmap_free; - pci_info(pdev, "added peer-to-peer DMA memory %pR\n", &pgmap->res);