Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1375953ybf; Sun, 1 Mar 2020 07:54:00 -0800 (PST) X-Google-Smtp-Source: APXvYqy5Df/JoSQjQl7eavxMpwjRtRgWLLkJHT9u3gG8e4vfpE+iNzk8SlJMi5B0X0YgZZYa9Wd5 X-Received: by 2002:a9d:4541:: with SMTP id p1mr10370622oti.199.1583078040309; Sun, 01 Mar 2020 07:54:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583078040; cv=none; d=google.com; s=arc-20160816; b=aqrocQm28AaN1EroAM23unrpDpz3EqTW5TA2+x4U6vjP96SlXCfi63+VJHcUD8ayTV lhoBDOKXrq2G8s4hswjQXMAq3TmKcxJ4YvRSPeeDBpShf+CjH4o1CCBmpsqUFhuPuOeG ifaAuJ73B3mF2vaP1TX1lcaAcUInf/9F7uJXQuZaj6B8QTuPXk6EAh3JVYIDrAc0jByj jramSdPbeBIMMW7FBNvT7bZfD10K/ZBXxj+evv37v1M/ZYbNuZbVwLJGDlBmzALhJUOK S3PgTdwyFmG8dqVV51MzwWPyYYkmH1MbxhSfnYY6TeLH3SyOFijZop4CTH2uBotxmPsC 3iQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=1YX6Y1gQNmVyzC4OFTtavzK3SSTW7dvfILV1Msp9sSY=; b=Uaekx+PFHUOU9s/SI+FtuZbpKoNIpzryoK8BxGT1kEVoIzEl0DQfnOcKwfX3+k27Sa 3qePV1PwX0yHtHCllZ/GBYY/rFlmplrxzpr+Cp3rk3loc7PrG7wscgEWwU8/KRkh/oUj XymK0UbEabMnoQuDmJ4a1k8CD4YlQEmGCculOJaStVjqz+YvH/tOMSWBTyzpBunUQ4pQ YOzU+GxZ6iDFkmpD0pGlg8+/9r+rngF3dLI5/5IJPyK9s3QdvXzIOZhHdA41cPPn0zfJ pKYnfkAAEPWRv+JB9JkPz+gnIWqwuNGqHBIlAIuKi+RNLcJJpY7dEjFQsZm0D/7eOnPG 286g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uU2y5uYQ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n70si3674121oig.95.2020.03.01.07.53.49; Sun, 01 Mar 2020 07:54:00 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uU2y5uYQ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbgCAPwT (ORCPT + 99 others); Sun, 1 Mar 2020 10:52:19 -0500 Received: from mail-il1-f195.google.com ([209.85.166.195]:40580 "EHLO mail-il1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbgCAPwT (ORCPT ); Sun, 1 Mar 2020 10:52:19 -0500 Received: by mail-il1-f195.google.com with SMTP id g6so5875741ilc.7; Sun, 01 Mar 2020 07:52:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1YX6Y1gQNmVyzC4OFTtavzK3SSTW7dvfILV1Msp9sSY=; b=uU2y5uYQGU56GBfqjH6M8RBtuS2X8yeZGTLxlAiuz89V8aaYeg1+Ysd6GgoTNrNurH +WeqiHMvOzzDn9T+Vpx6W33VRMO2Q85JzNKDfD8eQ5aF2DMd2AD/t+35dyGX54MHXdf2 4C0DJtaW/OMCK559rWmYs/++F1YUtJT9eH+2J1ovHjno9S3bABNvSFjJj2ScE0nRLkrR L/KRiKGigHSxyDwmfrITE4BY3UNheMZB10sgBVt8NnEYqrxoBWTVTYzfoHuAfrr7ZYXl mk5MCrXSp4uojrWa87Nea7wRkCcmK6O6srdjfZsbYFyYl9Wp3VIQgIqu8JqQ3WxGqHsq bjGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1YX6Y1gQNmVyzC4OFTtavzK3SSTW7dvfILV1Msp9sSY=; b=UE4Fpn/8A8/kqlaZy1zrdu6blVZgWQuhhw8T9H+K4pyKlq+6omqjVDOgIybdJfmjFM omjYmyvN26USI2rG/hATTEPocKFIbsPh262kv/NEvCtPitt6PD8SvGwtL4f1WH9o1pD4 90AaqLgvtIRySVy0dMnpmkUFs10CV/tEYd5t7ZGin54YSZcxpo8AaY+VbymTNuKpBmNU sbBU+szKn16T4Kel6XwF7o+Vv8WEb/k7JmY+qqahN2yQTNGbqSefk26qwm23WJ4Kxakb 47r/psLNKQYuB53dNeqY+5CjwjjFyJTl/pNZU+FevUTgzGF7Bi5veJbjmFMsOJU1oimC tWxw== X-Gm-Message-State: APjAAAUDoFt+IxCWZVyU/oQpz13RZjfgeKM/dvpUWOyNXmsB3NfNacqb 9UT/yq6WjOV0DgaOK+VUO/fWJQqBox6bzsvED2Q= X-Received: by 2002:a92:4a0b:: with SMTP id m11mr12562957ilf.122.1583077938497; Sun, 01 Mar 2020 07:52:18 -0800 (PST) MIME-Version: 1.0 References: <20200226210414.28133-1-linux@roeck-us.net> <20200226210414.28133-2-linux@roeck-us.net> <20200228175905.GB3188@roeck-us.net> <62d81632-4a6f-b2d8-e420-b58fb6c9d044@roeck-us.net> In-Reply-To: From: =?UTF-8?B?QW50dGkgU2VwcMOkbMOk?= Date: Sun, 1 Mar 2020 17:51:42 +0200 Message-ID: Subject: Re: [RFT PATCH 1/4] usb: dwc2: Simplify and fix DMA alignment code To: Guenter Roeck Cc: Doug Anderson , Minas Harutyunyan , Greg Kroah-Hartman , Boris ARZUR , linux-usb@vger.kernel.org, LKML , Felipe Balbi , Stefan Wahren , Martin Schiller Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 29 Feb 2020 at 18:33, Antti Sepp=C3=A4l=C3=A4 = wrote: > > On Sat, 29 Feb 2020 at 17:25, Guenter Roeck wrote: > > > > Sigh. It would have been too simple. Too bad I can't test myself. > > I'd like to know if this is because URB_NO_TRANSFER_DMA_MAP is set on a > > transfer, or because the beginning of the buffer indeed needs to be ali= gned > > to the DMA cache line size on that system. In the latter case, the ques= tion > > is why the alignment to DWC2_USB_DMA_ALIGN (=3D4) works. In the former = case, > > question would be why the realignment does any good in the first place. > > > > Any chance you can add some test code to help figuring out what exactly > > goes wrong ? > > > > Sure, I can try to help. Just let me know what code you would like to > insert and where and I'll see what I can do. > So I did some further research on this and it turns out that: - URB_NO_TRANSFER_DMA_MAP is not set on the offending transfers so the issue really is buffer alignment - DWC2_USB_DMA_ALIGN=3D4 "works" because in my limited testcase (usb 4g-dongle utilized via qmi-wwan) all transfers are unaligned. That is, every urb->transfer_buffer is misaligned by 2 bytes =3D=3D unaligned - I can fix both issues and thus make the patch work on MIPS by modifying it like this: -#define DWC2_USB_DMA_ALIGN 4 +#define DWC2_USB_DMA_ALIGN dma_get_cache_alignment() struct dma_aligned_buffer { void *old_xfer_buffer; - u8 data[0]; + u8 data[0] ____cacheline_aligned; }; --=20 Antti