Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758126AbcCCPNP (ORCPT ); Thu, 3 Mar 2016 10:13:15 -0500 Received: from mail-bn1bon0086.outbound.protection.outlook.com ([157.56.111.86]:15348 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756802AbcCCPNJ (ORCPT ); Thu, 3 Mar 2016 10:13:09 -0500 Authentication-Results: spf=fail (sender IP is 66.35.236.236) smtp.mailfrom=opensource.altera.com; ettus.com; dkim=pass (signature was verified) header.d=altera.onmicrosoft.com;ettus.com; dmarc=none action=none header.from=opensource.altera.com; Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=opensource.altera.com; From: Alan Tull To: Rob Herring , Pantelis Antoniou CC: Frank Rowand , Grant Likely , , , Moritz Fischer , Pantelis Antoniou , Alan Tull , Dinh Nguyen , Alan Tull Subject: [PATCH v3] of/overlay: add of overlay notifications Date: Thu, 3 Mar 2016 09:10:41 -0600 Message-ID: <1457017841-20141-1-git-send-email-atull@opensource.altera.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [64.129.157.38] X-ClientProxiedBy: SN2PR80CA028.lamprd80.prod.outlook.com (10.141.39.166) To CY1PR03MB1519.namprd03.prod.outlook.com (25.163.17.25) X-MS-Office365-Filtering-Correlation-Id: e35705a4-ade6-4a61-958d-08d3437652b3 X-Microsoft-Exchange-Diagnostics-untrusted: 1;CY1PR03MB1519;2:xVsdHDfKmHMldHdwW3sWW+jtmZ0kxkSY1U9BLi0nNUhVVUgWrAbBxIweOWb7piTPHI1EVGKr67PMQCzW0GKcl5O/nhampLjQHHitws7VMnfkygV9DizDuebVSslJ2brI7ECC1psnzDZxYuMU/CSevK7K+Q9shOJv5tbx6Ne2sSEU3gX/Nj8/lwKE17RsoiQf;3:OgoLG2qs0dIPDUPeLBUswKODZeNE8XIic/WZxyPmCtXbCMJi0XoMQBmqaA+d4xuitY2ZfBw/GxZVK7sIKk6EMQ7GOZPHGRYQPbPPoTH6q256HSbq3xn5xwa7Fw0xPFcj;25:XUUH9fzByrmeDriHXDwk4LNStYqXIZzTSkkr6ym4a67nG2Wed2FSNZLrlPESYeO67ZvQtLA5I6U6o5Jqp7WI9rT9W8CaGn7QuSwvB8vKG8MpZesl1HvIDiwmzRapl1pS65YIQBzpfASPJThf6AlrqKF8mBpSHpoRkL9Y5nFf0V5VHEl/LwhAKENsCSIbfR9UulmOkqZve0WJYwiXelqu/+bJNkVyKyXPyPE5Ry8goJsWFh70QIMw+Gt5LLUWlBGWdJYUHTh/GDtjw6b5JyNQUGJZCOscqw6R/Ana6mrgzFsATOvxN38NZwv74LH4keCNGP9VY7wdxdIl41oZfxi9RQ==;20:U0wW16XPQN2sMv9lQ8aC0gHXgIL+VLNUGAOvfzn9ilPj2EomFOlPStSkRVqEOJiuv3LM5EbFiUmUE5Iu1XFP7KrImnegWc4q4ZbpaCvZQM7xgK5CKTdbSXw2r8wFyiLs6J5PckC/uJ5tOhru468IJw6bNjnw369B0rzPx8f1IZc= X-Microsoft-Antispam-Untrusted: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1519; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:;UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:CY1PR03MB1519;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1519;BCL:0;PCL:0;RULEID:(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(5005006)(8121501046)(13018025)(3002001)(10201501046);SRVR:SN1PR0301MB2031;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB2031; X-Microsoft-Exchange-Diagnostics-untrusted: 1;CY1PR03MB1519;4:8kWlrCIpqPAOLyQrpvVwzsooM7G5ni0JMuT0iqjswPaITG3Kz/0XMjmJYw1IwocJKwhnZ8ijhL60UyMLAGFghWNBtMEBP7PgoQgt7IY1q4jKPf6bGoCedVocgqVP0B5ciGxyeFOusENoJxxcPJJ7nWTABqUFYoQ0XVojOj2qVqEQJLH3WM78d7xDrp2tvWweo7+CF3eOwVS7BPOpSN3R3KaPt9uhimuZ26dY7m92rBmQXdjOX8edtqQtfL1JCdHsOlKD1tYPlZIpPo7toeu+L2spiNX8eNP4qexi5FE7L4NfQBUAh3MxTzzymDGcYzLiUaeXbDAeWj7Mg1bO7hSchzR0n7V20Q+5eDvX8YIC/VpTop24PxQ/fIjRsdGnYjDI X-Forefront-PRVS: 0870212862 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(229853001)(575784001)(2906002)(66066001)(86362001)(92566002)(50466002)(15650500001)(19580395003)(5001770100001)(33646002)(42186005)(47776003)(53416004)(1096002)(586003)(77096005)(6116002)(122386002)(189998001)(5003940100001)(4001430100002)(107886002)(5001960100004)(48376002)(50226001)(5004730100002)(87976001)(50986999)(19580405001)(5008740100001)(40100003)(4326007)(4720700001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR03MB1519;H:linuxheads99.altera.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics-untrusted: =?us-ascii?Q?1;CY1PR03MB1519;23:d9KWaeZkubER5Zce+iKKyxsyeTazKge8dgY/6i7aK?= =?us-ascii?Q?6RQ1XtgLOGqKg75riSXavn+TMGrQEfBVFX1Y6AAxUDhLOoOOhZ7dNFFt8EnU?= =?us-ascii?Q?4sa5kh/nimZKyNEGhVAGpqbB+0pQ7wGLDejS8yMBhnhNhfx1tzIShI41tRyv?= =?us-ascii?Q?AhBDI9Oo75Ze7sSHsKFeOISTnQIhtebRp29sdTGPqJZ4zaKzIhNgnvGAlWjm?= =?us-ascii?Q?5MWuWdbthAcFqU3dq5Dd//3td3M/ByVPnqDoMwZ1EnN3F1iIXlce331tZ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JgVn1PE5hwlO+GdxjMX7Xk4cIGDFfyQPDUjqpwbWFygL/91bXlWaiSCqmFlsWgcK4uhnQRkXhcdvVoJA==;24:oYd9W9RJBlDJ8aiGjuA/5kIoiLQUt1BcyHsmcw29QqCvJpNM1lTHVfniHjSSFi1Jc+7VzaWTSivySr+zozO8/NJv74QIxQXBIE2XzSwoiTQ=;20:ySEHeRmx09DZHH+zsf4X+KWTixX/Xg5VHJdYX4j9xLiyMBjFvhqh2Y+BOOdLvWnt/HfmZDQqthCgV/mSUIuI2wJQZ45RZ/pQ3NKohXYx95Hj1rAxMI5eJPU0RogG6TQf+yEdc6EpCVbno3XoEInxtfL5IoeP7IgXkB1IUswvzdQ= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1519 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1BFFO11FD002.protection.gbl X-Forefront-Antispam-Report: CIP:66.35.236.236;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(3720700001)(11100500001)(5001770100001)(586003)(956001)(5004730100002)(4001430100002)(5003940100001)(50226001)(4326007)(47776003)(48376002)(86362001)(5001960100004)(6116002)(33646002)(122386002)(2906002)(53416004)(50986999)(107886002)(229853001)(575784001)(50466002)(189998001)(6806005)(5008740100001)(92566002)(1096002)(77096005)(105606002)(21840400001)(19580405001)(106466001)(40100003)(1220700001)(66066001)(19580395003)(85426001)(15650500001)(7099028)(4720700001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR0301MB2031;H:sj-itexedge04.altera.priv.altera.com;FPR:;SPF:Fail;MLV:sfv;MX:1;A:0;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD002;1:+XHsnCqVkquaPeJQ124lYyzZZ+hbWLCekvaSzsqzEIUoI8CbbF8+u6Ku7oCXRmxJov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SS2mFokR50VrcHmoj41QpaCQsu5cRZGB46JK37Ximp0brplOTQoZbbtRwMkn0/0wYgcindil/8b9YpK5HEui9bWvf/e++Mk66SojU3mtfWiizhnr4XMEFFJRgnCXf2fMkduLnG1nPQfMUwkXqHBUHX5BsSOpr0fmwroNpwpTJN7nU6tXK3mL4IhwgzTSDLlnnM5w4IdstTNaZEcWdrPfURoG X-DkimResult-Test: Passed X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(3001016);SRVR:SN1PR0301MB2031; X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB2031;20:dIljr0MDvvzSvy4gh622mefZoJvI/3S14RI0FYaoR18HHFjsROoFCsYa7lszVAx4/WX63/9GRD3JrsnDYTQtrzbndMY+LMTC5X3NacrgaegQDzmje1fOZqZT/wNoPNNknWjitOcmTGhcr4XlkemkDrK1ujlUU8EPaDViXZzyLLo=;4:HEKYEfiw+JAeISDqVphfCX7dm3c6kR5rSE8BfBB184VKrIR/VQeFIcWz/ada+Dx+7SVgBLRU8gH3eZBbPYhenZXp5mIsrRi8G1rE6UfNRIPja6QrbrrGiP1jt0Fnu2GtI9fXriKug7hGGjGZI3QvmgfCm3qJeVyRpPyUzYODo4Pmtzv1Oh2T2Oa44IrIurZEgpFYMB5ba+Tkqb8YS+atm+NnHbM6lDmKO37TAcNpVISjT4Upm35XVVQmQsDHK3RnmX64HR0Rag9KpaYADuAUO8v6QvIWBzngEI4a1k0adGXEt9pnvAqNh9N2g1ZhBcaoBILP5sIS49qGAdsbJPLShpWgDLlFQgigJCQCr9tt/IuaQHacGcBIp4fzAK6I1zXH3Jm6kOtR+BjOesGn8fVhs43nAMe63nZcJ3rdSC6lZifJkY3G7lgJxGswbYbiaKALHOErzwh/tq3wM5Jc1kCDMQ== X-Forefront-PRVS: 0870212862 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR0301MB2031;23:FzZd9HdkBkVRcYm5NZsiFnYzvHHEUFAnYJq6tGH?= =?us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7DS/gkgBLfa7v0yd+fG7E?= =?us-ascii?Q?pgzIQWE7Rpu9FDixEMKfA1OJ0I3r73k+Ykau0x2BnL8UwBmXOuUwPtRmhpZe?= =?us-ascii?Q?7Untj1QumH3lDT5UNnvSWKTS/k6/mUXwSz3b8owSNr8b6jHLvmGK8RaTe0e2?= =?us-ascii?Q?Tb5HynVjsTFM3wVZvWkeFmNwfmVie8Xb7NOVGONRpb0CDUBmJq1ZXncqK8ZS?= =?us-ascii?Q?xsrho0iiAh6niv4O/vbjVzKFOVQAnly6P1ii0clF7ltjjv7t+6d66RnSpfdj?= =?us-ascii?Q?IcPwzxO1DVUhS65DN+Bl+WRkT1nyEyqCpnlr93teoQ5EjsQEScLsfq56L6aF?= =?us-ascii?Q?rFBLpmprMgubWqg2k15bVGy6sJHgwCwqPNNF59W45EA1KU3qkHSybXclWtnT?= =?us-ascii?Q?WXQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB2031;5:y2Ba2kGoXJHxr9JC1sl4EorOhYqafq47T04oJ78tLcrTuK9Hvaq2qY0+i+iyq6KSkW9eJ3OzhS/FFAiOgyAg5e6ws1ZG4mTwbR9U+gK6fkJmV9eDD00JFtfCpWCGeNJOfrljwGnm8nui9rZQkH3lrw==;24:syMDDqO2cevLJVDNI4j22saYqf3UNCFTVqq1LVe/0suGQcbBrJdVpYfQSVp8OeXOVcwMad0aiImn2kpvIdX0kKD24EE03m97XVRHCqQRSbg=;20:xtuto3BfUgSXedPxpEHi19SujLE2uOp+54iLjnUUTYUcMLIwlmSyzg5aIi2K781vUw3fs0z7JinYzv677dvmK7sK2LCFxQBwa4yv/XiTcPeK82w0RXaeQ+gFhU9SHUyRxuwTmJzVX7XLEyK+vHuWX0hhgwT6ZILCZFs6rpQbtKI= X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2016 15:13:05.7706 (UTC) X-MS-Exchange-CrossTenant-Id: fbd72e03-d4a5-4110-adce-614d51f2077a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fbd72e03-d4a5-4110-adce-614d51f2077a;Ip=[66.35.236.236];Helo=[sj-itexedge04.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0301MB2031 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4899 Lines: 177 This patch add of overlay notifications. When DT overlays are being added, some drivers/subsystems need to see device tree overlays before the changes go into the live tree. This is distinct from reconfig notifiers that are post-apply or post-remove and which issue very granular notifications without providing access to the context of a whole overlay. The following 4 notificatons are issued: OF_OVERLAY_PRE_APPLY OF_OVERLAY_POST_APPLY OF_OVERLAY_PRE_REMOVE OF_OVERLAY_POST_REMOVE In the case of pre-apply notification, if the notifier returns error, the overlay will be rejected. This patch exports two functions for registering/unregistering notifications: of_overlay_notifier_register(struct notifier_block *nb) of_overlay_notifier_unregister(struct notifier_block *nb) The of_mutex is held during these notifications. The notification data includes pointers to the overlay target and the overlay: struct of_overlay_notify_data { struct device_node *overlay; struct device_node *target; }; Signed-off-by: Alan Tull --- v2: add missing 'static inline' in of.h v3: fix build for !OF_OVERLAY in of.h add a note in the header that the of_mutex is held --- drivers/of/overlay.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- include/linux/of.h | 25 +++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 8225081..a26f0ed 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -56,6 +56,41 @@ struct of_overlay { static int of_overlay_apply_one(struct of_overlay *ov, struct device_node *target, const struct device_node *overlay); +static BLOCKING_NOTIFIER_HEAD(of_overlay_chain); + +int of_overlay_notifier_register(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&of_overlay_chain, nb); +} +EXPORT_SYMBOL_GPL(of_overlay_notifier_register); + +int of_overlay_notifier_unregister(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&of_overlay_chain, nb); +} +EXPORT_SYMBOL_GPL(of_overlay_notifier_unregister); + +static int of_overlay_notify(struct of_overlay *ov, + enum of_overlay_notify_action action) +{ + struct of_overlay_notify_data nd; + int i, ret; + + for (i = 0; i < ov->count; i++) { + struct of_overlay_info *ovinfo = &ov->ovinfo_tab[i]; + + nd.target = ovinfo->target; + nd.overlay = ovinfo->overlay; + + ret = blocking_notifier_call_chain(&of_overlay_chain, + action, &nd); + if (ret) + return notifier_to_errno(ret); + } + + return 0; +} + static int of_overlay_apply_single_property(struct of_overlay *ov, struct device_node *target, struct property *prop) { @@ -370,6 +405,13 @@ int of_overlay_create(struct device_node *tree) goto err_free_idr; } + err = of_overlay_notify(ov, OF_OVERLAY_PRE_APPLY); + if (err < 0) { + pr_err("%s: Pre-apply notifier failed (err=%d)\n", + __func__, err); + goto err_free_idr; + } + /* apply the overlay */ err = of_overlay_apply(ov); if (err) { @@ -389,6 +431,8 @@ int of_overlay_create(struct device_node *tree) /* add to the tail of the overlay list */ list_add_tail(&ov->node, &ov_list); + of_overlay_notify(ov, OF_OVERLAY_POST_APPLY); + mutex_unlock(&of_mutex); return id; @@ -509,9 +553,10 @@ int of_overlay_destroy(int id) goto out; } - + of_overlay_notify(ov, OF_OVERLAY_PRE_REMOVE); list_del(&ov->node); __of_changeset_revert(&ov->cset); + of_overlay_notify(ov, OF_OVERLAY_POST_REMOVE); of_free_overlay_info(ov); idr_remove(&ov_idr, id); of_changeset_destroy(&ov->cset); diff --git a/include/linux/of.h b/include/linux/of.h index dc6e396..33832a9 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1076,6 +1076,18 @@ static inline bool of_device_is_system_power_controller(const struct device_node * Overlay support */ +enum of_overlay_notify_action { + OF_OVERLAY_PRE_APPLY, + OF_OVERLAY_POST_APPLY, + OF_OVERLAY_PRE_REMOVE, + OF_OVERLAY_POST_REMOVE, +}; + +struct of_overlay_notify_data { + struct device_node *overlay; + struct device_node *target; +}; + #ifdef CONFIG_OF_OVERLAY /* ID based overlays; the API for external users */ @@ -1083,6 +1095,9 @@ int of_overlay_create(struct device_node *tree); int of_overlay_destroy(int id); int of_overlay_destroy_all(void); +int of_overlay_notifier_register(struct notifier_block *nb); +int of_overlay_notifier_unregister(struct notifier_block *nb); + #else static inline int of_overlay_create(struct device_node *tree) @@ -1100,6 +1115,16 @@ static inline int of_overlay_destroy_all(void) return -ENOTSUPP; } +static inline int of_overlay_notifier_register(struct notifier_block *nb) +{ + return 0; +} + +static inline int of_overlay_notifier_unregister(struct notifier_block *nb) +{ + return 0; +} + #endif #endif /* _LINUX_OF_H */ -- 1.7.9.5