From patchwork Wed Apr 24 06:38:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 16368 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0350623A3C for ; Wed, 24 Apr 2013 06:39:57 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id fs12sf2032304lab.10 for ; Tue, 23 Apr 2013 23:39:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=8lbzU+Fbq/2corncdl75NRH7N10qqnYGdzdJ8t80CQw=; b=NsecYV3Rtl8wFE+HwF9mhjU6nV3BWl6HaVceuD3vTVKWffXvWpZnCSYE9kwr7w5861 MRw2bSewkH4pnhH+xerLauLvUxA4Ww/pB4MjZYdIs+lSh2S2O6dncllFnRI/EAdwF2Vl 9pH+sZFKpCZohG8XRRXxU3Ygx5PgkhBd4WfQ9SHJjX/2BKa5DWT7ANf179p/ZnkOfX5K fP1UXq6MDfgW9RktXteOUvcjMWVAsmLk1ehTuyQ55qiz5ebsU6/IEIjJB+HQoiySqPaC gcTBLGDBICXzIG1oLgKJvPn06Vbcjg4LmZmRKOjSVxR1SUFjwnZURMELpSnvcUKorg+O XR/g== X-Received: by 10.180.198.210 with SMTP id je18mr16167186wic.1.1366785546058; Tue, 23 Apr 2013 23:39:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.81.195 with SMTP id c3ls1308415wiy.54.canary; Tue, 23 Apr 2013 23:39:05 -0700 (PDT) X-Received: by 10.194.122.7 with SMTP id lo7mr43981718wjb.48.1366785545951; Tue, 23 Apr 2013 23:39:05 -0700 (PDT) Received: from mail-ve0-x22f.google.com (mail-ve0-x22f.google.com [2607:f8b0:400c:c01::22f]) by mx.google.com with ESMTPS id ci12si424137wjb.210.2013.04.23.23.39.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Apr 2013 23:39:05 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22f; Received: by mail-ve0-f175.google.com with SMTP id m1so571298ves.20 for ; Tue, 23 Apr 2013 23:39:04 -0700 (PDT) X-Received: by 10.58.181.201 with SMTP id dy9mr24695888vec.34.1366785544859; Tue, 23 Apr 2013 23:39:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp158470veb; Tue, 23 Apr 2013 23:39:03 -0700 (PDT) X-Received: by 10.15.77.133 with SMTP id p5mr15452385eey.46.1366785543205; Tue, 23 Apr 2013 23:39:03 -0700 (PDT) Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) by mx.google.com with ESMTPS id h7si2012371eex.211.2013.04.23.23.39.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Apr 2013 23:39:03 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.48 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=74.125.83.48; Received: by mail-ee0-f48.google.com with SMTP id d49so540960eek.35 for ; Tue, 23 Apr 2013 23:39:02 -0700 (PDT) X-Received: by 10.15.98.66 with SMTP id bi42mr59642911eeb.39.1366785542570; Tue, 23 Apr 2013 23:39:02 -0700 (PDT) Received: from localhost ([2a01:2003:1:1f50:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPSA id v48sm1905490eeg.7.2013.04.23.23.38.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 23 Apr 2013 23:39:01 -0700 (PDT) From: Fabio Baltieri To: Felipe Balbi Cc: Greg Kroah-Hartman , Linus Walleij , Lee Jones , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Virupax Sadashivpetimath , stable , Fabio Baltieri Subject: [PATCH] usb: musb: make use_sg flag URB specific Date: Wed, 24 Apr 2013 08:38:48 +0200 Message-Id: <1366785528-32158-1-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.1.3 X-Gm-Message-State: ALoCoQmZygEi700rB6I4MsnOjUwkzGwPe3it1bfuIpR0WMsnzdoa/2G6rTBrPkaxt94rTd+yohKX X-Original-Sender: fabio.baltieri@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Virupax Sadashivpetimath Since highmem PIO URB handling was introduced in: 8e8a551 usb: musb: host: Handle highmem in PIO mode when a URB is being handled it may happen that the static use_sg flag was set by a previous URB with buffer in highmem. This leads to error in handling the present URB. Fix this by making the use_sg flag URB specific. Cc: stable # 3.7+ Acked-by: Linus Walleij Signed-off-by: Virupax Sadashivpetimath Signed-off-by: Fabio Baltieri --- drivers/usb/musb/musb_host.c | 18 ++++++++---------- drivers/usb/musb/musb_host.h | 1 + 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 1a6b5a9..26d3f140 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -1232,7 +1232,6 @@ void musb_host_tx(struct musb *musb, u8 epnum) void __iomem *mbase = musb->mregs; struct dma_channel *dma; bool transfer_pending = false; - static bool use_sg; musb_ep_select(mbase, epnum); tx_csr = musb_readw(epio, MUSB_TXCSR); @@ -1463,9 +1462,9 @@ done: * NULL. */ if (!urb->transfer_buffer) - use_sg = true; + qh->use_sg = true; - if (use_sg) { + if (qh->use_sg) { /* sg_miter_start is already done in musb_ep_program */ if (!sg_miter_next(&qh->sg_miter)) { dev_err(musb->controller, "error: sg list empty\n"); @@ -1484,9 +1483,9 @@ done: qh->segsize = length; - if (use_sg) { + if (qh->use_sg) { if (offset + length >= urb->transfer_buffer_length) - use_sg = false; + qh->use_sg = false; } musb_ep_select(mbase, epnum); @@ -1552,7 +1551,6 @@ void musb_host_rx(struct musb *musb, u8 epnum) bool done = false; u32 status; struct dma_channel *dma; - static bool use_sg; unsigned int sg_flags = SG_MITER_ATOMIC | SG_MITER_TO_SG; musb_ep_select(mbase, epnum); @@ -1878,12 +1876,12 @@ void musb_host_rx(struct musb *musb, u8 epnum) * NULL. */ if (!urb->transfer_buffer) { - use_sg = true; + qh->use_sg = true; sg_miter_start(&qh->sg_miter, urb->sg, 1, sg_flags); } - if (use_sg) { + if (qh->use_sg) { if (!sg_miter_next(&qh->sg_miter)) { dev_err(musb->controller, "error: sg list empty\n"); sg_miter_stop(&qh->sg_miter); @@ -1913,8 +1911,8 @@ finish: urb->actual_length += xfer_len; qh->offset += xfer_len; if (done) { - if (use_sg) - use_sg = false; + if (qh->use_sg) + qh->use_sg = false; if (urb->status == -EINPROGRESS) urb->status = status; diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h index 5a9c8fe..738f7eb 100644 --- a/drivers/usb/musb/musb_host.h +++ b/drivers/usb/musb/musb_host.h @@ -74,6 +74,7 @@ struct musb_qh { u16 frame; /* for periodic schedule */ unsigned iso_idx; /* in urb->iso_frame_desc[] */ struct sg_mapping_iter sg_miter; /* for highmem in PIO mode */ + bool use_sg; /* to track urb using sglist */ }; /* map from control or bulk queue head to the first qh on that ring */