From patchwork Tue Nov 17 09:57:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56769 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1830967lbb; Tue, 17 Nov 2015 01:57:46 -0800 (PST) X-Received: by 10.66.240.4 with SMTP id vw4mr62768795pac.9.1447754266606; Tue, 17 Nov 2015 01:57:46 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qh12si56570759pab.145.2015.11.17.01.57.46; Tue, 17 Nov 2015 01:57:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753502AbbKQJ5n (ORCPT + 6 others); Tue, 17 Nov 2015 04:57:43 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:34371 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753608AbbKQJ5h (ORCPT ); Tue, 17 Nov 2015 04:57:37 -0500 Received: by wmvv187 with SMTP id v187so218356828wmv.1 for ; Tue, 17 Nov 2015 01:57:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KIB9uIheIZB87dpngPZ7eGgA/xFGSalaxaZW43I3O2o=; b=1MOhGTAnlGx3MOQtxBoY6G0qzJ9gL+YTt3AFCUpX7BlGMWy+7GWG3UZhNnprk+1EnM sQl1V0u0clOZooAbNvjpdJuBHvbZ5UvEf+94nzicfMEJ2wZC+8jemywKchce3uFWa2wF 9XbO8sZ75C+0fME951lKKaZNw1njrgqlDwyMzxIoxcHm4Sv8C47dmEu2xuYHt7ZjKA0X X3Ma4fh2vdHLRc7BR9W/mAok4L0e8lAvvV1N5wSsGX2NYuU1paA4jYWxZ5FchKdNOPHw CMob2qQLac8mYM9tEeBdC1xy8KzvJ/2/3zekgmD7ANSIle9bGN7xpGfxkS95fRpZSyIA 6KTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KIB9uIheIZB87dpngPZ7eGgA/xFGSalaxaZW43I3O2o=; b=A24mmabszvW4H8RgJdseXjPQ+jqTBGHILBXI88XVJH/r4HHetkUbpxdMV3WUEcTFJ3 o/5i1V14lJUPJclxdASrT+9cKfsr5/sXgIl56JQxiZDzJXPeaML+oJZiUlS15JuC8t1O LdfxVczpcmHr/+KZKtco1sTxcnfyqvEqKgsC8RM1ILvzZrtbEnOe5cqeUBKdKwSUydht N3v9N80PT5ULMltmoyJ34IsNYQiU1fH4DQVqqkmaiBcZLpw4NYRJQh26VsHgzF8MqpUO JiwytHjCmvTsziodHApXiRDDjQMVnWyFYlHRjsQXaXdoyBKqd8eMNNgDgfq4chaZ8d7M 3Amg== X-Gm-Message-State: ALoCoQm6x1XCNSkCilOtrOaFHZFhSUibn3rTuy8pnhO4tNw2p9/1y4E/W/1cUozsvomMOob2o80N X-Received: by 10.28.135.67 with SMTP id j64mr1650763wmd.93.1447754255746; Tue, 17 Nov 2015 01:57:35 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id bo7sm39038289wjb.46.2015.11.17.01.57.33 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:57:35 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, catalin.marinas@arm.com, will.deacon@arm.com, julien.grall@citrix.com, ard.biesheuvel@linaro.org, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org Cc: xen-devel@lists.xen.org, christoffer.dall@linaro.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, peter.huangpeng@huawei.com, shannon.zhao@linaro.org, zhaoshenglong@huawei.com, hangaohuai@huawei.com Subject: [PATCH 02/13] xen/grant-table: Move xlated_setup_gnttab_pages to common place Date: Tue, 17 Nov 2015 17:57:00 +0800 Message-Id: <1447754231-7772-3-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447754231-7772-1-git-send-email-shannon.zhao@linaro.org> References: <1447754231-7772-1-git-send-email-shannon.zhao@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Shannon Zhao Move xlated_setup_gnttab_pages to common place, so it can be reused by ARM to setup grant table when booting with ACPI. Signed-off-by: Shannon Zhao --- arch/x86/xen/grant-table.c | 51 ---------------------------------------------- drivers/xen/grant-table.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ include/xen/grant_table.h | 1 + 3 files changed, 50 insertions(+), 51 deletions(-) -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c index 1580e7a..2a99a9a 100644 --- a/arch/x86/xen/grant-table.c +++ b/arch/x86/xen/grant-table.c @@ -111,57 +111,6 @@ int arch_gnttab_init(unsigned long nr_shared) } #ifdef CONFIG_XEN_PVH -#include -#include -#include -static int __init xlated_setup_gnttab_pages(void) -{ - struct page **pages; - xen_pfn_t *pfns; - void *vaddr; - int rc; - unsigned int i; - unsigned long nr_grant_frames = gnttab_max_grant_frames(); - - BUG_ON(nr_grant_frames == 0); - pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL); - if (!pages) - return -ENOMEM; - - pfns = kcalloc(nr_grant_frames, sizeof(pfns[0]), GFP_KERNEL); - if (!pfns) { - kfree(pages); - return -ENOMEM; - } - rc = alloc_xenballooned_pages(nr_grant_frames, pages, 0 /* lowmem */); - if (rc) { - pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__, - nr_grant_frames, rc); - kfree(pages); - kfree(pfns); - return rc; - } - for (i = 0; i < nr_grant_frames; i++) - pfns[i] = page_to_pfn(pages[i]); - - vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL); - if (!vaddr) { - pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__, - nr_grant_frames, rc); - free_xenballooned_pages(nr_grant_frames, pages); - kfree(pages); - kfree(pfns); - return -ENOMEM; - } - kfree(pages); - - xen_auto_xlat_grant_frames.pfn = pfns; - xen_auto_xlat_grant_frames.count = nr_grant_frames; - xen_auto_xlat_grant_frames.vaddr = vaddr; - - return 0; -} - static int __init xen_pvh_gnttab_setup(void) { if (!xen_pvh_domain()) diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 62f591f..c084ba6 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -664,6 +664,55 @@ int gnttab_setup_auto_xlat_frames(phys_addr_t addr) } EXPORT_SYMBOL_GPL(gnttab_setup_auto_xlat_frames); +int __init xlated_setup_gnttab_pages(void) +{ + struct page **pages; + xen_pfn_t *pfns; + void *vaddr; + int rc; + unsigned int i; + unsigned long nr_grant_frames = gnttab_max_grant_frames(); + + BUG_ON(nr_grant_frames == 0); + pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL); + if (!pages) + return -ENOMEM; + + pfns = kcalloc(nr_grant_frames, sizeof(pfns[0]), GFP_KERNEL); + if (!pfns) { + kfree(pages); + return -ENOMEM; + } + rc = alloc_xenballooned_pages(nr_grant_frames, pages, 0 /* lowmem */); + if (rc) { + pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__, + nr_grant_frames, rc); + kfree(pages); + kfree(pfns); + return rc; + } + for (i = 0; i < nr_grant_frames; i++) + pfns[i] = page_to_pfn(pages[i]); + + vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL); + if (!vaddr) { + pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__, + nr_grant_frames, rc); + free_xenballooned_pages(nr_grant_frames, pages); + kfree(pages); + kfree(pfns); + return -ENOMEM; + } + kfree(pages); + + xen_auto_xlat_grant_frames.pfn = pfns; + xen_auto_xlat_grant_frames.count = nr_grant_frames; + xen_auto_xlat_grant_frames.vaddr = vaddr; + + return 0; +} +EXPORT_SYMBOL_GPL(xlated_setup_gnttab_pages); + void gnttab_free_auto_xlat_frames(void) { if (!xen_auto_xlat_grant_frames.count) diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h index 4478f4b..fa31e66 100644 --- a/include/xen/grant_table.h +++ b/include/xen/grant_table.h @@ -177,6 +177,7 @@ struct grant_frames { extern struct grant_frames xen_auto_xlat_grant_frames; unsigned int gnttab_max_grant_frames(void); int gnttab_setup_auto_xlat_frames(phys_addr_t addr); +int xlated_setup_gnttab_pages(void); void gnttab_free_auto_xlat_frames(void); #define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr))