Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934986AbdDFOJi (ORCPT ); Thu, 6 Apr 2017 10:09:38 -0400 Received: from mail-co1nam03on0065.outbound.protection.outlook.com ([104.47.40.65]:61616 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935158AbdDFOI5 (ORCPT ); Thu, 6 Apr 2017 10:08:57 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Message-ID: <1491487722.4829.11.camel@nxp.com> Subject: Re: [PATCH v3 33/37] mtd: nand: allocate aligned buffers if NAND_OWN_BUFFERS is unset From: Leonard Crestez To: Masahiro Yamada CC: , , "Boris Brezillon" , David Woodhouse , Marek Vasut , Dinh Nguyen , Artem Bityutskiy , Graham Moore , Enrico Jorns , Chuanxiao Dong , "Masami Hiramatsu" , Jassi Brar , Stephen Rothwell , Octavian Purdila Date: Thu, 6 Apr 2017 17:08:42 +0300 In-Reply-To: <1490861708-27813-3-git-send-email-yamada.masahiro@socionext.com> References: <1490861708-27813-1-git-send-email-yamada.masahiro@socionext.com> <1490861708-27813-3-git-send-email-yamada.masahiro@socionext.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-Matching-Connectors: 131359613299990768;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39400400002)(39840400002)(39850400002)(39860400002)(39410400002)(39450400003)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199003)(377454003)(189002)(24454002)(9170700003)(54906002)(106466001)(105606002)(39060400002)(38730400002)(110136004)(2906002)(4326008)(2950100002)(6246003)(47776003)(189998001)(85426001)(6916009)(53546009)(7416002)(50466002)(77096006)(305945005)(229853002)(5660300001)(23676002)(8676002)(53936002)(8656002)(104016004)(36756003)(2870700001)(103116003)(356003)(33646002)(8936002)(50226002)(50986999)(76176999)(81166006)(86362001)(5820100001)(99106002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR03MB397;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD017;1:lrkyAPPZaZx9XOWAfzIWlv7nZa23BGnkLbyDUoGSkCuloQpDgTRVMGLMwxcTUWQHIeWJdQ9ZJSLdJlCcLwYEPCtyEFLhNqxKSexB7RcSJWAB1TXPlnnxfgBzsJLhg/PNmTmGI5Qvzkn1IwVMHUPUN/vlXH+/tosgWBw4I+WI56Vgb3sOEGYrGw2P3uzmjdG0Tt5k+Ni6YFgYhIlVKvTq4RL/HWD7LcZzm56ST1NOGWjyJTIdVi8D7cZ+8NVchz8M4fwBMk3DDDmkbbRLLTynhyW2e15sqI3vWQ7CpyoMeYc8QuD6URzoqnMozS4g8CYDtxtFWpC1qWR+3yULvRzq3aUNsElwK9fOEAKqT1R3N2urNAgiJoYmTJFrlu2+50h2ms9/OswxacCRUHynh7WmfTd1WsCChR8OBKuS7Zbxr6aOKlkHtEBHup/lGGtQAu7HOKslmOptIoK0w5vgINryr2cf9DyGOIkVKemLyoXc0R8TD+llY9XEbUL2uvsuJFh113Bqehq1VYTq2MT4BiBesrtDZB1rkzbPv6N5lGXlFULBPDzTl2qxBgXnHtrbNRY88ztw5TxuUMMJ0859Q9IFZmp5+OBxMVZWDBINF0zSjnITdBBJZVpMLxs0UnNgouf34/5KOyfovTYZ5Ed8K8BH3NzeClKZ+0/N3zkUOxqej7OGizS/QPUUr6OHWsPXUk3j7V47Ew9PKayiSBbnWWHBDcObk6D4oDycD7Ldebk1Lc70jOOSKppzK1Wt/uSUnHysR5eFWRu28G6nFbgyGVEYYA== X-MS-Office365-Filtering-Correlation-Id: fb465868-dca2-47f2-20f0-08d47cf6730b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:DM2PR03MB397; X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB397;3:pMCOevKlRLd4rzKtkpH9vAdF8Wc6fFKBGcN63tAU6ihFZ+ZdnoYCXijQxUNoEFTji1qt2eCDHqstIcpBLjhi/xrSUCz1pPvI7/ROjSLg1KEhFE6TzFLWklUP+ijD7xLHNUXqCNDzQNYR0BFd75Ch94JquPrw8U753Gn1hom0NqGQXcckFKAXi5/weuGYscQAs4uwlSyM4esfDmLdbrSukTaFpFkhAyoXUQAJgNLC8nqOdTobsts/aTySiM46bn+XGbgbfdG6s3vajt1VkVPyE2pJmRSnT6qiXKTS43xWckpHa3BLmt2qn30jKHucFyh6atZ7c+JQwRn8GxwPE195j/MwuUMAiDR0n2civhocgP5lAG/jvkO/4xP2VQ9uA0UeQaUAl3xY3nHrC5M5TyXfh366URaE9TlyzXYgBSXVmfD2j+Gac49p/JynciggH7fK;25:zliqUEisTQnncqH561cIgjCrgIuImmomw2Pc9cIkX+ST5aEnlKLb2yFYEul4DtDvyBzdsl8R+2VDgQ8ONW8gm4KSz/sT/zd056fw9qQWaRH1wktHK0feIvo72Clu3W9GrzNHMsEnkpLhavTY8pJx3l0m2HVVZGfMWCSaqxSSL8fBNswuwfNL4iTCRvYtp70boTcl6J9E4T9xA0WBvlr+jx0puhKevDSvGYG0Eu+b27LGKAim0TzZRXgxADi11XKpvL+Is6sEbiNQ2YoCbEKXie0mWpPjei+JjzYZgKSpBYgnw+ALoSq+6wJpMQcBkY8x+2mx2oXZQ1Zsb99m7y/q9BCLTOo5eGRdzRap3VJswCwFf5pcDrWA/7x36GtQdBpLgzCT7QDqAM3yt5+3n3fAlpJGLl87giGh4f9qQQaZlDJYBV4SDfcQD2wzw2Z6U+Kmy2ED/qLDtKwLGB3gvEmfwg== X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB397;31:4jTVefQfp+vw8A/D+XO6poJe/4M3lqb/QaJnclFb3PlWBlsBqvzCtUsb+YzV0+jYhthh2SyDh+j+KlkeyekGdZzeFbToWhQogtP7xjbsG4Jf49bWwDAlMjnaLwLASMidlx+raFNYcauR8SLVqfmjp/5yuz2A4IuSqX0OJykaX4TCygawUtftZTLAW7oj7QisyyjuxVXH2BRBXU2oawGoqxNKq528WPibEOTeOaECP/fmGE7bBHsSJ3l6/VJ/oVp4XYMpvVjVH+Jg9fpqctk1GIHSNF9HsQBZ0xDk+9CYK4M= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(601004)(2401047)(8121501046)(13015025)(5005006)(13017025)(13018025)(13024025)(13023025)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(20161123563025)(20161123565025)(201703131430075)(201703131448075)(201703131433075)(201703161259075)(20161123561025)(20161123556025);SRVR:DM2PR03MB397;BCL:0;PCL:0;RULEID:(400006);SRVR:DM2PR03MB397; X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB397;4:95DnZDpsPXrxj/CpgavaxTZSBjv5sJv20vdi7VBpMhvEvg5lwaX3nppPFHMvj8+3uzeOuLjURW27FWELnjJmt6iJWU2NTVD2Kk/D5STgLydQO4K7cnyFm9GvbGO5bCSwfLLUf499UghenGOPRoWQpg6ljwQI4peYMxApFEZGDwNH9d9OYsEhg47KaaNHqPGRmTn/c1LrHnF6BwBSucSHjr09axzCQCJhSuWVze7xs2AsQpYeQKQoLy+CIYDP5d5F9sd10gvl/V9KbipIeaDlX/F5XB8nGrLM2jC6d9ZLIfhHRujg0i25/ZbirWP0k4Zm+hPlwTkdE5D1ttmF5XXOMoQxVbPoA1ehM1+u3AEUd911O0YaP/0713oFFntTOgtdpL75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9+aBywyQivkvM3YMAMh3uuuEp+YvC1KXzZqOLD4JrSzs1U4Zo+45WAOJJcyoXGiLzM8rnGfDD7a64V5YEg==;5:C6U8cpl+POW3JTN+FFYXawW4QL254TdcC3okLtHBj6+qQodSG7dImH/Ip3OefZHoLnuyId6wAig6qAElxibGLhnhPhXodGgsNvPVirqX/kdjiqNoyo7WEsOvuJZDM4c8QViA3zSvuBqFWZXfe1dFfiiTVo2pjDLMR8r1kxjkAXungumEp9TDcvZrcqy/OZRX;24:O9boPKRwlRWzaOa0j3b5Jw8YHrt31OZZZgnvfZuYV0H7FzcgkauagBnzj6w9Yr80GF4Q0IEfx7LNXEhm7diXTre5SefDvb6ExlD1rSVheGc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB397;7:QDBo+B7ikpKsJkJOPnsIA870mi3/NXIaJxSff09ZmeGwSPg+kynLzdAiWn4wKHof94JPxjFuFKdJf3ecs7HnwJmwYwCV/FnnLXLpUmhv1vf45s35LBvM0Byim2ge1+yr7c/aMzNRtAjqGi0pFYsH9cZ2h1QJD2zKnf2beuxVbEo0+TzC00gMJFsG58SqR4dennX14H5+/nZa0GaB7LQgX01wCDZMw3Rtg5C5l2zvtCYbGGps7KPWQE/GLGK1NNP6RHIIPIOtXbi2nfZm2Pwh47G35KUv/bOOmkw/vBwzfN9cqxMRzf30oBJ1pqCfchY4U/vVBl9brBnUoEo3xtKvsg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2017 14:08:49.7806 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB397 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1686 Lines: 38 On Thu, Mar 30, 2017 at 11:15 AM, Masahiro Yamada wrote: > > Some NAND controllers are using DMA engine requiring a specific > buffer alignment.  The core provides no guarantee on the nand_buffers > pointers, which forces some drivers to allocate their own buffers > and pass the NAND_OWN_BUFFERS flag. > > Rework the nand_buffers allocation logic to allocate each buffer > independently.  This should make most NAND controllers/DMA engine > happy, and allow us to get rid of these custom buf allocation in > NAND controller drivers. > > Signed-off-by: Masahiro Yamada > @@ -4914,8 +4930,12 @@ void nand_cleanup(struct nand_chip *chip) > >         /* Free bad block table memory */ >         kfree(chip->bbt); > -       if (!(chip->options & NAND_OWN_BUFFERS)) > +       if (!(chip->options & NAND_OWN_BUFFERS)) { > +               kfree(chip->buffers->databuf); > +               kfree(chip->buffers->ecccode); > +               kfree(chip->buffers->ecccalc); >                 kfree(chip->buffers); > +       } It seems that chip->buffers might not be allocated at this point, for example if nand_cleanup is called during a failed probe. You should check if (chip->buffers != NULL) before freeing stuff inside it. When attempting to run linux-next on various imx6qdl-sabreauto boards they now panic on boot. This happens because they have nand chips in devicetree which are not physically populated on the board. This normally fails in nand_scan_ident but now crashes later in nand_cleanup. -- Regards, Leonard