From patchwork Wed May 28 02:36:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Dutt X-Patchwork-Id: 4252271 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 780FCBF90B for ; Wed, 28 May 2014 02:37:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 92132202A1 for ; Wed, 28 May 2014 02:37:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95B4120279 for ; Wed, 28 May 2014 02:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753938AbaE1ChE (ORCPT ); Tue, 27 May 2014 22:37:04 -0400 Received: from mga03.intel.com ([143.182.124.21]:18478 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753823AbaE1ChD (ORCPT ); Tue, 27 May 2014 22:37:03 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 27 May 2014 19:37:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,924,1392192000"; d="scan'208";a="437833787" Received: from unknown (HELO localhost.ra.intel.com) ([10.10.34.161]) by azsmga001.ch.intel.com with ESMTP; 27 May 2014 19:36:59 -0700 From: Sudeep Dutt To: Greg Kroah-Hartman , Dan Williams Cc: Siva Yerramreddy , Ashutosh Dixit , Nikhil Rao , Sudeep Dutt , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Subject: [PATCH char-misc-next 7/8] misc: mic: add dma support in card driver Date: Tue, 27 May 2014 19:36:16 -0700 Message-Id: <2c741e954fbec33048a9a280b820ed9deffbf59a.1401239759.git.sudeep.dutt@intel.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Siva Yerramreddy This patch adds a dma device on the mic virtual bus Reviewed-by: Nikhil Rao Signed-off-by: Sudeep Dutt Signed-off-by: Siva Yerramreddy Signed-off-by: Ashutosh Dixit --- drivers/misc/mic/Kconfig | 2 +- drivers/misc/mic/card/mic_device.h | 3 +++ drivers/misc/mic/card/mic_x100.c | 52 +++++++++++++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mic/Kconfig b/drivers/misc/mic/Kconfig index bf76313..cc4eef0 100644 --- a/drivers/misc/mic/Kconfig +++ b/drivers/misc/mic/Kconfig @@ -39,7 +39,7 @@ comment "Intel MIC Card Driver" config INTEL_MIC_CARD tristate "Intel MIC Card Driver" - depends on 64BIT && X86 + depends on 64BIT && X86 && INTEL_MIC_BUS select VIRTIO help This enables card driver support for the Intel Many Integrated diff --git a/drivers/misc/mic/card/mic_device.h b/drivers/misc/mic/card/mic_device.h index e12a0c2..8d735ba 100644 --- a/drivers/misc/mic/card/mic_device.h +++ b/drivers/misc/mic/card/mic_device.h @@ -31,6 +31,7 @@ #include #include #include +#include /** * struct mic_intr_info - Contains h/w specific interrupt sources info @@ -71,6 +72,7 @@ struct mic_device { * @hotplug_work: Hot plug work for adding/removing virtio devices. * @irq_info: The OS specific irq information * @intr_info: H/W specific interrupt information. + * @dma_mbdev: dma device on the MIC virtual bus. */ struct mic_driver { char name[20]; @@ -81,6 +83,7 @@ struct mic_driver { struct work_struct hotplug_work; struct mic_irq_info irq_info; struct mic_intr_info intr_info; + struct mbus_device dma_mbdev; }; /** diff --git a/drivers/misc/mic/card/mic_x100.c b/drivers/misc/mic/card/mic_x100.c index 2868945..85066cf 100644 --- a/drivers/misc/mic/card/mic_x100.c +++ b/drivers/misc/mic/card/mic_x100.c @@ -148,6 +148,46 @@ void mic_card_unmap(struct mic_device *mdev, void __iomem *addr) iounmap(addr); } +static inline struct mic_driver *mbdev_to_mdrv(struct mbus_device *mbdev) +{ + return dev_get_drvdata(mbdev->dev.parent); +} + +static struct mic_irq *_mic_request_threaded_irq(struct mbus_device *mbdev, + irq_handler_t handler, irq_handler_t thread_fn, + const char *name, void *data, int intr_src) +{ + int rc = 0; + unsigned int irq = intr_src; + unsigned long cookie = irq; + + rc = request_threaded_irq(irq, handler, thread_fn, 0, name, data); + if (rc) { + dev_err(mbdev_to_mdrv(mbdev)->dev, + "request_threaded_irq failed rc = %d\n", rc); + return ERR_PTR(rc); + } + return (struct mic_irq *)cookie; +} + +static void _mic_free_irq(struct mbus_device *mbdev, + struct mic_irq *cookie, void *data) +{ + unsigned long irq = (unsigned long)cookie; + free_irq(irq, data); +} + +static void _mic_ack_interrupt(struct mbus_device *mbdev, int num) +{ + mic_ack_interrupt(&mbdev_to_mdrv(mbdev)->mdev); +} + +static struct mbus_hw_ops mbus_hw_ops = { + .request_threaded_irq = _mic_request_threaded_irq, + .free_irq = _mic_free_irq, + .ack_interrupt = _mic_ack_interrupt, +}; + static int __init mic_probe(struct platform_device *pdev) { struct mic_driver *mdrv = &g_drv; @@ -166,13 +206,22 @@ static int __init mic_probe(struct platform_device *pdev) goto done; } mic_hw_intr_init(mdrv); + platform_set_drvdata(pdev, mdrv); + rc = mbus_add_device(&mdrv->dma_mbdev, mdrv->dev, MBUS_DEV_DMA_MIC, + NULL, &mbus_hw_ops, mdrv->mdev.mmio.va); + if (rc) { + dev_err(&pdev->dev, "mbus_add_device failed rc %d\n", rc); + goto iounmap; + } rc = mic_driver_init(mdrv); if (rc) { dev_err(&pdev->dev, "mic_driver_init failed rc %d\n", rc); - goto iounmap; + goto remove_dma; } done: return rc; +remove_dma: + mbus_remove_device(&mdrv->dma_mbdev); iounmap: iounmap(mdev->mmio.va); return rc; @@ -184,6 +233,7 @@ static int mic_remove(struct platform_device *pdev) struct mic_device *mdev = &mdrv->mdev; mic_driver_uninit(mdrv); + mbus_remove_device(&mdrv->dma_mbdev); iounmap(mdev->mmio.va); return 0; }