From patchwork Fri Oct 17 17:09:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 38922 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D1A8F202DB for ; Fri, 17 Oct 2014 17:11:12 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id d1sf784797wiv.10 for ; Fri, 17 Oct 2014 10:11:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=d8aWm9/txfcejOa4tKhwyr4EdqJkcLvjjzsHIgH+D14=; b=ANXXoIFXhnJU6EEUk3GszXFy4S64P/0XnFniaHua695y9X8rFCIARMSzIAO7APRdzp fBRHP0X5RqVvZ2D7BoITaDGxdzIF2RrBCNbvRxLlywSjl7gvDdd3HH6rXzrTD0ffSqYe W1RmnBvFUga9IbrYczuWidb/VFoa/+abrZnDEKxU2gCtOQyuVp18/pbfGvTsIDSrE0Rp uxsQowIZ8lJV2wRNVoUcGxK7h0f6PvgCZ8leg5kN5in/5Km4yu7csIMBBcZuWVoIOdSd pgxM2d4MZrlry78EiDUE7D9uZfWBBqt6iWpgurSNnIVoPE1MjfbP4YxxjrzhDNXm3cWJ Cr6Q== X-Gm-Message-State: ALoCoQmPsxq31c8NkbY6eC8cgjAQNcwLl0/c3q8t0xcg133tP6NNqAZG6z3e1xtAdJJWyEgukyyr X-Received: by 10.112.26.82 with SMTP id j18mr67945lbg.16.1413565872077; Fri, 17 Oct 2014 10:11:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.1 with SMTP id s1ls288709lal.30.gmail; Fri, 17 Oct 2014 10:11:11 -0700 (PDT) X-Received: by 10.152.161.195 with SMTP id xu3mr10073336lab.15.1413565871822; Fri, 17 Oct 2014 10:11:11 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id p1si1411728laj.36.2014.10.17.10.11.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 10:11:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gi9so1078964lab.35 for ; Fri, 17 Oct 2014 10:11:11 -0700 (PDT) X-Received: by 10.153.8.164 with SMTP id dl4mr10178642lad.29.1413565871753; Fri, 17 Oct 2014 10:11:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp266846lbz; Fri, 17 Oct 2014 10:11:11 -0700 (PDT) X-Received: by 10.66.138.47 with SMTP id qn15mr9935542pab.82.1413565870222; Fri, 17 Oct 2014 10:11:10 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8si1689853pdo.55.2014.10.17.10.11.09 for ; Fri, 17 Oct 2014 10:11:10 -0700 (PDT) Received-SPF: none (google.com: linux-usb-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753457AbaJQRKU (ORCPT + 3 others); Fri, 17 Oct 2014 13:10:20 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:43990 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752032AbaJQRKS (ORCPT ); Fri, 17 Oct 2014 13:10:18 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9HHAHDk007445 for ; Fri, 17 Oct 2014 12:10:17 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9HHAHuO027722 for ; Fri, 17 Oct 2014 12:10:17 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Fri, 17 Oct 2014 12:10:17 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9HHAGVg022597; Fri, 17 Oct 2014 12:10:17 -0500 From: Felipe Balbi To: Linux USB Mailing List CC: Felipe Balbi Subject: [PATCH 02/28] usb: dwc3: ep0: hold our lock in dwc3_gadget_ep0_set_halt Date: Fri, 17 Oct 2014 12:09:38 -0500 Message-ID: <1413565804-13061-3-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.1.0.GIT In-Reply-To: <1413565804-13061-1-git-send-email-balbi@ti.com> References: <1413565804-13061-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balbi@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , dwc3_gadget_ep0_set_halt() will be called without locks held in some cases, so we must hold the lock on our own. While at that, also add a version without locks to be called in certain conditions. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/ep0.c | 16 +++++++++++++++- drivers/usb/dwc3/gadget.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index b359387..36f6158 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -271,7 +271,7 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc) dwc3_ep0_out_start(dwc); } -int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value) +int __dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value) { struct dwc3_ep *dep = to_dwc3_ep(ep); struct dwc3 *dwc = dep->dwc; @@ -281,6 +281,20 @@ int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value) return 0; } +int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value) +{ + struct dwc3_ep *dep = to_dwc3_ep(ep); + struct dwc3 *dwc = dep->dwc; + unsigned long flags; + int ret; + + spin_lock_irqsave(&dwc->lock, flags); + ret = __dwc3_gadget_ep0_set_halt(ep, value); + spin_unlock_irqrestore(&dwc->lock, flags); + + return ret; +} + void dwc3_ep0_out_start(struct dwc3 *dwc) { int ret; diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index 178ad89..f889008 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h @@ -82,6 +82,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, void dwc3_ep0_interrupt(struct dwc3 *dwc, const struct dwc3_event_depevt *event); void dwc3_ep0_out_start(struct dwc3 *dwc); +int __dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value); int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value); int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, gfp_t gfp_flags);