Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752581AbdL0UPP (ORCPT ); Wed, 27 Dec 2017 15:15:15 -0500 Received: from mail-by2nam03on0107.outbound.protection.outlook.com ([104.47.42.107]:37938 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751881AbdL0UPN (ORCPT ); Wed, 27 Dec 2017 15:15:13 -0500 From: Trent Piepho To: "broonie@kernel.org" CC: "nicolas.ferre@microchip.com" , "linux-kernel@vger.kernel.org" , "linux-mtd@lists.infradead.org" , "radu.pirea@microchip.com" , "linux@armlinux.org.uk" , "devicetree@vger.kernel.org" , "linux-spi@vger.kernel.org" , "robh@kernel.org" , "cyrille.pitchen@wedev4u.fr" , "dwmw2@infradead.org" , "computersforpeace@gmail.com" , "vigneshr@ti.com" , "boris.brezillon@free-electrons.com" , "richard@nod.at" , "marek.vasut@gmail.com" Subject: Re: [PATCH 0/3] mtd: spi-nor: fix DMA-unsafe buffer issue between MTD and SPI Thread-Topic: [PATCH 0/3] mtd: spi-nor: fix DMA-unsafe buffer issue between MTD and SPI Thread-Index: AQHTfHXFw6hvEl9zL0SstW+hyzuciaNV+niAgAEJoICAAKHHgA== Date: Wed, 27 Dec 2017 20:15:11 +0000 Message-ID: <1514405711.26695.67.camel@impinj.com> References: <1514313927.26695.19.camel@impinj.com> <20171227103609.GQ1827@finisterre> In-Reply-To: <20171227103609.GQ1827@finisterre> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; x-originating-ip: [216.243.31.162] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR0601MB3754;7:rA7CCmqrvMLpEaeSpIqsMeexVGaFO6nyotF0p5PKD7oxykEtPyVhr4py12hRsBMlR1BasLB6FZ0QFUCvHWL+nD9MEraLo+kn7hf/dgw06NoHKBCtk1cuLC0cZB5OngfTNagiJGDNgOjcDMsQn66nic5oJJWVBytUmBnQLZwhkqMj12ycMLVFeFOh2DnsjmiRmTMj9x0LsirRmbnmedfATfOcq1hhyAy2ET4hceKkHxSGzrFBOD9BZhshj/DNA1Co x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 2d460141-7b34-4986-81a4-08d54d6688d8 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060);SRVR:MWHPR0601MB3754; x-ms-traffictypediagnostic: MWHPR0601MB3754: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(944501075)(93006095)(93001095)(10201501046)(3002001)(6041268)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011);SRVR:MWHPR0601MB3754;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:MWHPR0601MB3754; x-forefront-prvs: 0534947130 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(366004)(39380400002)(39840400004)(346002)(396003)(24454002)(377424004)(199004)(189003)(6486002)(6246003)(86362001)(103116003)(2906002)(6916009)(3660700001)(76176011)(68736007)(8936002)(478600001)(106356001)(105586002)(81166006)(81156014)(1730700003)(3280700002)(8676002)(3846002)(6116002)(2351001)(14454004)(99286004)(4001150100001)(6512007)(305945005)(2900100001)(97736004)(4326008)(229853002)(39060400002)(7736002)(36756003)(25786009)(66066001)(5250100002)(53936002)(6436002)(2950100002)(5640700003)(2501003)(54906003)(316002)(59450400001)(7416002)(5660300001)(102836004)(6506007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR0601MB3754;H:MWHPR0601MB3753.namprd06.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; x-microsoft-antispam-message-info: 4Mb+5yHp8tVsCRBfSO8SdsAN8D9VEBSrS0h+EFirfxPyoqdUrwZRcuIBDVA4khy7kEZeSxLfpPukWG0VX8wSIw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d460141-7b34-4986-81a4-08d54d6688d8 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Dec 2017 20:15:11.9905 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0601MB3754 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id vBRKFLYi001703 Content-Length: 2187 Lines: 43 On Wed, 2017-12-27 at 10:36 +0000, Mark Brown wrote: > On Tue, Dec 26, 2017 at 06:45:28PM +0000, Trent Piepho wrote: > > > Or, since this only fixes instances of DMA-unsafe buffers used in > > access to SPI NOR flash chips, and since there are other SPI master > > interface users, those chip specific fixes in some/all spi master > > drivers are still needed to fix transfers not originated via spi-nor? > > SPI client drivers are *supposed* to use DMA safe memory already. How > often that happens in cases where it matters is a separate question, we > definitely have users with smaller transfers that don't do the right > thing but they're normally done using PIO anyway. I wonder what the end goal is here? A random collection of spi master drivers will accept DMA-unsafe buffers in some way. In some cases a framework like spi-nor provides the fixup to spi-nor master drivers (none so far) and in other cases (atmel-quadspi), the spi-nor master driver has its own fixes. Generic spi masters like spi-atmel, spi-ti-qspi, and spi-davinci will have their fixes for certain cases. Perhaps spi flash drivers like m25p80 will have fixes too? Some spi clients, like spidev, will have internal bounce buffers, rather than userspace addresses or commands in stack variables, so that they follow the rules about DMA safe buffers. What exactly is caught as DMA unsafe and what is not will of course vary greatly from driver to driver. Some drivers will catch highmem memory while other drivers will only detect vmalloc memory. Some will only catch an unsafe buffer if a specific SoC known to the driver to have an aliasing cache is enabled. Some will check buffers that arrive via the spi_flash_read interface but not via generic spi transfers, while others will check all spi transfer buffers. Obviously, I don't think this path will lead to a desirable end. Maybe the basic assumption, that clients should provide DMA safe buffers, should be revisited. Experience has shown that it's too much to ask for and spi clients will never get it right. It would be better to try to fix this at some common point between the clients and masters so it can be done once and for all.