From: Niklas Cassel <cassel@kernel.org>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Ard Biesheuvel <ardb@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Damien Le Moal <dlemoal@kernel.org>,
David Hildenbrand <david@redhat.com>,
Greg Marsden <greg.marsden@oracle.com>,
Ivan Ivanov <ivan.ivanov@suse.com>,
Kalesh Singh <kaleshsingh@google.com>,
Marc Zyngier <maz@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Matthias Brugger <mbrugger@suse.com>,
Miroslav Benes <mbenes@suse.cz>, Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org, linux-ide@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [RFC PATCH v1 34/57] sata_sil24: Remove PAGE_SIZE compile-time constant assumption
Date: Mon, 21 Oct 2024 13:04:08 +0200 [thread overview]
Message-ID: <ZxY1KAvGpyIzARtX@ryzen.lan> (raw)
In-Reply-To: <2f578256-7e56-491f-a4ca-ad6caa72b7ae@arm.com>
On Mon, Oct 21, 2024 at 10:24:37AM +0100, Ryan Roberts wrote:
> On 17/10/2024 13:51, Niklas Cassel wrote:
> > On Thu, Oct 17, 2024 at 01:42:22PM +0100, Ryan Roberts wrote:
(snip)
> That said, while investigating this, I've spotted a bug in my change. paddr calculation in sil24_qc_issue() is incorrect since sizeof(*pp->cmd_block) is no longer PAGE_SIZE. Based on feedback in another patch, I'm also converting the BUG_ONs to WARN_ON_ONCEs.
Side note: Please wrap you lines to 80 characters max.
>
> Additional proposed change, which I'll plan to include in the next version:
>
> ---8<---
> diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
> index 85c6382976626..c402bf998c4ee 100644
> --- a/drivers/ata/sata_sil24.c
> +++ b/drivers/ata/sata_sil24.c
> @@ -257,6 +257,10 @@ union sil24_cmd_block {
> struct sil24_atapi_block atapi;
> };
>
> +#define SIL24_ATA_BLOCK_SIZE struct_size_t(struct sil24_ata_block, sge, SIL24_MAX_SGE)
> +#define SIL24_ATAPI_BLOCK_SIZE struct_size_t(struct sil24_atapi_block, sge, SIL24_MAX_SGE)
> +#define SIL24_CMD_BLOCK_SIZE max(SIL24_ATA_BLOCK_SIZE, SIL24_ATAPI_BLOCK_SIZE)
> +
> static const struct sil24_cerr_info {
> unsigned int err_mask, action;
> const char *desc;
> @@ -886,7 +890,7 @@ static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc)
> dma_addr_t paddr;
> void __iomem *activate;
>
> - paddr = pp->cmd_block_dma + tag * sizeof(*pp->cmd_block);
> + paddr = pp->cmd_block_dma + tag * SIL24_CMD_BLOCK_SIZE;
> activate = port + PORT_CMD_ACTIVATE + tag * 8;
>
> /*
> @@ -1192,7 +1196,7 @@ static int sil24_port_start(struct ata_port *ap)
> struct device *dev = ap->host->dev;
> struct sil24_port_priv *pp;
> union sil24_cmd_block *cb;
> - size_t cb_size = PAGE_SIZE * SIL24_MAX_CMDS;
> + size_t cb_size = SIL24_CMD_BLOCK_SIZE * SIL24_MAX_CMDS;
> dma_addr_t cb_dma;
>
> pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
> @@ -1265,8 +1269,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> u32 tmp;
>
> /* union sil24_cmd_block must be PAGE_SIZE */
This comment should probably be rephrased to be more clear then, since like
you said sizeof(union sil24_cmd_block) will no longer be PAGE_SIZE.
> - BUG_ON(struct_size_t(struct sil24_atapi_block, sge, SIL24_MAX_SGE) != PAGE_SIZE);
> - BUG_ON(struct_size_t(struct sil24_ata_block, sge, SIL24_MAX_SGE) > PAGE_SIZE);
> + WARN_ON_ONCE(SIL24_ATAPI_BLOCK_SIZE != PAGE_SIZE);
> + WARN_ON_ONCE(SIL24_ATA_BLOCK_SIZE != PAGE_SIZE - 16);
>
> ata_print_version_once(&pdev->dev, DRV_VERSION);
> ---8<---
next prev parent reply other threads:[~2024-10-21 11:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241014105514.3206191-1-ryan.roberts@arm.com>
[not found] ` <20241014105912.3207374-1-ryan.roberts@arm.com>
2024-10-14 10:58 ` [RFC PATCH v1 34/57] sata_sil24: Remove PAGE_SIZE compile-time constant assumption Ryan Roberts
2024-10-17 9:09 ` Niklas Cassel
2024-10-17 12:42 ` Ryan Roberts
2024-10-17 12:51 ` Niklas Cassel
2024-10-21 9:24 ` Ryan Roberts
2024-10-21 11:04 ` Niklas Cassel [this message]
2024-10-21 11:26 ` Ryan Roberts
2024-10-21 11:43 ` Niklas Cassel
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=ZxY1KAvGpyIzARtX@ryzen.lan \
--to=cassel@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=david@redhat.com \
--cc=dlemoal@kernel.org \
--cc=greg.marsden@oracle.com \
--cc=gustavoars@kernel.org \
--cc=ivan.ivanov@suse.com \
--cc=kaleshsingh@google.com \
--cc=kees@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=mbenes@suse.cz \
--cc=mbrugger@suse.com \
--cc=ryan.roberts@arm.com \
--cc=will@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