From owner-freebsd-usb@FreeBSD.ORG Wed Jan 30 15:54:10 2008 Return-Path: Delivered-To: usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4ED8116A417 for ; Wed, 30 Jan 2008 15:54:10 +0000 (UTC) (envelope-from raj@semihalf.com) Received: from mail.semihalf.com (mail.semihalf.com [83.15.139.206]) by mx1.freebsd.org (Postfix) with ESMTP id B5A6613C43E for ; Wed, 30 Jan 2008 15:54:09 +0000 (UTC) (envelope-from raj@semihalf.com) Received: from localhost (unknown [127.0.0.1]) by mail.semihalf.com (Postfix) with ESMTP id 7E82814287 for ; Wed, 30 Jan 2008 16:29:19 +0100 (CET) Received: from mail.semihalf.com ([127.0.0.1]) by localhost (mail.semihalf.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19438-03 for ; Wed, 30 Jan 2008 16:28:59 +0100 (CET) Message-ID: <47A095D5.2060801@semihalf.com> Date: Wed, 30 Jan 2008 16:20:53 +0100 From: Rafal Jaworowski MIME-Version: 1.0 To: usb@freebsd.org Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at semihalf.com Cc: Subject: USB transfer coherency problems with write-allocate caches X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jan 2008 15:54:10 -0000 Hi, While working on an ARM SoC port, we have ecountered problems with USB transfer incoherencies on the border of busdma and d-cache enabled for write-allocate. This is observed with umass(4)/EHCI and mainfests with the following error: umass0: Invalid CSW: tag 1 should be 2 (probe0:umass-sim0:0:0:0): Request completed with CAM_REQ_CMP_ERR (probe0:umass-sim0:0:0:0): Retrying Command umass0: Invalid CSW: tag 1 should be 3 (probe0:umass-sim0:0:0:0): Request completed with CAM_REQ_CMP_ERR (probe0:umass-sim0:0:0:0): Retrying Command umass0: Invalid CSW: tag 1 should be 4 (probe0:umass-sim0:0:0:0): Request completed with CAM_REQ_CMP_ERR (probe0:umass-sim0:0:0:0): Retrying Command umass0: Invalid CSW: tag 1 should be 5 (probe0:umass-sim0:0:0:0): Request completed with CAM_REQ_CMP_ERR (probe0:umass-sim0:0:0:0): Retrying Command umass0: Invalid CSW: tag 1 should be 6 (probe0:umass-sim0:0:0:0): Request completed with CAM_REQ_CMP_ERR (probe0:umass-sim0:0:0:0): error 5 (probe0:umass-sim0:0:0:0): Retries Exausted Because of the way write-allocate works, we can end up having an old and un-flushed CSW in the cache (from a previous transaction) overwrite the newly arrived CSW, and hence the tags inconsistencies. Doing a BUS_DMASYNC_PREREAD in usbd_start_transfer() fixes the problems, see this patch: http://people.freebsd.org/~raj/patches/misc/usbdi-bus_dma-fix.diff I'd like to hear comments from people knowing other architectures if they have any comments/objections. Rafal PS. Please keep me on CC as I'm not subscribed to the list.