From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Jiang Liu To: Vinod Koul , Dan Williams Cc: Jiang Liu , Keping Chen , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jiang Liu Subject: [PATCH v1 2/8] dmaengine: rebalance DMA channels when CPU hotplug happens Date: Mon, 23 Apr 2012 21:51:43 +0800 Message-Id: <1335189109-4871-3-git-send-email-jiang.liu@huawei.com> In-Reply-To: <1335189109-4871-1-git-send-email-jiang.liu@huawei.com> References: <1335189109-4871-1-git-send-email-jiang.liu@huawei.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: Rebalance DMA channels when CPU hotplug happens to correctly update DMA channel reference count. Signed-off-by: Jiang Liu --- drivers/dma/dmaengine.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 5b6ad58..198d891 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -1008,8 +1009,29 @@ void dma_run_dependencies(struct dma_async_tx_descriptor *tx) } EXPORT_SYMBOL_GPL(dma_run_dependencies); +static int __cpuinit +hotcpu_rebalance(struct notifier_block *nfb, unsigned long action, void *hcpu) +{ + switch (action) { + case CPU_ONLINE: + case CPU_POST_DEAD: + mutex_lock(&dma_list_mutex); + dma_channel_rebalance(); + mutex_unlock(&dma_list_mutex); + break; + } + + return NOTIFY_OK; +} + +static struct notifier_block __refdata dma_cpu_notifier = { + .notifier_call = hotcpu_rebalance, +}; + + static int __init dma_bus_init(void) { + register_hotcpu_notifier(&dma_cpu_notifier); return class_register(&dma_devclass); } arch_initcall(dma_bus_init); -- 1.7.5.4