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.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 E1DA7C433E0 for ; Wed, 3 Mar 2021 14:18:30 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F064164E90 for ; Wed, 3 Mar 2021 14:18:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F064164E90 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: MIME-Version:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=i/nI1vPGmMB/9/bs6GNXpTqjVrf3Nh7ACeAQDQ5E21M=; b=TOQSucebfVOI8tQu7D31tJ19N 3p6s8eQo31Ezj00HpuX3tvv4Z/3dO8dfki3mEH0KTJtPUkKrUCG4aiSfOj2rL91FiYe56mkE+xSY5 gHiqHn5DyJi4/QP9bJYzUJ0kIHOVBeK6k6senLAgwCARoduPgN+fgo6fLLPXw11PkizkGpWyuVrzx UhvYSqNLq+i/C5KfbmC60UGLgvBcxME5H10cU21AaotuoAQIixs1jFatW0QU7l1PSEk7xIuXTUNw/ /wtcyGPS9LuO9vO/dRxxXvqOYHZJWDMiVfmrd1szFfP8LwSq9hwn7sLAyYt/mQhcS530q06vRTM9g XtW7lC/1g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHSHd-0055gm-Ng; Wed, 03 Mar 2021 14:15:26 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHS5u-0052Ng-I8 for linux-arm-kernel@desiato.infradead.org; Wed, 03 Mar 2021 14:03:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=MIME-Version:Content-Type:References: In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/6t5iosqfKjsEQGWumzJMBqxesGG81Q370wO0E0xkrg=; b=l2EMFlfNhc2GZPI1kagNeo0Arv hEGccvBi77Y3v40kpMPuHFZH3o8ZHhIOg/HJzBeQAO01A0ZWVD3kkzFCRyUR7lxlg0RXRk/rs+STc 3zelLYL7H9sWyZtVa5BS/ePCCw0umxWkESm3bM8oHZ0qRHeji7cynZHHerNLi04VwztRuliJV/a/m 0gAurG1519VRfsZTwMldcsJMrTKNrDFl/10Jf2EULFff07ppzTjHKlxhlYa2QS3YTj9EQTOoAdwSq kPJz6VVrw5vD6brZlnL5MnhiCG25ZnKMh99DURTOqkWWUdiajVxEfW64OryFy9ZoVRLgF8/3CSXK7 TGKy+S1A==; Received: from mx2.suse.de ([195.135.220.15]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH4M2-00H7V3-1V for linux-arm-kernel@lists.infradead.org; Tue, 02 Mar 2021 12:42:23 +0000 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> User-Agent: Evolution 3.38.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_124223_033701_C72EC317 X-CRM114-Status: GOOD ( 21.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1086083662806423070==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============1086083662806423070== Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-JrdrgEmwCwoQS03/ReLX" --=-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-- --===============1086083662806423070== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============1086083662806423070==--