mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chalios, Babis" <bchalios@amazon.es>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>, <tytso@mit.edu>,
	<Jason@zx2c4.com>, <dwmw@amazon.co.uk>, <graf@amazon.de>,
	<xmarcalx@amazon.co.uk>, "Michael S. Tsirkin" <mst@redhat.com>,
	<ani@anisinha.ca>, <imammedo@redhat.com>, <bchalios@amazon.es>
Subject: Re: [PATCH 2/2] virt: vmgenid: add support for generation counter
Date: Wed, 3 Aug 2022 19:53:55 +0200	[thread overview]
Message-ID: <88126336-191f-8e19-a32a-6ee653d28db0@amazon.es> (raw)
In-Reply-To: <YuqUjUBxq6X738t/@kroah.com>



On 3/8/22 17:30, Greg KH wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
>
>
>
> On Wed, Aug 03, 2022 at 05:21:27PM +0200, bchalios@amazon.es wrote:
>> +static const struct file_operations fops = {
>> +     .owner = THIS_MODULE,
>> +     .open = vmgenid_open,
>> +     .read = vmgenid_read,
>> +     .mmap = vmgenid_mmap,
>> +     .llseek = noop_llseek,
> Where is this new user/kernel api being documented?
>
> See, put it in the code please, no one knows to look in a random file in
> Documentation/
Agreed! Will move it in the code.
>
>
>> +};
>> +
>> +static struct miscdevice vmgenid_misc = {
>> +     .minor = MISC_DYNAMIC_MINOR,
>> +     .name = "vmgenid",
>> +     .fops = &fops,
>>   };
>>
>>   static int parse_vmgenid_address(struct acpi_device *device, acpi_string object_name,
>> @@ -57,7 +124,7 @@ static int vmgenid_add(struct acpi_device *device)
>>        phys_addr_t phys_addr;
>>        int ret;
>>
>> -     state = devm_kmalloc(&device->dev, sizeof(*state), GFP_KERNEL);
>> +     state = devm_kzalloc(&device->dev, sizeof(*state), GFP_KERNEL);
>>        if (!state)
>>                return -ENOMEM;
>>
>> @@ -74,6 +141,27 @@ static int vmgenid_add(struct acpi_device *device)
>>
>>        device->driver_data = state;
>>
>> +     /* Backwards compatibility. If CTRA is not there we just don't expose
>> +      * the char device
>> +      */
>> +     ret = parse_vmgenid_address(device, "CTRA", &state->gen_cntr_addr);
>> +     if (ret)
>> +             return 0;
>> +
>> +     state->next_counter = devm_memremap(&device->dev, state->gen_cntr_addr,
>> +                     sizeof(u32), MEMREMAP_WB);
>> +     if (IS_ERR(state->next_counter))
>> +             return 0;
>> +
>> +     memcpy(&state->misc, &vmgenid_misc, sizeof(state->misc));
>> +     ret = misc_register(&state->misc);
>> +     if (ret) {
>> +             devm_memunmap(&device->dev, state->next_counter);
>> +             return 0;
> Why are you not returning an error?  Why is this ok?
>
> And why call devm_memunmap() directly?  That kind of defeats the purpose
> of using devm_memremap(), right?
The intention here was to not fail the whole ACPI device if registering 
the misc device fails. My rationale
was that the ACPI device is used for other things as well (re-seeding RNG).

>
> thanks,
>
> greg k-h

Cheers,
Babis
Amazon Spain Services sociedad limitada unipersonal, Calle Ramirez de Prado 5, 28045 Madrid. Registro Mercantil de Madrid . Tomo 22458 . Folio 102 . Hoja M-401234 . CIF B84570936

  reply	other threads:[~2022-08-03 17:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 15:21 [PATCH 0/2] virt: vmgenid: add " bchalios
2022-08-03 15:21 ` [PATCH 1/2] virt: vmgenid: add helper function to parse ADDR bchalios
2022-08-03 15:21 ` [PATCH 2/2] virt: vmgenid: add support for generation counter bchalios
2022-08-03 15:28   ` Greg KH
2022-08-03 15:30   ` Greg KH
2022-08-03 17:53     ` Chalios, Babis [this message]
2022-08-03 15:31   ` Greg KH
2022-08-03 17:58     ` Chalios, Babis
2022-08-14  3:26   ` kernel test robot
2022-08-03 15:50 ` [PATCH 0/2] virt: vmgenid: add " Chalios, Babis
2022-08-03 15:57 ` Chalios, Babis
2022-08-04 13:33 ` Chalios, Babis
2022-08-04 14:59 ` Jason A. Donenfeld
2022-08-04 15:46   ` bchalios
2022-08-10  9:19   ` bchalios

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=88126336-191f-8e19-a32a-6ee653d28db0@amazon.es \
    --to=bchalios@amazon.es \
    --cc=Jason@zx2c4.com \
    --cc=ani@anisinha.ca \
    --cc=dwmw@amazon.co.uk \
    --cc=graf@amazon.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=imammedo@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=tytso@mit.edu \
    --cc=xmarcalx@amazon.co.uk \
    /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

all inboxes | Powered by JetHome®