Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Alvaro Karsz <alvaro.karsz@solid-run.com>
Cc: virtualization@lists.linux-foundation.org,
	linux-pci@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Jean Delvare <jdelvare@suse.com>
Subject: Re: [PATCH 3/3 v4] virtio: vdpa: new SolidNET DPU driver.
Date: Mon, 12 Dec 2022 09:01:03 -0800	[thread overview]
Message-ID: <3f83e874-3d7c-cc97-2207-a47dbcfe960f@roeck-us.net> (raw)
In-Reply-To: <CAJs=3_AdgWS23-t6dELgSfz7DS4U0eXuXP_UZ3Fn21VCEwA-4w@mail.gmail.com>

On 12/12/22 08:29, Alvaro Karsz wrote:
> Hi Guenter,
> Thanks for your comments.
> 
>> This is wrong. It should be possible to build the driver without it, and
>> without forcing everyone to enable hwmon just to get support for this device -
>> even more so since hwmon support is explicitly marked as optional below.
>> Why force people to compile it if it is not mandatory ?
>>
>>
>> Yes, I know, "select HWMON" is done elsewhere as well, but it is just as wrong
>> there. No one should be forced to enable HWMON support just to get, say, support
>> for the IDT PCIe-switch Non-Transparent Bridge.
> 
> 
> You have a good point.
> I will remove it from the Kconfig file, and I will add:
> #if IS_REACHABLE(CONFIG_HWMON)
> in relevant places
> 
> Something like:
> 
> solidrun/Makefile:
> obj-$(CONFIG_SNET_VDPA) += snet_vdpa.o
> snet_vdpa-$(CONFIG_SNET_VDPA) += snet_main.o
> #if IS_REACHABLE(CONFIG_HWMON)

I don't think that works in Makefiles. It would have to be ifdef.

> snet_vdpa-$(CONFIG_SNET_VDPA) += snet_hwmon.o
> #endif
> 

Even better would be a separate CONFIG_SNET_VDPA_HWMON Kconfig option.

> solidrun/snet_main.c, snet_vdpa_probe_pf function:
> 
> if (PSNET_FLAG_ON(psnet, SNET_CFG_FLAG_HWMON)) {
> #if IS_REACHABLE(CONFIG_HWMON)
>          psnet_create_hwmon(pdev);
> #else
>          SNET_ERR(pdev, "Can't start HWMON, CONFIG_HWMON is not reachable\n");
> #endif

Per your own statement, that is not an error, and thus should not be logged
as one.

> }
> 
> solidrun/snet_vdpa.h, snet_vdpa_probe_pf function:
> #if IS_REACHABLE(CONFIG_HWMON)
> void psnet_create_hwmon(struct pci_dev *pdev);
> #endif
> 
> What do you think?
> 

It would be much better to add a shim function in the include file.

There should be a dependency

	depends on HWMON || HWMON=n

in Kconfig, and the shim function would then be

#if IS_REACHABLE(CONFIG_HWMON)
void psnet_create_hwmon(struct pci_dev *pdev);
#else
void psnet_create_hwmon(struct pci_dev *pdev) {}
#endif

>> I do not see why the second include would be needed.
> 
> You're right, I'll remove it.
> 
>>
>> Tpecast seems unnecessary.
> 
> I'll remove it.
> 
>> Kind of obvious.
> 
> Ok, I'll remove the comment.
> 
>> Badly misleading indent. No idea why checkpatch doesn't report it.
>>
>>
>> That makes me wonder: Did you not run checkpatch --strict, or did you choose
>> to ignore what it reports ?
> 
> I did run checkpatch (without --strict).
> I tried now with --strict. and I'm not getting any indent
> errors/warnings, this is strange..
> I will fix it.
> 

I referred to the other problems it reports, such as using macro arguments
without ().

>> FWIW, a _hwmon ending in a hwmon driver device name is redundant.
>> What else would it be ? Why not just use pci_name() ?
> 
> I'll change it to "snet_%s", pci_name(pdev)
> 
>> devm_hwmon_device_register_with_info() returns an ERR_PTR on error,
>> not NULL.
> 
> Ok, I'll fix it.
> 
>> I hope you know what you are doing here. This may result in people wondering
>> why hwmon support doesn't work if they expect it to work. No one looks
>> into the kernel log. Besides, ignoring the error doesn't really help
>> much because that error return means that something serious is wrong.
> 
> You have a point, but the hwmon is not the "main" functionality of
> this device, so I don't want to fail the entire device because of a
> "side" functionality.
> Now that the SNET vdpa driver doesn't select CONFIG_HWMON, we may have
> a situation when the SNET_CFG_FLAG_HWMON flag is set, but the kernel
> is compiled without CONFIG_HWMON.
> I don't think that I should fail probe in this case.
> 
>> Wow, a 5-second hot loop. Not my responsibility to accept or reject this
>> part of the code, but personally I think this is completely unaccceptable.
> 
> The SNET DPU may require some time to become ready.
> If the driver is compiled as a module, this is not a problem, but if
> the driver is builtin in the kernel, we may need to wait a little for
> the DPU.
> But you're right, 5 secs is indeed a big number, I'll change it to 2 secs.
> 

That isn't the point. A 2-second hot loop is just as bad.
There should be a usleep_range() or similar between loop iterations.

Guenter

>> Memory allocation failures are not commonly logged since the low level code
>> already does that.
> 
> Right, I'll remove the error log.
> 
> Alvaro


  parent reply	other threads:[~2022-12-12 17:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 14:24 [PATCH 0/3] virtio: vdpa: new SolidNET DPU driver Alvaro Karsz
2022-12-12 14:24 ` [PATCH 1/3] Add SolidRun vendor id Alvaro Karsz
2022-12-12 14:24 ` [PATCH 2/3] New PCI quirk for SolidRun SNET DPU Alvaro Karsz
2022-12-12 14:24 ` [PATCH 3/3 v4] virtio: vdpa: new SolidNET DPU driver Alvaro Karsz
2022-12-12 15:01   ` Guenter Roeck
2022-12-12 16:29     ` Alvaro Karsz
2022-12-12 16:38       ` Alvaro Karsz
2022-12-12 17:01       ` Guenter Roeck [this message]
2022-12-12 17:46         ` Alvaro Karsz
2022-12-12 17:56           ` Alvaro Karsz
2022-12-12 19:05             ` Guenter Roeck
2022-12-12 20:17               ` Alvaro Karsz

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=3f83e874-3d7c-cc97-2207-a47dbcfe960f@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=alvaro.karsz@solid-run.com \
    --cc=jasowang@redhat.com \
    --cc=jdelvare@suse.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox