Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Alistair Francis <alistair23@gmail.com>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"Jonathan.Cameron@huawei.com" <Jonathan.Cameron@huawei.com>,
	"lukas@wunner.de" <lukas@wunner.de>
Cc: "alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"christian.koenig@amd.com" <christian.koenig@amd.com>,
	Chaitanya Kulkarni <chaitanyak@nvidia.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"logang@deltatee.com" <logang@deltatee.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"rdunlap@infradead.org" <rdunlap@infradead.org>,
	Alistair Francis <alistair.francis@wdc.com>
Subject: Re: [PATCH v13 3/4] PCI/DOE: Expose the DOE features via sysfs
Date: Tue, 2 Jul 2024 11:57:42 +0000	[thread overview]
Message-ID: <f0083401-7bb8-451d-8274-d508c1b55992@nvidia.com> (raw)
In-Reply-To: <20240702060418.387500-3-alistair.francis@wdc.com>

> @@ -707,6 +773,45 @@ void pci_doe_init(struct pci_dev *pdev)
>   			pci_doe_destroy_mb(doe_mb);
>   		}
>   	}
> +
> +	if (doe_mb) {
> +		xa_for_each(&doe_mb->feats, i, entry)
> +			num_features++;
> +
> +		sysfs_attrs = kcalloc(num_features + 1, sizeof(*sysfs_attrs), GFP_KERNEL);
> +		if (!sysfs_attrs)
> +			return;
> +
> +		attrs = kcalloc(num_features, sizeof(*attrs), GFP_KERNEL);
> +		if (!attrs) {
> +			kfree(sysfs_attrs);
> +			return;
> +		}
> +
> +		doe_mb->device_attrs = attrs;
> +		doe_mb->sysfs_attrs = sysfs_attrs;
> +
> +		xa_for_each(&doe_mb->feats, i, entry) {
> +			sysfs_attr_init(&attrs[i].attr);
> +
> +			vid = xa_to_value(entry) >> 8;
> +			type = xa_to_value(entry) & 0xFF;
> +
> +			attrs[i].attr.name = kasprintf(GFP_KERNEL, "%04lx:%02lx", vid, type);
> +			if (!attrs[i].attr.name) {
> +				pci_doe_sysfs_feature_remove(pdev, doe_mb);
> +				return;
> +			}
> +			attrs[i].attr.mode = 0444;
> +			attrs[i].show = pci_doe_sysfs_feature_show;
> +
> +			sysfs_attrs[i] = &attrs[i].attr;
> +		}
> +
> +		sysfs_attrs[num_features] = NULL;

shouldn't sysfs_attrs[num_features] be already NULL since it's allocated
using kcalloc() ?

> +
> +		pci_doe_sysfs_group.attrs = sysfs_attrs;
> +	}

-ck



  reply	other threads:[~2024-07-02 11:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02  6:04 [PATCH v13 1/4] PCI/DOE: Rename DOE protocol to feature Alistair Francis
2024-07-02  6:04 ` [PATCH v13 2/4] PCI/DOE: Rename Discovery Response Data Object Contents to type Alistair Francis
2024-07-02  6:04 ` [PATCH v13 3/4] PCI/DOE: Expose the DOE features via sysfs Alistair Francis
2024-07-02 11:57   ` Chaitanya Kulkarni [this message]
2024-07-02 13:58   ` Jonathan Cameron
2024-07-05  1:24     ` Alistair Francis
2024-07-05 10:29       ` Jonathan Cameron
2024-07-08  0:55         ` Krzysztof Wilczyński
2024-07-09  0:50           ` Alistair Francis
2024-07-02  6:04 ` [PATCH v13 4/4] PCI/DOE: Allow enabling DOE without CXL Alistair Francis

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=f0083401-7bb8-451d-8274-d508c1b55992@nvidia.com \
    --to=chaitanyak@nvidia.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=alex.williamson@redhat.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=christian.koenig@amd.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=lukas@wunner.de \
    --cc=rdunlap@infradead.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