Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752454AbdCCTPo (ORCPT ); Fri, 3 Mar 2017 14:15:44 -0500 Received: from mail-sn1nam02on0081.outbound.protection.outlook.com ([104.47.36.81]:41376 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751976AbdCCTPk (ORCPT ); Fri, 3 Mar 2017 14:15:40 -0500 Authentication-Results: cavium.com; dkim=none (message not signed) header.d=none;cavium.com; dmarc=none action=none header.from=caviumnetworks.com; Subject: Re: [PATCH v11 2/9] mmc: cavium: Add core MMC driver for Cavium SOCs To: Ulf Hansson , Jan Glauber References: <20170206133953.8390-1-jglauber@cavium.com> <20170206133953.8390-3-jglauber@cavium.com> Cc: "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Steven J . Hill" , David Daney From: David Daney Message-ID: <59986cad-be37-27fd-f9fe-bb11579bc0ea@caviumnetworks.com> Date: Fri, 3 Mar 2017 10:39:11 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: DM2PR07CA0049.namprd07.prod.outlook.com (10.141.52.177) To BY2PR07MB2422.namprd07.prod.outlook.com (10.166.115.14) X-MS-Office365-Filtering-Correlation-Id: 89a68026-45bd-4f28-a1ec-08d462649804 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BY2PR07MB2422; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2422;3:gdt9W+EfbWLhNIYs+ixE8m1m8xoxObPYU+qK8sPmpGLeBzNHNcd9n3YhBILyTF98oU7maLGpAd1k69QNg9r9+h74gsTzkKTtNf1XsHO5Nz6dRsa4YWyrQxpOLj9N5c+07r2Of4Rf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EpLknun4fmdL4yA3y/s8Ia60ohAGwWkGLlchAKgEoC4YeWCnpjxXUrkwS9yAlzP5fO2+qgh7jcI0o9rhnB9UI0KZ19EJUIu1LfqArMMdQzaE+aMiQawR0EltCqNPpxC0xJM/VFPgkyo7VmI8yrpoEjdPd162dFpO8+MTgAa/8pCnw2Zdd5qHSrTGoMIPS0xHva+jHtnV9oF+2Hpx997A9JyhnVgEZjAPmeJQwMpn3yMJvA3d8bIjpIWjfkKnrN8CTQ8b5gukfF1n64o2ZlfNymBVxCRtZsJmHuPG6P6tETnrHHOGEYBBo59hppZ6LcivkstFthYllKMFEzZVXMlK3pQI6XuFagP0VxY1uI0CYSLOvH0qVyBC4qzegSV4gzMl7KkD+VDwJqj/JLySLJ9l+yMvMEY3BFEHcV+7VMVqky8skzbEOD7wPcSuuYX4pgMvKQeOJw6Mi8x0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123562025)(20161123558025)(20161123560025)(20161123555025)(20161123564025)(6072148);SRVR:BY2PR07MB2422;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB2422; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2422;4:YHOyPhWF6Df9fJFPn4WHbHS+sBuVGKe4yMLrhlI8pVUpDpm/0bHivVjVT8FwCVZt0ecsq4jU3C8blwPa12mzGBC71c3MCjiDffuhIaT1fQA5jrKE6VkstKQSPWuoN8/yUypyE+qgDm3iw/ONvX0LiMKuJQutE87Qx6Acic4ORREif0dtJ6IqFzXRqMJ+88foZywfvgucjPnB8+gU2bkfFwX2Ha5DrjNoW8NJxaR8LC5XxUHdvvVfRiqq40s4s/UXY1qKivFxIZJ6YltzJdfXfZLDESMj1iwhNzipHyHgpgNk1rPr3cZItvePTWuBSYfdOcOdXEYr0RNrGuvtWmGMdCCRfZT5PvS3yzFINMUQCyv+bvY+4LXm1xnCvGMDD098Q3TPftJK9kRaQUX59YqKwXRJX5XXbGDc1J3m2JAr9h+CQB0+LtHfgv7h5dt/Ync8l2WpPOyy28CvwNSEflaMBM5hYClM1l0QAcQEAHprPG27ZempXk54qZZZslK7knRuv5yLNeVSVEASVZtFk5t1xV84EI4g/jfUzhNXPIF/4yilILCJ0y065niR1T4BwXMqkOp+8FPdnSgE2EKK4r7ASif6K0FBXabHUHbADIp9ow0= X-Forefront-PRVS: 0235CBE7D0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(24454002)(377454003)(189998001)(229853002)(31696002)(6506006)(25786008)(5660300001)(47776003)(7736002)(33646002)(305945005)(92566002)(2906002)(23676002)(54906002)(50466002)(6512007)(6486002)(64126003)(83506001)(4001350100001)(4326008)(38730400002)(76176999)(53416004)(65956001)(66066001)(36756003)(50986999)(53546006)(6246003)(3846002)(107886003)(42186005)(31686004)(230700001)(53936002)(81166006)(8676002)(6116002)(42882006)(65826007)(6666003)(2950100002)(54356999);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR07MB2422;H:ddl.caveonetworks.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjA3TUIyNDIyOzIzOmR2bHBBbzZHdFMyRHQ0dElKQzFoMXhKQ3A4?= =?utf-8?B?VVM0a21NMmFkUS9XVTdlc2grZGJsajZMbVR5WldheUxLbFR1V0dNVnVnRCtO?= =?utf-8?B?eHFrVzF1SnpyNHQzNEYxQlJMWDJsd0RkaFhRYmNrU3IyUVArTVhYQlN6Y0I5?= =?utf-8?B?eUJhWkNSeTRWRUExZExnb1lXVVhZbllJNWloQkVuMEZZNVBkY2VuUmM4VkNy?= =?utf-8?B?NU5rK3RocG9DelBqa2lHc0NXNnk0bkxvNHlCeEM5R0dpeDNYOFNXN201YkxJ?= =?utf-8?B?UDBkb3lzcW5zazg5T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bYxmvoIvurxTbvJDS4l/tKs/B7x1Ahbx5dJSn+h8dYtFz4eTCGsgNG1XvrjjJ/R7jJL+J+KcMecwAbDAGOWXhGl+iWJzseOCEPw==;24:5AT5n3oHtLtRKN7AeZpcQBuKY0Zi2XQeCiOXhBocrCZ8J6Mprk11PGS9nqvkwGpj/0wTMykBVRNM/5Tk7bEdgbD7CB54O6cv0ISt8p3kLpw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2422;7:wmKGEuyrtnYaeakgW363RLu0cHJhwox+W2Mi+HdVwXNDDcwUlapDETyO9zf/H+PGp73cf4ryHuBE54+gCcBtON9g+dE+Li5feK1/5+WOWxtipYD/J3HehzQ/LLRfHqRCN9ZfQIWjxKUzzY/ggpAX5QeK3khHZ4iweL5ssixvTAZLpSIgsJ7r+EAkRU1DrfdB3ZbrVakZtbsmG5tCTX9VjXb4Vf2b3jiUmcJ0E50Ky+3u6Irms/ABRFCatPgCbDagt1iR5HfGMSIGIZhMDV7LeP5I3WxWmSuXXRSKgk6dZXKvvMF/ZGrW6hw6sIfdWsAoyW2DhWR2X22gNXOskRCscQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 18:39:14.5897 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB2422 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3313 Lines: 81 On 03/03/2017 03:47 AM, Ulf Hansson wrote: > On 6 February 2017 at 14:39, Jan Glauber wrote: [...] >> +} >> + >> +static void prepare_ext_dma(struct mmc_host *mmc, struct mmc_request *mrq, >> + union mio_emm_dma *emm_dma) >> +{ >> + struct cvm_mmc_slot *slot = mmc_priv(mmc); >> + >> + /* >> + * Our MMC host hardware does not issue single commands, >> + * because that would require the driver and the MMC core >> + * to do work to determine the proper sequence of commands. > > I don't get this. The allowed sequence of the commands is determined > by the SD/(e)MMC/SDIO spec and much of this knowledge is the > responsibility of the mmc core. > >> + * Instead, our hardware is superior to most other MMC bus > > No need to brag about your HW. Let's just describe how it works instead. > >> + * hosts. The sequence of MMC commands required to execute >> + * a transfer are issued automatically by the bus hardware. > > What does this really mean? Is this about HW support for better > dealing with data requests? The entire comment should be removed. It is laced with sarcasm that is very difficult for people not intimately familiar with the discussions to detect and decipher. The real story is that the Cavium MMC hardware was designed based on a defective premise. Hardwired in to the core of the MMC bus interface hardware is a multi-command synthesizer/sequencer that is hard coded to work with a limited subset of MMC-only command sequences. This allows you to read data from the first few MB of an MMC device with only a handful of assembly language instructions contained in the on-die mask-ROM of the SoC. When it comes to actually using the MMC/SD bus interface from within the Linux MMC framework, we have to apply a transform to the command sequences supplied by the Linux MMC core so that the command sequence synthesized by Cavium MMC hardware matches as closely as possible what was actually requested. For many command sequences, the match between what is synthesized by the hardware and what was requested is not exact. > >> + * >> + * - David Daney >> + */ >> + emm_dma->val = 0; >> + emm_dma->s.bus_id = slot->bus_id; >> + emm_dma->s.dma_val = 1; >> + emm_dma->s.sector = (mrq->data->blksz == 512) ? 1 : 0; >> + emm_dma->s.rw = (mrq->data->flags & MMC_DATA_WRITE) ? 1 : 0; >> + emm_dma->s.block_cnt = mrq->data->blocks; >> + emm_dma->s.card_addr = mrq->cmd->arg; >> + if (mmc_card_mmc(mmc->card) || (mmc_card_sd(mmc->card) && >> + (mmc->card->scr.cmds & SD_SCR_CMD23_SUPPORT))) >> + emm_dma->s.multi = 1; Here is a prefect example. If a multi-block transfer was requested, the hardware command synthesizer uses the "multi" bit to determine if it should generate a command sequence for a single multi-block transfer, or multiple single-block transfers. Probably the MMC core would never request a multi-block transfer from a device that doesn't support it, but we check here just-in-case. >> + >> + pr_debug("[%s] blocks: %u multi: %d\n", (emm_dma->s.rw) ? "W" : "R", >> + mrq->data->blocks, emm_dma->s.multi); >> +} >> +