From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B37D4D0E6FA for ; Mon, 21 Oct 2024 11:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nGMCM+IrhIGAK/1KxJptEubxT1WfclkWW2jkCLnLo1o=; b=IRPzOb8DLj6RSk5kwuiu+xPW4M uYCbT2sQEM1hLN8SY1gr3RLtfoiJ3RV43Yi9cg8rBnX04reXsRyJNIxITnipz/TzoiHmWU+pvSNtm Oon/DRpizNNYt4stqmKTRGXd74frA7nsMRXag9OkOGCIdcyRHnvNxREUXigVfx4INxfYBO6PjiT1/ BVo09eMMFz5fUna4FAE68SRfE5/DK/GmOIFRGZoF/FIU/xt7i2FXtWgizcGeodbNKqH+1Dq1XDzKP +lOC3TlxtZkvW6mOhNkNjHZbguHjLFm4FIyXZQ67WiHI0vSWzF6T/4B+BCOH5PCQuouyPZRS6CqGd 3AIuCXxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2qqY-000000075ne-49Pj; Mon, 21 Oct 2024 11:45:14 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2qp2-000000075Q9-2JLk for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 11:43:42 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 3CCF3A42764; Mon, 21 Oct 2024 11:43:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83058C4CEC3; Mon, 21 Oct 2024 11:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729511019; bh=awMHKeW2IqFLj8Un2Mvc6m+8vNSs8NS5bptZgfjy3Vc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YnUZcBiwYN0oUEeEN8LXcEyIIfpko9fRGTmgbdH9YqBuPYZSZ6fd1nAx3SYHnTtZ6 0+kKjJEolyA7JaHYxeB1sERy/Bx0qJVDrUbBIrelx+n9qu30MtD+oRvnqdh/8FjREZ 1LkgNq/GG215kUUqZXU0mnCR8rXbaIKnXbgL8J49OpXiLNEQ8YLUuGiDMBSzbqyUzi 5xrjZJwdCHucJLpgaWYm/Wd+iqQmJaXwiYXdMlVIfubyCRZJUlS2Lp7nwvIUWGN29N BIHjAFRwmJnNv1adZRa1v6DMrh8XfZk0jxPnpaLxgAIXB/RIHi8eLd+Wnk9LCHUIkk wvtzlsVf2oaqQ== Date: Mon, 21 Oct 2024 13:43:31 +0200 From: Niklas Cassel To: Ryan Roberts Cc: Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , Damien Le Moal , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Kees Cook , "Gustavo A. R. Silva" Subject: Re: [RFC PATCH v1 34/57] sata_sil24: Remove PAGE_SIZE compile-time constant assumption Message-ID: References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> <20241014105912.3207374-34-ryan.roberts@arm.com> <7aa84080-6845-496a-a394-30d334632298@arm.com> <2f578256-7e56-491f-a4ca-ad6caa72b7ae@arm.com> <8e1e0824-1022-4f8f-9753-e134c7244d3a@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8e1e0824-1022-4f8f-9753-e134c7244d3a@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_044340_742527_836C5B8E X-CRM114-Status: GOOD ( 22.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 21, 2024 at 12:26:15PM +0100, Ryan Roberts wrote: > On 21/10/2024 12:04, Niklas Cassel wrote: > > 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. > > Yes sorry, I turned off line wrapping for that last mail because I didn't want > it to wrap the copy/pasted patch. I'll figure out how to mix and match for future. > > > > > > >> > >> 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. > > How about: > > /* > * union sil24_cmd_block must be PAGE_SIZE once taking into account the 'sge' > * flexible array members in struct sil24_atapi_block and struct sil24_ata_block > */ Sounds good to me! Kind regards, Niklas