Received: from eggs.gnu.org ([2001:4830:134:3::10]:39585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1hMi-0006i7-PX for qemu-devel@nongnu.org; Mon, 30 Jun 2014 15:35:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1hMZ-0005SQ-IA for qemu-devel@nongnu.org; Mon, 30 Jun 2014 15:35:48 -0400 Received: from mail-qa0-x22b.google.com ([2607:f8b0:400d:c00::22b]:42967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1hMZ-0005S5-13 for qemu-devel@nongnu.org; Mon, 30 Jun 2014 15:35:39 -0400 Received: by mail-qa0-f43.google.com with SMTP id k15so6769210qaq.2 for ; Mon, 30 Jun 2014 12:35:38 -0700 (PDT) Date: Mon, 30 Jun 2014 15:35:36 -0400 From: "Gabriel L. Somlo" Message-ID: <20140630193535.GP1688@ERROL.INI.CMU.EDU> References: <1404147350-28904-1-git-send-email-somlo@cmu.edu> <1404147350-28904-2-git-send-email-somlo@cmu.edu> <20140630180412.GB2871@redhat.com> <20140630181250.GN1688@ERROL.INI.CMU.EDU> <20140630192956.GO1688@ERROL.INI.CMU.EDU> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140630192956.GO1688@ERROL.INI.CMU.EDU> Subject: Re: [Qemu-devel] [RFC PATCH v1 1/2] e1000: clean up set_phy_ctrl function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: pbonzini@redhat.com, Jason Wang , qemu-devel@nongnu.org, stefanha@redhat.com, agraf@suse.de Sorry for the repeated self-replies, I appear to be thinking in very small increments today :) On Mon, Jun 30, 2014 at 03:29:57PM -0400, Gabriel L. Somlo wrote: > > > Weird. > > > So does this mean have_autoneg is always false then? > > > How does it work? > > Oh, I think I know what's going on now: > > In set_mdic() we have: > > ... > } else { > if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) { > phyreg_writeops[addr](s, index, data); > } > s->phy_reg[addr] = data; > } > ... Of course, we could change this to ... } else { if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) { phyreg_writeops[addr](s, index, data); } else { s->phy_reg[addr] = data; } } and have phy_set_ctrl() be a proper write_op, expected to actually write the data as well as do other things. That would at least be a step toward the principle of least WTF, IMHO :) I'll send out an updated patch shortly... Thanks, --Gabriel > ... > > Basically, phyreg_writeops[PHY_CTRL] == set_phy_ctrl() is the only > one that applies, but it's like a "pre-write" writeop, the write > happens *after* the write_op completes :) :) Fun stuff... > > Leaving it as-is is probably OK, although it does indeed not handle > SC bits properly. > > I could rewrite have_autoneg() to accept the *value* of the phy control > register, then we can use it from set_phy_ctrl() before the register > is actually written. Not sure about whether that would be more or less > ugly than the current form :) > > Thanks, > --Gabriel