From: Wolfgang Denk Date: Fri, 02 Sep 2011 11:24:59 +0200 Subject: [U-Boot] [PATCH v3] net: ll_temac: Add LL TEMAC driver to u-boot In-Reply-To: <4E609682.8030701@monstr.eu> References: <1314877154-14536-1-git-send-email-monstr@monstr.eu> <20110901130605.A31D2166C886@gemini.denx.de> <4E5F85DA.4080403@monstr.eu> <20110901140904.3334B18C46FE@gemini.denx.de> <4E607A0B.3040608@monstr.eu> <20110902081901.AC090137213A@gemini.denx.de> <4E609682.8030701@monstr.eu> Message-ID: <20110902092459.857E7203630@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Michal Simek, In message <4E609682.8030701@monstr.eu> you wrote: > > >>>>>> +static void sdma_out_be32(struct ll_priv *priv, u32 offset, u32 val) > >>>>>> +{ > >>>>>> + if (priv->mode & DCR_BIT) > >>>>>> + mtdcr_local(priv->ctrl + offset, val); > >>>>>> + else > >>>>>> + out_be32((u32 *)(priv->ctrl + offset * 4), val); > >>>>>> +} > > ... ... > >> The first reg for DMA2 accessed trough DCR is at 0xB0, the second at 0xB1, etc.. > > > > This is indeed a good example, as it shows how terribly broken your > > code is. > > > > See function sdma_out_be32() above. It is suppose to write a 32 bit > > value ("u32 val") as a 32 bit entity in big endian mode ("_be32") to > > some device register - but the register addresses are (1) not aligned > > to 32 bit boundaries and (2) not even 32 bits apart. > > I think you misunderstand what there is written. Maybe. Maybe even I want to misunderstand it. The problem is that the code does not prevent such misunderstanding. There are many shortcomings of that code. > DCR is defined just for PPC right now because none wanted to do it for Microblaze. Actually even this is incorrect - AFAIK Device Control Registers (DCR) exist not on all PPC systems, but only on 4xx (and even there only on some models). So your code works on a few systems, silently does not do anything on others, and crashes on yet others with an illegal instruction. How do you call code that exposes such behaviour? I don't want to have this in mainline. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Don't hit a man when he's down - kick him; it's easier.