Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1781313rdb; Thu, 25 Jan 2024 06:07:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEumSeQKK4zHrhWi4Ye2NDn/BfRkRihrAC8UoqFrQehQfrtA5njHBmAuyqRzV6GjdAJz9C7 X-Received: by 2002:a17:906:4a18:b0:a31:1a20:8ad0 with SMTP id w24-20020a1709064a1800b00a311a208ad0mr507023eju.155.1706191634491; Thu, 25 Jan 2024 06:07:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706191634; cv=pass; d=google.com; s=arc-20160816; b=RgsFVbFV/J5tatUBKY1GMwhtypIe9R/tfOn0eYBFejZSOVh2b/2LdA2IL5XU9tzfbN zzahPjFfOnMz9rrLvB4lpgVT9rJ7oQz5wbnisx/LRuQPN2P0ZkzYTU/t4bD1y4gmo/EB MTvCmKqYWtvoivbruDHW/hNJUqEhaP65o04Fzf8KdtcKmszlJW466jkmLtBwaNFmtfOx USvFb7Q6UshkfpOKM8hG4cNWSNBTRV+CxPK4Zn+rENrTmx/WyMk20Pf2h04Fkxy2GBRZ 2orf02eGUMNTP2M1piRwKFjp5evWgXBQ/GNvJ0Y8ZtaSZK/cWpc5XyT7gKrv9DudO4yt 1E7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+dgwbLNQZUUkM3P26rXaaVfEGlwAg1uVIoXax0FCC+Y=; fh=4sXfdSQyjmc96ke1rtO2iuC9vblT2Ox67/QQ++Jp/Nw=; b=FWICPDuaIBrP3nhPEOmD1UN5PGuLNLZWo9sZdty8MWnTFMHxsmvzMcIrqIBxLP1OFh Yp26bSUprgNuer71OHwi5MVCwg0QKCkHLSMMiLM2CpbdGgc6Z6XdoY7Rx+HHCFPRH+j+ sG36yGLG5ubCnSs9ItKm7WSL+sQnJ/zbNyQuvssZyRkOmqSiA9TlZ0XYklItd0sxOR9t eMm30Iy6jf4DU3twrSSUCMygooueW43rW6HFDZG91AcwA67e+BKdeZAOICPr0HMzEL4b miFnAGEaCFZ13iq70pCXsmMXVvtuJ1O70j0+w7V8cMx3zanivWhA57dOQP2sNU4hxZRC jWxw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TK3+NGFQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-38700-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38700-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v20-20020a170906339400b00a30c933c62bsi414454eja.353.2024.01.25.06.07.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 06:07:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38700-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TK3+NGFQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-38700-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38700-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8FA771F23012 for ; Thu, 25 Jan 2024 14:06:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A29C62A0C; Thu, 25 Jan 2024 14:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TK3+NGFQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9480262812; Thu, 25 Jan 2024 14:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706191573; cv=none; b=TVAZHAiA5bMOkpWoslGedbUGMsCqamwhs8KTQMLrrSqubX55skPyydNZTNjteQ7/wagg0wX6VoUwljyT6R5eD0Qzowt0W6FMXtxVloJcrshI7j1Z6HF0weCWFQbgNnJjNFCHgfPOWo68LwRBH/g2UX7hngIWV+qetCqjJRw86Bk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706191573; c=relaxed/simple; bh=G4QAP5APqsbl64s+QuDiT63+BHv2vR1X3SL4Yr7Rzns=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q9tiFX7u2NaJMP/GByNcE+73oQPH+wnRgi/o4gaoTLRWPU/lnpq1Snhiz++N2dtfqlZNUBjr+L3C7AZGRx795VItmwRDbJvqqIOBAEN9GP8gtQHPO/NY2e+rwwluAoqwkx+35AtJlgcECxzF/mNTux/YNDCGfVgfXYYR9XUd6s0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TK3+NGFQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1408C433C7; Thu, 25 Jan 2024 14:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706191573; bh=G4QAP5APqsbl64s+QuDiT63+BHv2vR1X3SL4Yr7Rzns=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TK3+NGFQMeAVRx4ymxjxQJrv8UMD0YnQzyWplwLfDTnsYbyE5nrI6SHhJOKNwwVxa iSZ+0fpd4wKyayJC/QKXIWfjbLHLT271UGEx2o6LF1tgvT5geKPBS9x7rLdX+Td9rC dIiK+UmqsbaczIgknBD3u6epmnZtAaHULgZwIZ3lRI66iAY16mT033Cg4asp3tLZbj 8NhPiwLnZ39OACOqNGsoGao4KLxgw/W2WhZYJj5z6IMfOe2GEv3z3iofAD0CuBXP+R MWPSHXq503puswZytnZUI8ameL4V/NgD4AF4gLiiRi8e/1sacJEPKv5aLml47Bq6BU 9FOul8fPqk3qg== Date: Thu, 25 Jan 2024 15:06:05 +0100 From: Niklas Cassel To: Lennert Buytenhek Cc: Damien Le Moal , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Robin Murphy , John Garry , Joerg Roedel Subject: Re: [PATCH] ahci: add 43-bit DMA address quirk for ASMedia ASM106x controllers Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jan 25, 2024 at 03:43:06PM +0200, Lennert Buytenhek wrote: > On Thu, Jan 25, 2024 at 02:30:14PM +0100, Niklas Cassel wrote: (snip) > > > @@ -943,11 +951,19 @@ static int ahci_pci_device_resume(struct device *dev) > > > > > > #endif /* CONFIG_PM */ > > > > > > -static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac) > > > +static int ahci_configure_dma_masks(struct pci_dev *pdev, > > > + struct ahci_host_priv *hpriv) > > > { > > > - const int dma_bits = using_dac ? 64 : 32; > > > + int dma_bits; > > > int rc; > > > > > > + if (!(hpriv->cap & HOST_CAP_64)) > > > + dma_bits = 32; > > > + else if (hpriv->flags & AHCI_HFLAG_43BIT_ONLY) > > > + dma_bits = 43; > > > + else > > > + dma_bits = 64; > > > + > > > > I would prefer if you write this as: > > > > if (hpriv->cap & HOST_CAP_64) { > > dma_bits = 64; > > if (hpriv->flags & AHCI_HFLAG_43BIT_ONLY) > > dma_bits = 43; > > } else { > > dma_bits = 32; > > } > > > > Such that we still require the device to advertize 64 bit support, > > and the quirk. > > If the device does not advertize 64, we don't want it to be possible > > to use a mask >32, even if the quirk flag is set. > > Isn't that logic exactly the same as in my version? I.e. in both > versions, HOST_CAP_64 has to be set and AHCI_HFLAG_43BIT_ONLY has > to be set for dma_bits to become 43. > > (I don't mind doing it your way, I just don't see a functional > difference between the versions. :-) ) Yes, you are right. But please change it to not use an inverted check for the flag anyway, as such pattern has apparently proven to be too complicated for my brain to interpret correctly already :) Kind regards, Niklas