netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Cc: "Machulsky, Zorik" <zorik@amazon.com>,
	"Jubran, Samih" <sameehj@amazon.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"Kiyanovski, Arthur" <akiyano@amazon.com>,
	"Woodhouse, David" <dwmw@amazon.co.uk>,
	"Matushevsky, Alexander" <matua@amazon.com>,
	"Bshara, Saeed" <saeedb@amazon.com>,
	"Wilson, Matt" <msw@amazon.com>,
	"Liguori, Anthony" <aliguori@amazon.com>,
	"Bshara, Nafea" <nafea@amazon.com>,
	"Tzalik, Guy" <gtzalik@amazon.com>,
	"Belgazal, Netanel" <netanel@amazon.com>,
	"Saidi, Ali" <alisaidi@amazon.com>,
	"Herrenschmidt, Benjamin" <benh@amazon.com>
Subject: Re: [PATCH V1 net-next 02/11] net: ena: ethtool: add extra properties retrieval via get_priv_flags
Date: Sat, 1 Jun 2019 00:38:29 +0200	[thread overview]
Message-ID: <20190531223829.GH15954@unicorn.suse.cz> (raw)
In-Reply-To: <30FE74C2-429B-4837-84D5-E973F33AF35F@amazon.com>

On Fri, May 31, 2019 at 09:57:51PM +0000, Machulsky, Zorik wrote:
>     >  
>     > +int ena_com_extra_properties_strings_init(struct ena_com_dev *ena_dev)
>     > +{
>     > +	struct ena_admin_get_feat_resp resp;
>     > +	struct ena_extra_properties_strings *extra_properties_strings =
>     > +			&ena_dev->extra_properties_strings;
>     > +	u32 rc;
>     > +
>     > +	extra_properties_strings->size = ENA_ADMIN_EXTRA_PROPERTIES_COUNT *
>     > +		ENA_ADMIN_EXTRA_PROPERTIES_STRING_LEN;
>     > +
>     > +	extra_properties_strings->virt_addr =
>     > +		dma_alloc_coherent(ena_dev->dmadev,
>     > +				   extra_properties_strings->size,
>     > +				   &extra_properties_strings->dma_addr,
>     > +				   GFP_KERNEL);
>     
>     Do you need to fetch the private flag names on each ETHTOOL_GSTRING
>     request? I suppose they could change e.g. on a firmware update but then
>     even the count could change which you do not seem to handle. Is there
>     a reason not to fetch the names once on init rather then accessing the
>     device memory each time?
>     
>     My point is that ethtool_ops::get_strings() does not return a value
>     which indicates that it's supposed to be a trivial operation which
>     cannot fail, usually a simple copy within kernel memory.
> 
> ena_com_extra_properties_strings_init() is called in probe() only, and not for every ETHTOOL_GSTRING
> request. For the latter we use ena_get_strings(). And just to make sure we are on the same page, extra_properties_strings->virt_addr 
> points to the host memory and not to the device memory. I believe this should answer your concern.

That's what I misunderstood. Sorry for the noise then.

>     > +static void get_private_flags_strings(struct ena_adapter *adapter, u8 *data)
>     > +{
>     > +	struct ena_com_dev *ena_dev = adapter->ena_dev;
>     > +	u8 *strings = ena_dev->extra_properties_strings.virt_addr;
>     > +	int i;
>     > +
>     > +	if (unlikely(!strings)) {
>     > +		adapter->ena_extra_properties_count = 0;
>     > +		netif_err(adapter, drv, adapter->netdev,
>     > +			  "Failed to allocate extra properties strings\n");
>     > +		return;
>     > +	}
>     
>     This is a bit confusing, IMHO. I'm aware we shouldn't really get here as
>     with strings null, count would be zero and ethtool_get_strings()
>     wouldn't call the ->get_strings() callback. But if we ever do, it makes
>     little sense to complain about failed allocation (which happened once on
>     init) each time userspace makes ETHTOOL_GSTRINGS request for private
>     flags.
> 
> I believe we still want to check validity of the strings pointer to keep the driver resilient, however I agree that 
> the logged message is confusing. Let us rework this commit  

Yes, I didn't question the check, only the error message.

Michal

  reply	other threads:[~2019-05-31 22:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29  9:49 [PATCH V1 net-next 00/11] Extending the ena driver to support new features and enhance performance sameehj
2019-05-29  9:49 ` [PATCH V1 net-next 01/11] net: ena: add handling of llq max tx burst size sameehj
2019-05-30 19:40   ` David Miller
2019-05-29  9:49 ` [PATCH V1 net-next 02/11] net: ena: ethtool: add extra properties retrieval via get_priv_flags sameehj
2019-05-29 22:09   ` Jakub Kicinski
2019-05-30 12:21     ` Kiyanovski, Arthur
2019-05-30 19:41   ` David Miller
2019-06-03 14:29     ` Jubran, Samih
2019-05-31  8:19   ` Michal Kubecek
2019-05-31 21:57     ` Machulsky, Zorik
2019-05-31 22:38       ` Michal Kubecek [this message]
2019-05-29  9:49 ` [PATCH V1 net-next 03/11] net: ena: replace free_tx/rx_ids union with single free_ids field in ena_ring sameehj
2019-05-29  9:49 ` [PATCH V1 net-next 04/11] net: ena: arrange ena_probe() function variables in reverse christmas tree sameehj
2019-05-29  9:49 ` [PATCH V1 net-next 05/11] net: ena: add newline at the end of pr_err prints sameehj
2019-05-29  9:49 ` [PATCH V1 net-next 06/11] net: ena: documentation: update ena.txt sameehj
2019-05-29  9:50 ` [PATCH V1 net-next 07/11] net: ena: allow automatic fallback to polling mode sameehj
2019-05-29  9:50 ` [PATCH V1 net-next 08/11] net: ena: add support for changing max_header_size in LLQ mode sameehj
2019-05-29  9:50 ` [PATCH V1 net-next 09/11] net: ena: optimise calculations for CQ doorbell sameehj
2019-05-29  9:50 ` [PATCH V1 net-next 10/11] net: ena: add good checksum counter sameehj
2019-05-29  9:50 ` [PATCH V1 net-next 11/11] net: ena: use dev_info_once instead of static variable sameehj

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=20190531223829.GH15954@unicorn.suse.cz \
    --to=mkubecek@suse.cz \
    --cc=akiyano@amazon.com \
    --cc=aliguori@amazon.com \
    --cc=alisaidi@amazon.com \
    --cc=benh@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dwmw@amazon.co.uk \
    --cc=gtzalik@amazon.com \
    --cc=matua@amazon.com \
    --cc=msw@amazon.com \
    --cc=nafea@amazon.com \
    --cc=netanel@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedb@amazon.com \
    --cc=sameehj@amazon.com \
    --cc=zorik@amazon.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).