From patchwork Mon May 14 13:47:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 159002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 217DFB701F for ; Mon, 14 May 2012 23:50:05 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755466Ab2ENNuD (ORCPT ); Mon, 14 May 2012 09:50:03 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:49717 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755030Ab2ENNuC (ORCPT ); Mon, 14 May 2012 09:50:02 -0400 Received: by mail-pz0-f46.google.com with SMTP id y13so5939338dad.19 for ; Mon, 14 May 2012 06:50:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=47sqCuv41Yu7IEk0pba3uhcJbNVBcgO640WCsHDtGNs=; b=IZqxjXGv4fFFtbn0ua0B4TnL8y67ecjFyMhC+TJ1qGx7SBKu7tJJUSSh0LCeasC1y/ cNSsLMfvJY6dLV89fLT7Co1SEut+g1UE49K4TZ/13Ypwig3zCOSyjzq7IXHCwlierjy8 gHRmtWjhhiY4/5iSVpX8giyPXI62QvDlpylfm6qDOUs6kaqLpon026FPbOs0HGcSz0pl mN2pK2khQSoLYCmMYyoCDHHcTf9ED7SOIATw5ikgDEKflKzjj0R5vnlr4FljgN7Efnrk nn3WF/9ceQNZAWrauc5ig/fbCK+MUqIbEstqvZv0RD0laTbrQ9oxvjhK49MjSTcE8ifi CdPw== Received: by 10.68.239.163 with SMTP id vt3mr5483545pbc.60.1337003402344; Mon, 14 May 2012 06:50:02 -0700 (PDT) Received: from localhost.localdomain ([221.221.27.187]) by mx.google.com with ESMTPS id pp8sm22345496pbb.21.2012.05.14.06.49.36 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 14 May 2012 06:50:01 -0700 (PDT) From: Jiang Liu To: Dan Williams , Maciej Sosnowski , Vinod Koul Cc: Jiang Liu , Keping Chen , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Jiang Liu Subject: [RFC PATCH v2 2/7] dmaengine: rebalance DMA channels when CPU hotplug happens Date: Mon, 14 May 2012 21:47:04 +0800 Message-Id: <1337003229-9158-3-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1337003229-9158-1-git-send-email-jiang.liu@huawei.com> References: <1337003229-9158-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Jiang Liu 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 file changed, 22 insertions(+) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 58bc45c..d3b1c48 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -1003,8 +1004,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);