From patchwork Tue Jan 17 13:15:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 91646 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp482445qgi; Tue, 17 Jan 2017 05:15:21 -0800 (PST) X-Received: by 10.98.215.27 with SMTP id b27mr40447777pfh.70.1484658921657; Tue, 17 Jan 2017 05:15:21 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e144si24943607pfh.43.2017.01.17.05.15.21; Tue, 17 Jan 2017 05:15:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750941AbdAQNPU (ORCPT + 4 others); Tue, 17 Jan 2017 08:15:20 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:37393 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750939AbdAQNPT (ORCPT ); Tue, 17 Jan 2017 08:15:19 -0500 Received: by mail-wm0-f48.google.com with SMTP id c206so222199590wme.0 for ; Tue, 17 Jan 2017 05:15:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oQlLO/6ZnlGxh++XpQbXobRptxS4Zl9QHCTKKbg81WM=; b=bhwi5KLlcWAfIcckjoZ2eLkYkyMY9nQTP7S4s0TCRLKDBPrFKBdHO/S8a9Gtk167aT HNvobW8gx7EucovUPRNkITTCT5lJNtCcraAvmPDpnSlcP//3wCmeKekuxW0EjELg9axs Jr9sbVAmahYzqKcwjD93gx1pea3T6OgOm4vCtgS0O7s/8vWFf7nrzvDuZorXeGDh+t5J 0U59f4werHkZWZGDJf2urU8co0eJf/vLFLqZccTC+X9EwmKA6rwao0jZZz4SbZTiRaQL LkGhc8lRat3IERZVm2duVxbDDIfi31sou3Ct4+qqCWI3OWdmUY8CgTR2LQTL9jaVb+tQ 2Bbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oQlLO/6ZnlGxh++XpQbXobRptxS4Zl9QHCTKKbg81WM=; b=rjJ9xbXFeWA3zvqNVIhZnQNJZhp+sThoRf5VQGIKb5ciyFHU9iyn1NgsaKkqyeKISi SMc6cdIarTpLGW1YBsMS8/WIBbJBJLwCL43A5DgPDyZ9NcJ2KcGvQZzDh2WDsiRmL6cE ktWNjremHXd0beXn7913Pp5GwE5V4GjLBQyuOaOWs/R9l5ArSUMdIAOJgh4zMzzrpSBe 5A0Q1beSkwKiZeaMCmEmxrOy4j5aDDhUcMW+XxmlS40McwGT2wfags4fOsKEbxUEDutP p6gW8wb7vrouOmWLvPa0WhI8ifTmJTWKp4mXKMbRk+hbrlTU08/hRWdPoTgyJbC3JOla pZbA== X-Gm-Message-State: AIkVDXItFVL+lp2nkgBLN7u7cHUHgp/rF5rLz8aeQFPeuqFwmIr+7GvTE0FpMbcA2OWElSSr X-Received: by 10.28.109.218 with SMTP id b87mr15293671wmi.52.1484658917599; Tue, 17 Jan 2017 05:15:17 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id 197sm37008036wmy.16.2017.01.17.05.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jan 2017 05:15:16 -0800 (PST) From: Alexandre Bailon To: vinod.koul@intel.com Cc: dmaengine@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, tony@atomide.com, linux-omap@vger.kernel.org, b-liu@ti.com, sergei.shtylyov@cogentembedded.com, Alexandre Bailon Subject: [PATCH v2 1/2] usb: musb: cppi41: Add new functions for platform driver Date: Tue, 17 Jan 2017 14:15:10 +0100 Message-Id: <20170117131511.7252-2-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170117131511.7252-1-abailon@baylibre.com> References: <20170117131511.7252-1-abailon@baylibre.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Currently, the CPPI 4.1 driver is not completely generic and only work on dsps. Add two functions which will help to move platform code from CPPI 4.1 to MUSB glue driver: - cppi41_register_dma_callback() to register a platform dma_callback (e.g to acknowledge interrupt on DMA completion). - cppi41_dma_controller_to_musb() to convert a dma_controller pointer to a musb pointer. This is required to get a musb pointer from DMA callbacks. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/musb_cppi41.c | 27 +++++++++++++++++++++++++-- drivers/usb/musb/musb_dma.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index 1636385..d76022b 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -36,6 +36,8 @@ struct cppi41_dma_controller { u32 rx_mode; u32 tx_mode; u32 auto_req; + + cppi41_platform_dma_callback dma_callback; }; static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel) @@ -217,6 +219,10 @@ static void cppi41_dma_callback(void *private_data) int is_hs = 0; bool empty; + controller = cppi41_channel->controller; + if (controller->dma_callback) + controller->dma_callback(musb); + spin_lock_irqsave(&musb->lock, flags); dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie, @@ -249,8 +255,6 @@ static void cppi41_dma_callback(void *private_data) * We spin on HS (no longer than than 25us and setup a timer on * FS to check for the bit and complete the transfer. */ - controller = cppi41_channel->controller; - if (is_host_active(musb)) { if (musb->port1_status & USB_PORT_STAT_HIGH_SPEED) is_hs = 1; @@ -288,6 +292,16 @@ static void cppi41_dma_callback(void *private_data) spin_unlock_irqrestore(&musb->lock, flags); } +void cppi41_register_dma_callback(struct dma_controller *c, + cppi41_platform_dma_callback callback) +{ + struct cppi41_dma_controller *controller = container_of(c, + struct cppi41_dma_controller, controller); + + controller->dma_callback = callback; +} +EXPORT_SYMBOL_GPL(cppi41_register_dma_callback); + static u32 update_ep_mode(unsigned ep, unsigned mode, u32 old) { unsigned shift; @@ -709,3 +723,12 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) return NULL; } EXPORT_SYMBOL_GPL(cppi41_dma_controller_create); + +struct musb *cppi41_dma_controller_to_musb(struct dma_controller *c) +{ + struct cppi41_dma_controller *controller = container_of(c, + struct cppi41_dma_controller, controller); + + return controller->musb; +} +EXPORT_SYMBOL_GPL(cppi41_dma_controller_to_musb); diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h index 46357e1..7f3c585 100644 --- a/drivers/usb/musb/musb_dma.h +++ b/drivers/usb/musb/musb_dma.h @@ -231,9 +231,13 @@ extern struct dma_controller * cppi_dma_controller_create(struct musb *musb, void __iomem *base); extern void cppi_dma_controller_destroy(struct dma_controller *c); +typedef void (*cppi41_platform_dma_callback)(struct musb *musb); extern struct dma_controller * cppi41_dma_controller_create(struct musb *musb, void __iomem *base); extern void cppi41_dma_controller_destroy(struct dma_controller *c); +extern struct musb *cppi41_dma_controller_to_musb(struct dma_controller *c); +extern void cppi41_register_dma_callback(struct dma_controller *c, + cppi41_platform_dma_callback callback); extern struct dma_controller * ux500_dma_controller_create(struct musb *musb, void __iomem *base); From patchwork Tue Jan 17 13:15:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 91647 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp482455qgi; Tue, 17 Jan 2017 05:15:23 -0800 (PST) X-Received: by 10.98.57.154 with SMTP id u26mr43322958pfj.136.1484658923095; Tue, 17 Jan 2017 05:15:23 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e144si24943607pfh.43.2017.01.17.05.15.22; Tue, 17 Jan 2017 05:15:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750985AbdAQNPV (ORCPT + 4 others); Tue, 17 Jan 2017 08:15:21 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38244 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964AbdAQNPU (ORCPT ); Tue, 17 Jan 2017 08:15:20 -0500 Received: by mail-wm0-f53.google.com with SMTP id r144so221803784wme.1 for ; Tue, 17 Jan 2017 05:15:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Txmf5oc3bvMof3NIp+pdlskPHzOnlIr5fb2jY/KeWBc=; b=rxAwhS70BWBHmifnGFJ6SjBM2d8eci6R/5V84whzsHzw8M/jzNUAnKE2JFL1QV8fMl yftHoFvYEueCJIPkn5ew3mr6LjUpbzGyYyTdbYG8y7aWSEhyTIkxsRckGDflF3l/lKo+ F02Qo11Gyqv+K1Nh5N+euMG7j0qpX9Rd57VTnmOKzi38RjpfPlNJE6WMJrkd4qFmptOf luChfSUQRM3r06e2xjpTMfEYCw7AhrEPt7Bpnjeu2C4Z+3m947eFv7fyVssHui8bBn+F EXysXrSX9byUkzxUpSEGvdgKIG3aIjLuxChuRPKkoHRpvMvN2uwYfbLeIDO3EY5ZhYdo 4oCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Txmf5oc3bvMof3NIp+pdlskPHzOnlIr5fb2jY/KeWBc=; b=gkSEp6ionyM2a06UTyWp1rogM4PbHAkZM+k3AqCtvGAg36wx9JclJN5pX0t3B1jNwY /Vtk9UBRP/7VS9d0vwIvz+5rAYkSNefZQck1zGfL5lnSbrJtRCxir7/GTWP0my5k05nS GDaxv3LJ9OH2RxeaTBe81EEhPY0Wu0VcChrcjNsk5JiC/mAdsPqo8klzwZ7G/YeYKJU5 1q09RTP0w+ng0ervVKf72LMuTi6Oxn+FeRGu/s1XB6m3PO7e00GhlBoZHY/q4/jFcRcI YlG2+NCtCMB5hPD+be+NuwXQ/9UZu9wqpqAVOpNX1fkDyjb18CQWC8CeGtrNEU2vv/iQ U9dw== X-Gm-Message-State: AIkVDXJcHXS5863s/88q/IENRa4EEPt02ftZvgVGAIGMPMCCPeu4Jx4EyQn8PZkCEsztBgUB X-Received: by 10.28.181.145 with SMTP id e139mr15377704wmf.103.1484658919375; Tue, 17 Jan 2017 05:15:19 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id 197sm37008036wmy.16.2017.01.17.05.15.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jan 2017 05:15:18 -0800 (PST) From: Alexandre Bailon To: vinod.koul@intel.com Cc: dmaengine@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, tony@atomide.com, linux-omap@vger.kernel.org, b-liu@ti.com, sergei.shtylyov@cogentembedded.com, Alexandre Bailon Subject: [PATCH v2 2/2] usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback() Date: Tue, 17 Jan 2017 14:15:11 +0100 Message-Id: <20170117131511.7252-3-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170117131511.7252-1-abailon@baylibre.com> References: <20170117131511.7252-1-abailon@baylibre.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Update cppi41_dma_callback() to detect an aborted transfer. This was not required before because cppi41_dma_callback() was only invoked on transfer completion. In order to make CPPI 4.1 driver more generic, cppi41_dma_callback() will be invoked after a transfer abort in order to let the MUSB driver perform some action such as acknowledge the interrupt that may be fired during a teardown. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/musb_cppi41.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index d76022b..f182c07 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -101,7 +101,8 @@ static bool musb_is_tx_fifo_empty(struct musb_hw_ep *hw_ep) return true; } -static void cppi41_dma_callback(void *private_data); +static void cppi41_dma_callback(void *private_data, + const struct dmaengine_result *result); static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel) { @@ -156,7 +157,7 @@ static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel) if (WARN_ON(!dma_desc)) return; - dma_desc->callback = cppi41_dma_callback; + dma_desc->callback_result = cppi41_dma_callback; dma_desc->callback_param = &cppi41_channel->channel; cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); trace_musb_cppi41_cont(cppi41_channel); @@ -206,7 +207,8 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer) return ret; } -static void cppi41_dma_callback(void *private_data) +static void cppi41_dma_callback(void *private_data, + const struct dmaengine_result *result) { struct dma_channel *channel = private_data; struct cppi41_dma_channel *cppi41_channel = channel->private_data; @@ -223,6 +225,9 @@ static void cppi41_dma_callback(void *private_data) if (controller->dma_callback) controller->dma_callback(musb); + if (result->result == DMA_TRANS_ABORTED) + return; + spin_lock_irqsave(&musb->lock, flags); dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie, @@ -415,7 +420,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel, if (!dma_desc) return false; - dma_desc->callback = cppi41_dma_callback; + dma_desc->callback_result = cppi41_dma_callback; dma_desc->callback_param = channel; cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); cppi41_channel->channel.rx_packet_done = false;