Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Guixin Liu <kanie@linux.alibaba.com>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v9 1/2] PCI: Introduce named defines for pci rom
Date: Thu, 11 Dec 2025 16:05:43 +0200	[thread overview]
Message-ID: <aTrPtxDdg__tabSE@smile.fi.intel.com> (raw)
In-Reply-To: <20251211125906.57027-2-kanie@linux.alibaba.com>

On Thu, Dec 11, 2025 at 08:59:05PM +0800, Guixin Liu wrote:
> Convert the magic numbers associated with PCI ROM into named
> definitions. Some of these definitions will be used in the second
> fix patch.

Please, give at least 24h between the versions in order other being able (quick
enough) to review the changes.

...

> +#include <linux/bits.h>
>  #include <linux/kernel.h>
>  #include <linux/export.h>
>  #include <linux/pci.h>
>  #include <linux/slab.h>

> +#include <linux/sizes.h>

'i' goes before 'l', yeah it's hard to see in small monospace fonts.

...


> +#define PCI_ROM_HEADER_SIZE			0x1A
> +#define PCI_ROM_POINTER_TO_DATA_STRUCT		0x18
> +#define PCI_ROM_LAST_IMAGE_INDICATOR		0x15
> +#define PCI_ROM_LAST_IMAGE_INDICATOR_BIT	BIT(7)

> +#define PCI_ROM_IMAGE_LEN			0x10
> +#define PCI_ROM_IMAGE_LEN_UNIT_BYTES		SZ_512

I'm a bit confused by the naming here.

There are two definitions that end with _LEN, but the meaning of them is
the offset where the respective "len" can be read from.

Now, there is a _LEN_UNIT_BYTES, which seems related to _LEN, but in unclear
way.

With all the AA55 signature it pretty much sounds to me like a sector division
(legacy from the era of floppies).

That said, I would name the size of the "unit" as

#define PCI_ROM_IMAGE_SECTOR_SIZE		SZ_512

(without or with _BYTES on your choice, usually we don't use unit for bytes
 when there is no room for misinterpretation).

> +#define PCI_ROM_IMAGE_SIGNATURE			0xAA55

Despite the below comment explains this, I would explicitly state it here

/* Data structure signature is "PCIR" in ASCII representation */

> +#define PCI_ROM_DATA_STRUCT_SIGNATURE		0x52494350
> +#define PCI_ROM_DATA_STRUCT_LEN			0x0A

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-12-11 14:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-11 12:59 [PATCH v9 0/2] PCI: Fix crash when access broken rom Guixin Liu
2025-12-11 12:59 ` [PATCH v9 1/2] PCI: Introduce named defines for pci rom Guixin Liu
2025-12-11 14:05   ` Andy Shevchenko [this message]
2025-12-12  1:57     ` Guixin Liu
2025-12-11 12:59 ` [PATCH v9 2/2] PCI: Check rom header and data structure addr before accessing Guixin Liu
2025-12-11 14:07   ` Andy Shevchenko
2025-12-12  1:58     ` Guixin Liu

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=aTrPtxDdg__tabSE@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=bhelgaas@google.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=kanie@linux.alibaba.com \
    --cc=linux-pci@vger.kernel.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