From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB89EC433E0 for ; Tue, 2 Mar 2021 14:40:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FEA564F2B for ; Tue, 2 Mar 2021 14:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239337AbhCBOWL (ORCPT ); Tue, 2 Mar 2021 09:22:11 -0500 Received: from mx2.suse.de ([195.135.220.15]:38564 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235778AbhCBMn3 (ORCPT ); Tue, 2 Mar 2021 07:43:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 46604ACD4; Tue, 2 Mar 2021 12:42:18 +0000 (UTC) Message-ID: <5ba9bdddbdee87d501b791309115c2eadaf9be84.camel@suse.de> Subject: Re: [RFC 09/13] iommu/arm-smmu: Make use of dev_64bit_mmio_supported() From: Nicolas Saenz Julienne To: Arnd Bergmann Cc: DTML , Florian Fainelli , Will Deacon , Neil Armstrong , David Woodhouse , "linux-kernel@vger.kernel.org" , Russell King - ARM Linux , Christoph Hellwig , Rob Herring , Catalin Marinas , Robin Murphy , Ard Biesheuvel , Linux ARM Date: Tue, 02 Mar 2021 13:42:16 +0100 In-Reply-To: References: <20210226140305.26356-1-nsaenzjulienne@suse.de> <20210226140305.26356-10-nsaenzjulienne@suse.de> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-JrdrgEmwCwoQS03/ReLX" User-Agent: Evolution 3.38.4 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-JrdrgEmwCwoQS03/ReLX Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Arnd, thanks for the reviews! On Tue, 2021-03-02 at 10:32 +0100, Arnd Bergmann wrote: > On Fri, Feb 26, 2021 at 3:03 PM Nicolas Saenz Julienne > wrote: >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (smmu->impl && unlik= ely(smmu->impl->write_reg)) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0smmu->impl->write_reg(smmu, page, offset, val); > > - else > > + else if (dev_64bit_mmio_supported(smmu->dev)) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0writel_relaxed(val, arm_smmu_page(smmu, page) + = offset); > > + else > > + hi_lo_writeq_relaxed(val, arm_smmu_page(smmu, page) + o= ffset); > > =C2=A0} >=20 > This is a writel_relaxed(), not a writeq_relaxed(), so I suppose you don'= t > have to change it at all. Yes, that was silly of me. I was worrying about the semantics of the whole thing, and missed basic stuff like this. > > + else if (dev_64bit_mmio_supported(smmu->dev)) > > + return readq_relaxed(arm_smmu_page(smmu, page) + offset= ); > > + else > > + return hi_lo_readq_relaxed(arm_smmu_page(smmu, page) + = offset); > > } >=20 >=20 > I see this pattern repeat across multiple drivers. I think Christoph > had originally > suggested folding the if/else logic into the writel_relaxed() that is def= ined in > include/linux/io-64-nonatomic-hi-lo.h, but of course that doesn't work if= you > need to pass a device pointer. >=20 > It might still make sense to have another wrapper in that same file thoug= h, > something like >=20 > static inline hi_lo_writeq_relaxed_if_possible(struct device *dev, __u64 = val, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0volatile void __iomem *addr= ) > { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (dev_64bit_mmio_supported(sm= mu->dev)) { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0readq_relaxed(arm_smmu_page(smmu, page) + offset); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0writel_relaxed(val >> 32, addr + 4); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0writel_relaxed(val, addr); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > } I like the idea. I'll try to integrate it into the next revision. Regards, Nicolas --=-JrdrgEmwCwoQS03/ReLX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAmA+MqgACgkQlfZmHno8 x/7dpwf/aLel0KoDRYbTs0N1MCxUYaw65bxfhjj33y441mkd9HUSVemzI3HBOTln uEs/4WoEx/tWa+9t93oM2P+RLoQsk79775dXJzUUsKhaEjfFwEjEKlME+XCyedJ1 ST7bgtafNyYLOEVgDqIOm/ies5GMLg7uO8f9za9Qfyu77tclP2AkvKFhlOyKHp5M dbZY4+YwhzP6mqVRqZCPlQvHZUBh1UH7yQHdZNjZkLcgvz3x1+f6EUW+rScBrpNq iSqt5gav8YDB0AcWD7tsxDZajP1tTqqjHfREvZoycWs7QLeC8vrODzO7S/G4za7u a8YAd5JlT6Xja8V8kqq5VSQmcdNYoA== =Loxv -----END PGP SIGNATURE----- --=-JrdrgEmwCwoQS03/ReLX--