Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp8254241ybc; Fri, 29 Nov 2019 07:41:44 -0800 (PST) X-Google-Smtp-Source: APXvYqxhiNnC2hFxU3YgO6sSvkziMWKAJbLAxpIDcM/PCy1ymDsnGszvf2+yqUSJt64um6Je6cKG X-Received: by 2002:a17:906:9603:: with SMTP id s3mr20016413ejx.116.1575042104765; Fri, 29 Nov 2019 07:41:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575042104; cv=none; d=google.com; s=arc-20160816; b=kXEOzWFH0ywYRWSwhMhWrpNhWhDYFiUIumHO/oUrRqWBId7bXO4hpQFmPA5WFvvAcp D4AuX+DaXYnLneoIhHC6pViynaOCd8RRPm20qSygbmadiwDAN0GC+Az/vE2WbMD7BXWV 6RwPkB2tDoOgy95lX8pPx7dXcaG60sAJ7X3GdtMiMRaoV0wj920HigI49fkqcqGXyF/F U6aVvCkGJttTSxbgWjtNkfspIMRecDYXMcXHUPG5ihKhHcm/6MldXt/wUDahPVBZW1wM VNEmBaZRz60U3I4gHI/XyofWcjGUXJ5eJkXPViO0++mptwZzPGgo8S3OsRJWIlouiarG jt/w== 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=GZ64dFx/b6xoVXXGFcVREkFmLBqmtyqbMTpiRv9D3vk=; b=BODcKukbA7xhmFP3nDpKt75qwIoBEWtDdRoRhO7kDqJ892SdyT/CwJXwGrs+VTq6hY dEj7Yhnkkg5xE7VCpWZNo62R48T0w0SYrhDr/YhwU7AUIdTLf4dfhwHCpjQQ2H+QEOZC ZCJmB6s0f6eFB91D1bSDyMueZK05zqBObjXdPeKfqJCv5RdtoADCZop7whD97LHKU7Xc sIoJM44toO4jaBmKrFIm8Bc7fZ6ZjuvR2otCdGivdY4LzlM2Hjg+5lUPiOCchJdzC/kg 6Gufrypkda1r+QcprKN2Zrt6fPnVaPSoSVCoTGljQx5iK9JA8M/IGHwIcLnS31sLLnQ+ 1hMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@antmicro.com header.s=google header.b=b1IChhjA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si14805071ejq.189.2019.11.29.07.41.20; Fri, 29 Nov 2019 07:41:44 -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=@antmicro.com header.s=google header.b=b1IChhjA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727079AbfK2Pjl (ORCPT + 99 others); Fri, 29 Nov 2019 10:39:41 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:44310 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726608AbfK2Pjl (ORCPT ); Fri, 29 Nov 2019 10:39:41 -0500 Received: by mail-io1-f65.google.com with SMTP id j20so32789829ioo.11 for ; Fri, 29 Nov 2019 07:39:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antmicro.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GZ64dFx/b6xoVXXGFcVREkFmLBqmtyqbMTpiRv9D3vk=; b=b1IChhjArK99MWA1YVOtlfL8+65h6lp14vSr6zaz6U/uJRX1NnqsinLYifo5jeI8QL 9NQqI1S+uP+PGNiVgwxZaSP1yEr699GBPQgTa6Kxh2KZRCo8kjWU6gyU6oXnAHBXHxm3 kKZNUp9hgsc4yPCyLbIbC8GpTx/9/en1oOVRoFnC6VE98XRs3rHb47JkrHJC94IOtQeB i66Upa+3wY0VAI9TN3tHeEZHLaWFuZqdU/5nelGTlXkejXirbyXtWERnkMkfKQm+EgWO WBNJuDj1LGuChGWfugCocwa7j5aYFC6mASJdftS5jEu3k3FjKMWHf2Aw2qU7gKJaz5Yb RekQ== 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=GZ64dFx/b6xoVXXGFcVREkFmLBqmtyqbMTpiRv9D3vk=; b=BgeuL4dmMilezXgzrhbA469SPlDlvUocjTw0vjr5JaAq8OU/98Z+mJuiioVpl2o9jl KzpkEtUkm8uV9DOewQsuVihtg4mAvalQmZE1d+jhfu91ATZlEFN4uc/GSbtzNQAqQ4Ma vbAlGpbTrpwlGKTWveDuHzaCcv9j09t860jsQWjNHjSvkRanUYcFtjA38x0iU4u6SYFy gSKr9e0dvcuZocHZVjK1nWEpN7lKeAmHsovW0K7b65Ii7YWusatrs8MM30/onxpunBB2 hjYBgXttUEqE3KpK8jfpeMZ4c6AZBwOmqIoZU+rPXOQZAqqWaGIrmyCOwu2LWrPK3Ac5 CiTQ== X-Gm-Message-State: APjAAAUuMsyDZVXznzcxiLw5tEXtYp0KfCEGluSnYfbhiUf9/5s8XeQo CvpFHBZANAE92SWlkkSegoEbzLXac8QkMexFXIscvg== X-Received: by 2002:a02:a388:: with SMTP id y8mr10590059jak.70.1575041979840; Fri, 29 Nov 2019 07:39:39 -0800 (PST) MIME-Version: 1.0 References: <20191023114634.13657-0-mholenko@antmicro.com> <20191023114634.13657-2-mholenko@antmicro.com> <20191120192648.GA3087498@kroah.com> <20191126091926.GB1372654@kroah.com> In-Reply-To: <20191126091926.GB1372654@kroah.com> From: Mateusz Holenko Date: Fri, 29 Nov 2019 16:39:28 +0100 Message-ID: Subject: Re: [PATCH v2 2/4] litex: add common LiteX header To: Greg Kroah-Hartman Cc: Rob Herring , Mark Rutland , Jiri Slaby , devicetree@vger.kernel.org, "open list:SERIAL DRIVERS" , Stafford Horne , Karol Gugala , Mauro Carvalho Chehab , "David S. Miller" , "Paul E. McKenney" , Filip Kokosinski , Joel Stanley , Jonathan Cameron , Maxime Ripard , Shawn Guo , Heiko Stuebner , Sam Ravnborg , Icenowy Zheng , Laurent Pinchart , linux-kernel@vger.kernel.org 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 wt., 26 lis 2019 o 10:19 Greg Kroah-Hartman napisa=C5=82(a): > > On Tue, Nov 26, 2019 at 10:02:18AM +0100, Mateusz Holenko wrote: > > =C5=9Br., 20 lis 2019 o 20:26 Greg Kroah-Hartman > > napisa=C5=82(a): > > > > > > On Wed, Oct 23, 2019 at 11:47:04AM +0200, Mateusz Holenko wrote: > > > > +#ifdef __LITTLE_ENDIAN > > > > +# define LITEX_READ_REG(addr) ioread32(addr) > > > > +# define LITEX_READ_REG_OFF(addr, off) ioread32(addr + off= ) > > > > +# define LITEX_WRITE_REG(val, addr) iowrite32(val, addr= ) > > > > +# define LITEX_WRITE_REG_OFF(val, addr, off) iowrite32(val, addr= + off) > > > > +#else > > > > +# define LITEX_READ_REG(addr) ioread32be(addr) > > > > +# define LITEX_READ_REG_OFF(addr, off) ioread32be(addr + o= ff) > > > > +# define LITEX_WRITE_REG(val, addr) iowrite32be(val, ad= dr) > > > > +# define LITEX_WRITE_REG_OFF(val, addr, off) iowrite32be(val, ad= dr + off) > > > > +#endif > > > > > > I just noticed this. > > > > > > Ick, this is not good. You will run into problems in the future with > > > this, I can guarantee it. What about systems where the CPU is one > > > endian and the hardware in the other? It will happen trust us. > > > > As mentioned in the previous comment, LiteX CSRs are guaranteed to be > > always little-endian - this includes configurations with both > > big-endian and little-endian CPUs. > > What enforces that guarantee? liteuart is na IP core that comes as a part of a design generated and configured by LiteX SoC builder (https://github.com/enjoy-digital/litex). Current implementation of LiteX generates systems in such a way that CSRs in peripherals are little-endian regardless of a softcore CPU used (available options cover both little-endian and big-endian CPU cores). Liteuart is a part of the LiteX project and is probably not usable outside of it. I was digging through the code and documentation to verify that the always-little-endian-CSR behaviour is "guaranteed", but - to my surprise - couldn't find anything. It seems to be simply an implementation detail that might (maybe?) change in the future. In this context your suggestion about probing things dynamically seems to be even more relevant. > > The aim of including the ifdef section was exactly to target situation > > where endianness is different for CPU and devices. As such this > > approach *should* work. > > "should" :) > > We have seen it happen all the time that some hardware team hooks this > up backwards, no matter what the "spec" required. So be careful here. > > good luck! > > greg k-h --=20 Mateusz Holenko Antmicro Ltd | www.antmicro.com Roosevelta 22, 60-829 Poznan, Poland