Re: [RFC PATCH 04/13] switchtec: add link event notifier block

From: Greg Kroah-Hartman
Date: Sat Jun 17 2017 - 01:14:53 EST


On Thu, Jun 15, 2017 at 02:37:20PM -0600, Logan Gunthorpe wrote:
> In order for the switchtec NTB code to handle link change events we
> create a notifier block in the switchtec code which gets called
> whenever an appropriate event interrupt occurs.
>
> In order to preserve userspace's ability to follow these events,
> we compare the event count with a stored copy from last time we
> checked.
>
> Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
> Reviewed-by: Stephen Bates <sbates@xxxxxxxxxxxx>
> Reviewed-by: Kurt Schwemmer <kurt.schwemmer@xxxxxxxxxxxxx>
> ---
> drivers/pci/switch/switchtec.c | 53 ++++++++++++++++++++++++++++++++++++++++++
> include/linux/switchtec.h | 5 ++++
> 2 files changed, 58 insertions(+)
>
> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> index e9bf17b1934e..63e305b24fb9 100644
> --- a/drivers/pci/switch/switchtec.c
> +++ b/drivers/pci/switch/switchtec.c
> @@ -972,6 +972,50 @@ static const struct file_operations switchtec_fops = {
> .compat_ioctl = switchtec_dev_ioctl,
> };
>
> +static void link_event_work(struct work_struct *work)
> +{
> + struct switchtec_dev *stdev;
> +
> + stdev = container_of(work, struct switchtec_dev, link_event_work);
> +
> + dev_dbg(&stdev->dev, "%s\n", __func__);

You do know about ftrace, right? It's good to drop debugging code like
this for "final" versions.

> +
> + blocking_notifier_call_chain(&stdev->link_notifier, 0, stdev);
> +}

Do you really need a notifier call chain? How many different things are
going to "hook up" to this? I ask as they tend to get really messy over
time while direct callbacks are easier to handle and manage.

thanks,

greg k-h