Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp175349imu; Thu, 6 Dec 2018 22:12:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/UzaiXSgp9vagZGDXk7qRukhJqRsgjqLMuhn0qBFuNBCatKAXOX+YhbZxJCm0BZcW+7uaIN X-Received: by 2002:a62:3141:: with SMTP id x62mr1029121pfx.12.1544163164987; Thu, 06 Dec 2018 22:12:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544163164; cv=none; d=google.com; s=arc-20160816; b=wnn+SDOJ+BwC/DRhZTegrJ0gh53Kxs8JnHdFSqp7mueoBrpU+MTMSR0OvwRRh5ZWDi UBvt45ofKgi6jUkRTFPZJsqcd3TVq5Cx4yPlllApANq8nhdtP35L3siXNeD8aH/hiObr wDNSUOpDnzqcbjitJrTMj4hFNGynv9j9VL5nWvgdIJAbSaGeLGjQDhNwSFVhkmgQiVPe P4EZDmVoDnODrSwJaugVtTxTETLfHzY9T8zn9jx4NEl11UTdLltrC8ZQ1ia5/VZKPrgQ /bSIsxiG0SiPy20ORjTCIbirbqjMY4yocDXewqAzRaCwARQQF0PJbKi5UisNXeK9dvOD HQ4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=nLa9z+Iu6tjzbHi8uYCefzZo9ZWzNrNsGXSH7Wse6fM=; b=rL7MqcHHoXowaUdcyJd9UecMXOYsEcUAWcurbDy50NYlsoLR7TuEQkJ8HouiP9d5vw YGDMJi4I4stCIPiHcpqJLrZA2eek+gYDAROIljirdj9U+wlY5TiYQ6QNS1r8jjei5s6m kmxBP0URpZDoVHhss5C4+VruOPuTkOLUNcJkUcz31u2jOVKWFmaVEvEySEZL1+GRB2du xMT4vR5QzU3D0gXIkXanJnm+j1uU13fF6cTT1qYjXc0W0s3/BTVkP99n/6jnG33c8yTx cq+EEL+TXquyNm9J7WE53FEDXb9iTq9GBUSvusF2na/7Z/EX4nAUTOUwrITimLUjahyx VMcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v189si2021651pgb.398.2018.12.06.22.12.28; Thu, 06 Dec 2018 22:12:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725992AbeLGGLx (ORCPT + 99 others); Fri, 7 Dec 2018 01:11:53 -0500 Received: from mga17.intel.com ([192.55.52.151]:38895 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbeLGGLx (ORCPT ); Fri, 7 Dec 2018 01:11:53 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Dec 2018 22:11:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,324,1539673200"; d="scan'208";a="123764889" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.72.175]) by fmsmga002.fm.intel.com with ESMTP; 06 Dec 2018 22:11:48 -0800 From: Felipe Balbi To: Anurag Kumar Vulisha , Greg Kroah-Hartman , Shuah Khan , Alan Stern , Johan Hovold , Jaejoong Kim , Benjamin Herrenschmidt , Roger Quadros , Manu Gautam , "martin.petersen\@oracle.com" , Bart Van Assche , Mike Christie , Matthew Wilcox , Colin Ian King Cc: "linux-usb\@vger.kernel.org" , "linux-kernel\@vger.kernel.org" , "v.anuragkumar\@gmail.com" , Thinh Nguyen , Tejas Joglekar , Ajay Yugalkishore Pandey Subject: RE: [PATCH v7 09/10] usb: dwc3: Check for IOC/LST bit in both event->status and TRB->ctrl fields In-Reply-To: References: <1543662811-5194-1-git-send-email-anurag.kumar.vulisha@xilinx.com> <1543662811-5194-10-git-send-email-anurag.kumar.vulisha@xilinx.com> <875zw82vfj.fsf@linux.intel.com> Date: Fri, 07 Dec 2018 08:11:47 +0200 Message-ID: <874lbpx3vg.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Anurag Kumar Vulisha writes: >>> @@ -2286,7 +2286,12 @@ static int >>dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, >>> if (event->status & DEPEVT_STATUS_SHORT && !chain) >>> return 1; >>> >>> - if (event->status & (DEPEVT_STATUS_IOC | DEPEVT_STATUS_LST)) >>> + if ((event->status & DEPEVT_STATUS_IOC) && >>> + (trb->ctrl & DWC3_TRB_CTRL_IOC)) >>> + return 1; >> >>this shouldn't be necessary. According to databook, event->status >>contains the bits from the completed TRB. Which means that >>event->status & IOC will always be equal to trb->ctrl & IOC. >> > Thanks for reviewing this patch. Lets consider an example where a request > has num_sgs > 0 and each sg is mapped to a TRB and the last TRB has the > IOC bit set. Once the controller is done with the transfer, it generates > XferInProgress for the last TRB (since IOC bit is set). As a part of trb reclaim > process dwc3_gadget_ep_reclaim_trb_sg() calls > dwc3_gadget_ep_reclaim_completed_trb() for req->num_sgs times. Since > the event already has the IOC bit set, the loop is exited from the loop at the > very first TRB and the remaining TRBs (mapped to the sglist) are left unhandled. > To avoid this we modified the code to exit only if both TRB & event has the IOC > bit set. Seems like IOC case should just test for chain flag as well: modified drivers/usb/dwc3/gadget.c @@ -2372,7 +2372,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, if (event->status & DEPEVT_STATUS_SHORT && !chain) return 1; - if (event->status & DEPEVT_STATUS_IOC) + if (event->status & DEPEVT_STATUS_IOC && !chain) return 1; return 0; -- balbi