All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-trivial] [PATCH] hw/net/eepro100: Implement read-only bits in MDI registers
Date: Sun, 08 Jun 2014 15:31:58 +0400	[thread overview]
Message-ID: <539449AE.4090909@msgid.tls.msk.ru> (raw)
In-Reply-To: <1402159924-13853-1-git-send-email-peter.maydell@linaro.org>

07.06.2014 20:52, Peter Maydell wrote:
> Although we defined an eepro100_mdi_mask[] array indicating which bits
> in the registers are read-only, we weren't actually doing anything with
> it. Make the MDI register-read code use it rather than manually making
> registers 2 and 3 totally read-only and the rest totally read-write.

s/register-read/register-write/ -- can be fixed when applying.

I'm not sure this is "trivial enough", because the side effect is
not obvious, at least not to someone not familiar with eepro100
registers and their usage.

Besides, the description does not seem to be very accurate too.
From the code I see that the original code makes register 0
"semi-writable", register 1 is unwritable and the rest fully
writable.

In this context, apparently we're losing the ability to write to
register 0 completely, since its mask is 0 but the original code
allows writing something to it.

Also, maybe updating the "missing()" calls according to the
bitmask is a good idea...

Thanks,

/mjt

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This seemed a better fix for the unused variable than just deleting it...
> 
>  hw/net/eepro100.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
> index 3b891ca..9c70cce 100644
> --- a/hw/net/eepro100.c
> +++ b/hw/net/eepro100.c
> @@ -1217,7 +1217,6 @@ static void eepro100_write_mdi(EEPRO100State *s)
>                  break;
>              case 1:            /* Status Register */
>                  missing("not writable");
> -                data = s->mdimem[reg];
>                  break;
>              case 2:            /* PHY Identification Register (Word 1) */
>              case 3:            /* PHY Identification Register (Word 2) */
> @@ -1230,7 +1229,8 @@ static void eepro100_write_mdi(EEPRO100State *s)
>              default:
>                  missing("not implemented");
>              }
> -            s->mdimem[reg] = data;
> +            s->mdimem[reg] &= eepro100_mdi_mask[reg];
> +            s->mdimem[reg] |= data & ~eepro100_mdi_mask[reg];
>          } else if (opcode == 2) {
>              /* MDI read */
>              switch (reg) {
> 



WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] hw/net/eepro100: Implement read-only bits in MDI registers
Date: Sun, 08 Jun 2014 15:31:58 +0400	[thread overview]
Message-ID: <539449AE.4090909@msgid.tls.msk.ru> (raw)
In-Reply-To: <1402159924-13853-1-git-send-email-peter.maydell@linaro.org>

07.06.2014 20:52, Peter Maydell wrote:
> Although we defined an eepro100_mdi_mask[] array indicating which bits
> in the registers are read-only, we weren't actually doing anything with
> it. Make the MDI register-read code use it rather than manually making
> registers 2 and 3 totally read-only and the rest totally read-write.

s/register-read/register-write/ -- can be fixed when applying.

I'm not sure this is "trivial enough", because the side effect is
not obvious, at least not to someone not familiar with eepro100
registers and their usage.

Besides, the description does not seem to be very accurate too.
>From the code I see that the original code makes register 0
"semi-writable", register 1 is unwritable and the rest fully
writable.

In this context, apparently we're losing the ability to write to
register 0 completely, since its mask is 0 but the original code
allows writing something to it.

Also, maybe updating the "missing()" calls according to the
bitmask is a good idea...

Thanks,

/mjt

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This seemed a better fix for the unused variable than just deleting it...
> 
>  hw/net/eepro100.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
> index 3b891ca..9c70cce 100644
> --- a/hw/net/eepro100.c
> +++ b/hw/net/eepro100.c
> @@ -1217,7 +1217,6 @@ static void eepro100_write_mdi(EEPRO100State *s)
>                  break;
>              case 1:            /* Status Register */
>                  missing("not writable");
> -                data = s->mdimem[reg];
>                  break;
>              case 2:            /* PHY Identification Register (Word 1) */
>              case 3:            /* PHY Identification Register (Word 2) */
> @@ -1230,7 +1229,8 @@ static void eepro100_write_mdi(EEPRO100State *s)
>              default:
>                  missing("not implemented");
>              }
> -            s->mdimem[reg] = data;
> +            s->mdimem[reg] &= eepro100_mdi_mask[reg];
> +            s->mdimem[reg] |= data & ~eepro100_mdi_mask[reg];
>          } else if (opcode == 2) {
>              /* MDI read */
>              switch (reg) {
> 

  reply	other threads:[~2014-06-08 11:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-07 16:52 [Qemu-trivial] [PATCH] hw/net/eepro100: Implement read-only bits in MDI registers Peter Maydell
2014-06-07 16:52 ` [Qemu-devel] " Peter Maydell
2014-06-08 11:31 ` Michael Tokarev [this message]
2014-06-08 11:31   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-06-08 12:27   ` Peter Maydell
2014-06-08 12:27     ` [Qemu-devel] " Peter Maydell
2014-06-08 12:44     ` Michael Tokarev
2014-06-08 12:44       ` [Qemu-devel] " Michael Tokarev
2014-06-09 14:46     ` Peter Maydell
2014-06-09 14:46       ` [Qemu-devel] " Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=539449AE.4090909@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.