Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3066121pxj; Mon, 7 Jun 2021 01:03:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvBBRn2Y2FCxQs1+xFCNwze8hsT9W+AkGEwtxSYhIpHivcaIJ5t/r+32bHyfRLjEKbGZHb X-Received: by 2002:a17:906:b307:: with SMTP id n7mr16571435ejz.261.1623053011918; Mon, 07 Jun 2021 01:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623053011; cv=none; d=google.com; s=arc-20160816; b=Ula1H0Juqcx57wvuGiL68eB8ao0Siyv90CE6AWJ4lxxaJCZ+BslWRqUsaAH1Yd8kZZ crfeludhYwbzRtfYNn1jbs4Z+Hvweah+nENXrrFi+R0Pw/mA6BOfwaGH26hGMcCjly8+ +he+j3M/H7kmySli+GxnDNUeLrq10Dow9xG199dFJJng8I5qPRZ1Twn2BC1s3S1p5Paf QvsQxi4vuq7dn2lC9Db2JYAOBDDw6qNUtzcU6Xz+2UORu9vcj3hnUZd696dXuJzcN1Bm ICLIGMMGuv3jpwkmkOuBdTZmeLqvq47QMa1HfaTmmVOaDdcUtc2SsdPODxhmm2QpMX3L LXlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature:dkim-signature; bh=pi51sQPyO+v+HxFzLV7xeS0Ul+G+7aVbQaStkS90iwc=; b=aUdYJIzmQ6NCKVp5KR3AIC5sjbl2PNBkXbvVGE1DUJzX9BOBqVH+htJ2/sGnIp5OZc ViquWMM/ao0AwIjkJU0AOjElptHb1fXegq9X3y5LOKH9DBVZ9KtDbSbanRoWQJHB+Jv0 ViBTUYTj3w6rQrhcXNkQdGvT3+hbLNgxdbQiUNhlL914D1I70afLLia2El6/d+vm4dds /me0cJeOI8DgrE8RMWD5UoWttXz579/aG0sYYRdqlLZMYWJej+Hzh11aPfJ+YijmKWVO y+3BNwih66QlKxio2OvF49Sm54wmXnRT2LeNJ22Gik408Y2N+Duibgw7loLO0nCAXJuH FfLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b="p/Nu1H7v"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=eN1yEgQY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si12266020edr.492.2021.06.07.01.03.09; Mon, 07 Jun 2021 01:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b="p/Nu1H7v"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=eN1yEgQY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230281AbhFGIEK (ORCPT + 99 others); Mon, 7 Jun 2021 04:04:10 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:38311 "EHLO wout5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230410AbhFGIEH (ORCPT ); Mon, 7 Jun 2021 04:04:07 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id EECC4DBD; Mon, 7 Jun 2021 04:02:14 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute3.internal (MEProxy); Mon, 07 Jun 2021 04:02:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=mime-version:message-id:in-reply-to:references:date:from:to :cc:subject:content-type; s=fm1; bh=pi51sQPyO+v+HxFzLV7xeS0Ul+G+ 7aVbQaStkS90iwc=; b=p/Nu1H7vvxJLufWppVSbptoET2eqBryLbD1enxhS3BWb b+sEiYKS3WcqyPx5PDO0qg8vVmHhw655EWjHvA2FkZByr42gPnQstHUu+zj3S4fO lBg82ADuvNUjBdJGhbgRb5vqPCgfyVPJYnDmT6X+Ru0OdrzrvrakkZW8IASUmWkp DEsG7oJuzKwmQfYmoIs/l/ooMhE25yAT00/j6wKcNkhqNaClUXFhPreZC++mRwwN 5DXh2vQ/oht161uXbuzw/d7/CpVl1rtfvBMAUmOIXNji+4fFHz2jfCazZTAtgQT2 v4yAJoJoFP7CD03VUN8XigWyjXONPDjoes2yihirwg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=pi51sQ PyO+v+HxFzLV7xeS0Ul+G+7aVbQaStkS90iwc=; b=eN1yEgQYNjJULIUkPXXEfy E+b6MyqVsZ3gzK0fZSu0jMmVKkEdUnCi/CabGXKyRGQuf4mxgSUPzfNNcmfK4KE0 oSy89RWr8lfhwuWyi7JELUbwuxXb7LqeowuLqIVQBpdvAcF6FvPGF8Kg16aoBdI3 6bXgI1GSWXd4CBD0ihv5B6r/nzvO/Rj4PxzpePHxYgddBYLsJdwjJoGbmwdhaeP1 MA/IW1gPBr4vN5yoKi9pMG2mvHt+eqAhW/ynlQm3eO6COzBQ4uQYR/OviuB8gjI3 SCCY5VxZ3m/T8c2yVhlXdbFsr4pGIHiA9crd3hWrMPwrhdc4v2TaxA+6PLK2FIiw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedtiedguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfufhv vghnucfrvghtvghrfdcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrf grthhtvghrnhepgfeigeeiffeuhfettdejgfetjeetfeelfefgfefgvddvtdfghfffudeh vdefkeffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshhvvghnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id B3D2A51C0061; Mon, 7 Jun 2021 04:02:13 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-519-g27a961944e-fm-20210531.001-g27a96194 Mime-Version: 1.0 Message-Id: <23348bfc-aad7-4e5f-83b1-e69463e618e5@www.fastmail.com> In-Reply-To: References: <20210607061751.89752-1-sven@svenpeter.dev> Date: Mon, 07 Jun 2021 10:01:50 +0200 From: "Sven Peter" To: "Arnd Bergmann" Cc: "USB list" , "Felipe Balbi" , "Greg Kroah-Hartman" , "Linux Kernel Mailing List" Subject: Re: [PATCH v3] usb: dwc3: support 64 bit DMA in platform driver Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 7, 2021, at 09:25, Arnd Bergmann wrote: > On Mon, Jun 7, 2021 at 8:18 AM Sven Peter wrote: > > > > Currently, the dwc3 platform driver does not explicitly ask for > > a DMA mask. This makes it fall back to the default 32-bit mask which > > breaks the driver on systems that only have RAM starting above the > > first 4G like the Apple M1 SoC. > > > > Fix this by calling dma_set_mask_and_coherent with a 64bit mask. > > > > Signed-off-by: Sven Peter > > --- > > > > Third time's a charm I hope - this time much simpler :) > > I think this is almost good, but there is still one small issue: > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > index b6e53d8212cd..ba4792b6a98f 100644 > > --- a/drivers/usb/dwc3/core.c > > +++ b/drivers/usb/dwc3/core.c > > @@ -1545,6 +1545,10 @@ static int dwc3_probe(struct platform_device *pdev) > > > > dwc3_get_properties(dwc); > > > > + ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64)); > > + if (ret) > > + return ret; > > This will now fail on machines with dwc3 connected to a 32-bit bus (or a > bus that is accidentally not annotated as supporting 64-bit) when there is > some memory that is not addressable through that bus. > > If dma_set_mask_and_coherent() fails, the platform should just fall back to > 32-bit addressing as it did before your change. dma_alloc_*() will do that > implicitly by allocating from ZONE_DMA32, while dma_map_*() fails > on any non-addressable memory, or falls back to swiotlb if that is available. Makes sense, but just to make sure I understand this correctly: All that needs to be done is call dma_set_mask_and_coherent with a 64 bit mask and then just ignore the return value? Thanks, Sven