From: Sean Anderson <seanga2@gmail.com>
To: Simon Horman <simon.horman@corigine.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4 10/10] net: sunhme: Consolidate common probe tasks
Date: Sat, 25 Mar 2023 12:06:41 -0400 [thread overview]
Message-ID: <a4ecd20b-5d13-893b-2329-f6dd0c565ad5@gmail.com> (raw)
In-Reply-To: <ZB66hgG2+nn6CxS7@corigine.com>
On 3/25/23 05:10, Simon Horman wrote:
> On Fri, Mar 24, 2023 at 01:51:36PM -0400, Sean Anderson wrote:
>> Most of the second half of the PCI/SBUS probe functions are the same.
>> Consolidate them into a common function.
>>
>> Signed-off-by: Sean Anderson <seanga2@gmail.com>
>
> Hi Sean,
>
> overall this looks good.
> But I (still?) have some concerns about handling hm_revision.
>
> ...
>
>> diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
>> index bd1925f575c4..ec85aef35bf9 100644
>> --- a/drivers/net/ethernet/sun/sunhme.c
>> +++ b/drivers/net/ethernet/sun/sunhme.c
>> @@ -2430,6 +2430,58 @@ static void happy_meal_addr_init(struct happy_meal *hp,
>> }
>> }
>>
>> +static int happy_meal_common_probe(struct happy_meal *hp,
>> + struct device_node *dp)
>> +{
>> + struct net_device *dev = hp->dev;
>> + int err;
>> +
>> +#ifdef CONFIG_SPARC
>> + hp->hm_revision = of_getintprop_default(dp, "hm-rev", hp->hm_revision);
>
> Previously the logic, for SPARC for PCI went something like this:
>
> /* in happy_meal_pci_probe() */
> hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff);
> if (hp->hm_revision == 0xff)
> hp->hm_revision = 0xc0 | (pdev->revision & 0x0f);
>
> Now it goes something like this:
>
> /* in happy_meal_pci_probe() */
> hp->hm_revision = 0xc0 | (pdev->revision & 0x0f);
> /* in happy_meal_common_probe() */
> hp->hm_revision = of_getintprop_default(dp, "hm-rev", hp->hm_revision);
>
> Is this intentional?
>
> Likewise, for sbus (which implies SPARC) the logic was something like:
>
> /* in happy_meal_sbus_probe_one() */
> hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff);
> if (hp->hm_revision == 0xff)
> hp->hm_revision = 0xa0;
>
> And now goes something like this:
>
> /* in happy_meal_pci_probe() */
> hp->hm_revision = 0xa0;
> /* in happy_meal_common_probe() */
> hp->hm_revision = of_getintprop_default(dp, "hm-rev", hp->hm_revision);
Yes, this is intentional. Logically, they are the same; we just set up the default
before calling of_getintprop_default instead of after.
>> +#endif
>> +
>> + /* Now enable the feature flags we can. */
>> + if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21)
>> + hp->happy_flags |= HFLAG_20_21;
>> + else if (hp->hm_revision != 0xa0)
>> + hp->happy_flags |= HFLAG_NOT_A0;
>> +
>> + hp->happy_block = dmam_alloc_coherent(hp->dma_dev, PAGE_SIZE,
>> + &hp->hblock_dvma, GFP_KERNEL);
>> + if (!hp->happy_block)
>> + return -ENOMEM;
>> +
>> + /* Force check of the link first time we are brought up. */
>> + hp->linkcheck = 0;
>> +
>> + /* Force timer state to 'asleep' with count of zero. */
>> + hp->timer_state = asleep;
>> + hp->timer_ticks = 0;
>> +
>> + timer_setup(&hp->happy_timer, happy_meal_timer, 0);
>> +
>> + dev->netdev_ops = &hme_netdev_ops;
>> + dev->watchdog_timeo = 5 * HZ;
>> + dev->ethtool_ops = &hme_ethtool_ops;
>> +
>> + /* Happy Meal can do it all... */
>> + dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM;
>> + dev->features |= dev->hw_features | NETIF_F_RXCSUM;
>> +
>> +
>
> nit: one blank line is enough.
Ah, oops.
--Sean
>> + /* Grrr, Happy Meal comes up by default not advertising
>> + * full duplex 100baseT capabilities, fix this.
>> + */
>> + spin_lock_irq(&hp->happy_lock);
>> + happy_meal_set_initial_advertisement(hp);
>> + spin_unlock_irq(&hp->happy_lock);
>> +
>> + err = devm_register_netdev(hp->dma_dev, dev);
>> + if (err)
>> + dev_err(hp->dma_dev, "Cannot register net device, aborting.\n");
>> + return err;
>> +}
>> +
>
> ...
next prev parent reply other threads:[~2023-03-25 16:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 17:51 [PATCH net-next v4 00/10] net: sunhme: Probe/IRQ cleanups Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 01/10] net: sunhme: Fix uninitialized return code Sean Anderson
2023-03-25 8:17 ` Simon Horman
2023-03-25 8:26 ` Simon Horman
2023-03-24 17:51 ` [PATCH net-next v4 02/10] net: sunhme: Just restart autonegotiation if we can't bring the link up Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 03/10] net: sunhme: Remove residual polling code Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 04/10] net: sunhme: Unify IRQ requesting Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 05/10] net: sunhme: Alphabetize includes Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 06/10] net: sunhme: Switch SBUS to devres Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 07/10] net: sunhme: Consolidate mac address initialization Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 08/10] net: sunhme: Clean up mac address init Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 09/10] net: sunhme: Inline error returns Sean Anderson
2023-03-25 8:24 ` Simon Horman
2023-03-25 8:29 ` Simon Horman
2023-03-24 17:51 ` [PATCH net-next v4 10/10] net: sunhme: Consolidate common probe tasks Sean Anderson
2023-03-25 9:10 ` Simon Horman
2023-03-25 16:06 ` Sean Anderson [this message]
2023-03-26 7:57 ` Simon Horman
2023-03-27 7:50 ` [PATCH net-next v4 00/10] net: sunhme: Probe/IRQ cleanups patchwork-bot+netdevbpf
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=a4ecd20b-5d13-893b-2329-f6dd0c565ad5@gmail.com \
--to=seanga2@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=simon.horman@corigine.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).