netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Igor Russkikh <Igor.Russkikh@aquantia.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"richardcochran@gmail.com" <richardcochran@gmail.com>,
	Egor Pomozov <Egor.Pomozov@aquantia.com>,
	Dmitry Bezrukov <Dmitry.Bezrukov@aquantia.com>,
	Simon Edelhaus <sedelhaus@marvell.com>,
	Sergey Samoilenko <Sergey.Samoilenko@aquantia.com>
Subject: Re: [PATCH v2 net-next 04/12] net: aquantia: add PTP rings infrastructure
Date: Tue, 15 Oct 2019 09:02:38 +0000	[thread overview]
Message-ID: <14148d19-5869-f510-2a08-e3d69ad25575@aquantia.com> (raw)
In-Reply-To: <20191014161451.GM21165@lunn.ch>

Hi Andrew,

>>  
>> +	aq_ptp_ring_deinit(self);
>>  	aq_ptp_unregister(self);
>> +	aq_ptp_ring_free(self);
>>  	aq_ptp_free(self);
> 
> Is this order safe? Seems like you should first unregister, and then
> deinit?

Will double check, probably you are right.


>> +	err = aq_ring_init(&aq_ptp->hwts_rx);
>> +	if (err < 0)
>> +		goto err_exit;
>> +	err = aq_nic->aq_hw_ops->hw_ring_rx_init(aq_nic->aq_hw,
>> +						 &aq_ptp->hwts_rx,
>> +						 &aq_ptp->ptp_ring_param);
>> +
>> +err_exit:
>> +	return err;
> 
> Maybe there should be some undoing going on here. If you filled the rx
> ring, do you need to empty it on error?

Right, ptp_rx should be cleaned here.


>> +	err = aq_nic->aq_hw_ops->hw_ring_rx_start(aq_nic->aq_hw,
>> +						  &aq_ptp->hwts_rx);
>> +	if (err < 0)
>> +		goto err_exit;
>> +
>> +err_exit:
> 
> Do you need to stop the rings which started, before the error
> happened?

The failures there are only theoretical (they only do check if the device
is still on PCI bus).

err result will propagate and cause overall NIC object to be failed on open,
eventually aq_nic_deinit will be called and HW will endup in disabled state.

Thus, believe we only have to care not to leak memory, like in above ptp_rx case.


>> +	memset(self, 0, sizeof(*self));
>> +
>> +	self->aq_nic = aq_nic;
>> +	self->idx = idx;
>> +	self->size = size;
>> +	self->dx_size = dx_size;
> 
> More self. Why not ring? I suppose because the rest of this file is
> using the unhelpful self?

Right. I think I'll make a separate patchset to fix this naming,
to not to mixup things.

>> +err_exit:
>> +	if (err < 0) {
>> +		aq_ring_free(self);
>> +		return NULL;
> 
> return ERR_PTR(err)?
> 
>> +	}
>> +
>> +	return self;
> 
> And this code structure seem odd. Why not.

The only cause of error on these *_alloc() functions is ENOMEM.
So think I'll just simplify this, remove all `err` fields and leave
NULL as a fail indicator.

Regards,
  Igor

  reply	other threads:[~2019-10-15  9:02 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 10:56 [PATCH v2 net-next 00/12] net: aquantia: PTP support for AQC devices Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 01/12] net: aquantia: PTP skeleton declarations and callbacks Igor Russkikh
2019-10-12 18:49   ` Richard Cochran
2019-10-12 18:56   ` Richard Cochran
2019-10-08 10:56 ` [PATCH v2 net-next 02/12] net: aquantia: unify styling of bit enums Igor Russkikh
2019-10-14 15:50   ` Andrew Lunn
2019-10-08 10:56 ` [PATCH v2 net-next 03/12] net: aquantia: add basic ptp_clock callbacks Igor Russkikh
2019-10-12 19:02   ` Richard Cochran
2019-10-14 11:43     ` Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 04/12] net: aquantia: add PTP rings infrastructure Igor Russkikh
2019-10-14 16:14   ` Andrew Lunn
2019-10-15  9:02     ` Igor Russkikh [this message]
2019-10-08 10:56 ` [PATCH v2 net-next 05/12] net: aquantia: styling fixes on ptp related functions Igor Russkikh
2019-10-14 16:16   ` Andrew Lunn
2019-10-08 10:56 ` [PATCH v2 net-next 06/12] net: aquantia: implement data PTP datapath Igor Russkikh
2019-10-14 16:36   ` Andrew Lunn
2019-10-15  9:09     ` Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 07/12] net: aquantia: rx filters for ptp Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 08/12] net: aquantia: add support for ptp ioctls Igor Russkikh
2019-10-14 16:23   ` Andrew Lunn
2019-10-15  9:06     ` Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 09/12] net: aquantia: implement get_ts_info ethtool Igor Russkikh
2019-10-12 19:07   ` Richard Cochran
2019-10-14 11:45     ` Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 10/12] net: aquantia: add support for Phy access Igor Russkikh
2019-10-15 12:19   ` Andrew Lunn
2019-10-16 13:12     ` Igor Russkikh
2019-10-16 19:38       ` Andrew Lunn
2019-10-08 10:56 ` [PATCH v2 net-next 11/12] net: aquantia: add support for PIN funcs Igor Russkikh
2019-10-12 19:25   ` Richard Cochran
2019-10-15 12:35   ` Andrew Lunn
2019-10-08 10:57 ` [PATCH v2 net-next 12/12] net: aquantia: adding atlantic ptp maintainer Igor Russkikh

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=14148d19-5869-f510-2a08-e3d69ad25575@aquantia.com \
    --to=igor.russkikh@aquantia.com \
    --cc=Dmitry.Bezrukov@aquantia.com \
    --cc=Egor.Pomozov@aquantia.com \
    --cc=Sergey.Samoilenko@aquantia.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=sedelhaus@marvell.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).