From patchwork Fri Apr 1 15:49:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 64875 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp811599lbc; Fri, 1 Apr 2016 08:51:59 -0700 (PDT) X-Received: by 10.31.148.144 with SMTP id w138mr2721583vkd.44.1459525908690; Fri, 01 Apr 2016 08:51:48 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 109si4466554ual.64.2016.04.01.08.51.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Apr 2016 08:51:48 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1am1LO-0004bj-MK; Fri, 01 Apr 2016 15:50:42 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1am1LN-0004au-Em for xen-devel@lists.xen.org; Fri, 01 Apr 2016 15:50:41 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 68/C0-29419-0D89EF65; Fri, 01 Apr 2016 15:50:40 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1459525839!32278827!1 X-Originating-IP: [209.85.220.45] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38985 invoked from network); 1 Apr 2016 15:50:40 -0000 Received: from mail-pa0-f45.google.com (HELO mail-pa0-f45.google.com) (209.85.220.45) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Apr 2016 15:50:40 -0000 Received: by mail-pa0-f45.google.com with SMTP id td3so93479027pab.2 for ; Fri, 01 Apr 2016 08:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PO2yePTVVNjv+ScXuWCyBYXqVDxmpUUcbVXBLwhhHcE=; b=E5X5+IGcFP1Z53M59tqPXuph9gB0OIdLnQuk/M4rOZohuhZZo+6QXYZrs4aPZ9LbZd C1mdIYj2nLg6Gw7PQS4Cz3jR65xyOjfM5Hf6Ewrm/h5Xm6WkYKEej0JIB4+sEIXLeYvB l54YtfCaFhMbxVWTgtpOPUKqS0VgfYktrTk6U= 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=PO2yePTVVNjv+ScXuWCyBYXqVDxmpUUcbVXBLwhhHcE=; b=WAEyYeYTfdFGcUcFhYissUVhOTErkMYMcpNxmhDRYglErHKffhA6r9yNQFya2GZKjC 2znq8mjMa6FTfkPRTw0rqkFSxWx8djI2DPcf+n7JU9JfnEPw3WdvxsaA/SiNX1KQNM4O pKt2N3Y4EcWXqtwj64Qh9HUuNc57Ex/WSQjkmztzyO6TwL5H+pG4qjEBeny3f+idzgNd CZlcwZJ6AGwkkRiP6iplPTYrMnQguftAaQNBKKVmqQINJjVZatqrMT8i6Spc66LjLchu m7FTE/xRBxWRTS2hJ05iUAlx3QCpcrXDp3xpahzcz9oKU+q8qCWWdYM6fSBVAq4U64k4 6aHg== X-Gm-Message-State: AD7BkJJH0oBjG+GF63DmmywaCn2HZlk9rqAG4KhGTx1Z1VDVpO07h1vVMIfpleM+L+3HBeGz X-Received: by 10.66.118.7 with SMTP id ki7mr32128985pab.152.1459525838662; Fri, 01 Apr 2016 08:50:38 -0700 (PDT) Received: from localhost.localdomain ([167.160.116.218]) by smtp.gmail.com with ESMTPSA id yj1sm22536791pac.16.2016.04.01.08.50.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 01 Apr 2016 08:50:37 -0700 (PDT) From: Shannon Zhao To: linux-arm-kernel@lists.infradead.org, stefano.stabellini@citrix.com Date: Fri, 1 Apr 2016 23:49:05 +0800 Message-Id: <1459525755-36968-8-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459525755-36968-1-git-send-email-shannon.zhao@linaro.org> References: <1459525755-36968-1-git-send-email-shannon.zhao@linaro.org> Cc: devicetree@vger.kernel.org, linux-efi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, peter.huangpeng@huawei.com, julien.grall@arm.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, xen-devel@lists.xen.org, shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v10 07/17] Xen: ARM: Add support for mapping AMBA device mmio X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a bus_notifier for AMBA bus device in order to map the device mmio regions when DOM0 booting with ACPI. Signed-off-by: Shannon Zhao Reviewed-by: Stefano Stabellini --- drivers/xen/arm-device.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c index 76e26e5..3854043 100644 --- a/drivers/xen/arm-device.c +++ b/drivers/xen/arm-device.c @@ -139,3 +139,46 @@ static int __init register_xen_platform_notifier(void) } arch_initcall(register_xen_platform_notifier); + +#ifdef CONFIG_ARM_AMBA +#include + +static int xen_amba_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct amba_device *adev = to_amba_device(data); + int r = 0; + + switch (action) { + case BUS_NOTIFY_ADD_DEVICE: + r = xen_map_device_mmio(&adev->res, 1); + break; + case BUS_NOTIFY_DEL_DEVICE: + r = xen_unmap_device_mmio(&adev->res, 1); + break; + default: + return NOTIFY_DONE; + } + if (r) + dev_err(&adev->dev, "AMBA: Failed to %s device %s MMIO!\n", + action == BUS_NOTIFY_ADD_DEVICE ? "map" : + (action == BUS_NOTIFY_DEL_DEVICE ? "unmap" : "?"), + adev->dev.init_name); + + return NOTIFY_OK; +} + +static struct notifier_block amba_device_nb = { + .notifier_call = xen_amba_notifier, +}; + +static int __init register_xen_amba_notifier(void) +{ + if (!xen_initial_domain() || acpi_disabled) + return 0; + + return bus_register_notifier(&amba_bustype, &amba_device_nb); +} + +arch_initcall(register_xen_amba_notifier); +#endif