Skip to content

Commit b360514

Browse files
Ansuelmiquelraynal
authored andcommitted
mtd: nand: raw: qcom_nandc: reorder qcom_nand_host struct
Reorder structs in nandc driver to save holes. Signed-off-by: Christian Marangi <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent fc602b4 commit b360514

File tree

1 file changed

+62
-45
lines changed

1 file changed

+62
-45
lines changed

drivers/mtd/nand/raw/qcom_nandc.c

Lines changed: 62 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ nandc_set_reg(chip, reg, \
238238
* @bam_ce - the array of BAM command elements
239239
* @cmd_sgl - sgl for NAND BAM command pipe
240240
* @data_sgl - sgl for NAND BAM consumer/producer pipe
241+
* @last_data_desc - last DMA desc in data channel (tx/rx).
242+
* @last_cmd_desc - last DMA desc in command channel.
243+
* @txn_done - completion for NAND transfer.
241244
* @bam_ce_pos - the index in bam_ce which is available for next sgl
242245
* @bam_ce_start - the index in bam_ce which marks the start position ce
243246
* for current sgl. It will be used for size calculation
@@ -250,14 +253,14 @@ nandc_set_reg(chip, reg, \
250253
* @rx_sgl_start - start index in data sgl for rx.
251254
* @wait_second_completion - wait for second DMA desc completion before making
252255
* the NAND transfer completion.
253-
* @txn_done - completion for NAND transfer.
254-
* @last_data_desc - last DMA desc in data channel (tx/rx).
255-
* @last_cmd_desc - last DMA desc in command channel.
256256
*/
257257
struct bam_transaction {
258258
struct bam_cmd_element *bam_ce;
259259
struct scatterlist *cmd_sgl;
260260
struct scatterlist *data_sgl;
261+
struct dma_async_tx_descriptor *last_data_desc;
262+
struct dma_async_tx_descriptor *last_cmd_desc;
263+
struct completion txn_done;
261264
u32 bam_ce_pos;
262265
u32 bam_ce_start;
263266
u32 cmd_sgl_pos;
@@ -267,33 +270,31 @@ struct bam_transaction {
267270
u32 rx_sgl_pos;
268271
u32 rx_sgl_start;
269272
bool wait_second_completion;
270-
struct completion txn_done;
271-
struct dma_async_tx_descriptor *last_data_desc;
272-
struct dma_async_tx_descriptor *last_cmd_desc;
273273
};
274274

275275
/*
276276
* This data type corresponds to the nand dma descriptor
277+
* @dma_desc - low level DMA engine descriptor
277278
* @list - list for desc_info
278-
* @dir - DMA transfer direction
279+
*
279280
* @adm_sgl - sgl which will be used for single sgl dma descriptor. Only used by
280281
* ADM
281282
* @bam_sgl - sgl which will be used for dma descriptor. Only used by BAM
282283
* @sgl_cnt - number of SGL in bam_sgl. Only used by BAM
283-
* @dma_desc - low level DMA engine descriptor
284+
* @dir - DMA transfer direction
284285
*/
285286
struct desc_info {
287+
struct dma_async_tx_descriptor *dma_desc;
286288
struct list_head node;
287289

288-
enum dma_data_direction dir;
289290
union {
290291
struct scatterlist adm_sgl;
291292
struct {
292293
struct scatterlist *bam_sgl;
293294
int sgl_cnt;
294295
};
295296
};
296-
struct dma_async_tx_descriptor *dma_desc;
297+
enum dma_data_direction dir;
297298
};
298299

299300
/*
@@ -337,52 +338,64 @@ struct nandc_regs {
337338
/*
338339
* NAND controller data struct
339340
*
340-
* @controller: base controller structure
341-
* @host_list: list containing all the chips attached to the
342-
* controller
343341
* @dev: parent device
342+
*
344343
* @base: MMIO base
345-
* @base_phys: physical base address of controller registers
346-
* @base_dma: dma base address of controller registers
344+
*
347345
* @core_clk: controller clock
348346
* @aon_clk: another controller clock
349347
*
348+
* @regs: a contiguous chunk of memory for DMA register
349+
* writes. contains the register values to be
350+
* written to controller
351+
*
352+
* @props: properties of current NAND controller,
353+
* initialized via DT match data
354+
*
355+
* @controller: base controller structure
356+
* @host_list: list containing all the chips attached to the
357+
* controller
358+
*
350359
* @chan: dma channel
351360
* @cmd_crci: ADM DMA CRCI for command flow control
352361
* @data_crci: ADM DMA CRCI for data flow control
362+
*
353363
* @desc_list: DMA descriptor list (list of desc_infos)
354364
*
355365
* @data_buffer: our local DMA buffer for page read/writes,
356366
* used when we can't use the buffer provided
357367
* by upper layers directly
358-
* @buf_size/count/start: markers for chip->legacy.read_buf/write_buf
359-
* functions
360368
* @reg_read_buf: local buffer for reading back registers via DMA
369+
*
370+
* @base_phys: physical base address of controller registers
371+
* @base_dma: dma base address of controller registers
361372
* @reg_read_dma: contains dma address for register read buffer
362-
* @reg_read_pos: marker for data read in reg_read_buf
363373
*
364-
* @regs: a contiguous chunk of memory for DMA register
365-
* writes. contains the register values to be
366-
* written to controller
367-
* @cmd1/vld: some fixed controller register values
368-
* @props: properties of current NAND controller,
369-
* initialized via DT match data
374+
* @buf_size/count/start: markers for chip->legacy.read_buf/write_buf
375+
* functions
370376
* @max_cwperpage: maximum QPIC codewords required. calculated
371377
* from all connected NAND devices pagesize
378+
*
379+
* @reg_read_pos: marker for data read in reg_read_buf
380+
*
381+
* @cmd1/vld: some fixed controller register values
372382
*/
373383
struct qcom_nand_controller {
374-
struct nand_controller controller;
375-
struct list_head host_list;
376-
377384
struct device *dev;
378385

379386
void __iomem *base;
380-
phys_addr_t base_phys;
381-
dma_addr_t base_dma;
382387

383388
struct clk *core_clk;
384389
struct clk *aon_clk;
385390

391+
struct nandc_regs *regs;
392+
struct bam_transaction *bam_txn;
393+
394+
const struct qcom_nandc_props *props;
395+
396+
struct nand_controller controller;
397+
struct list_head host_list;
398+
386399
union {
387400
/* will be used only by QPIC for BAM DMA */
388401
struct {
@@ -400,22 +413,22 @@ struct qcom_nand_controller {
400413
};
401414

402415
struct list_head desc_list;
403-
struct bam_transaction *bam_txn;
404416

405417
u8 *data_buffer;
418+
__le32 *reg_read_buf;
419+
420+
phys_addr_t base_phys;
421+
dma_addr_t base_dma;
422+
dma_addr_t reg_read_dma;
423+
406424
int buf_size;
407425
int buf_count;
408426
int buf_start;
409427
unsigned int max_cwperpage;
410428

411-
__le32 *reg_read_buf;
412-
dma_addr_t reg_read_dma;
413429
int reg_read_pos;
414430

415-
struct nandc_regs *regs;
416-
417431
u32 cmd1, vld;
418-
const struct qcom_nandc_props *props;
419432
};
420433

421434
/*
@@ -431,19 +444,21 @@ struct qcom_nand_controller {
431444
* and reserved bytes
432445
* @cw_data: the number of bytes within a codeword protected
433446
* by ECC
434-
* @use_ecc: request the controller to use ECC for the
435-
* upcoming read/write
436-
* @bch_enabled: flag to tell whether BCH ECC mode is used
437447
* @ecc_bytes_hw: ECC bytes used by controller hardware for this
438448
* chip
439-
* @status: value to be returned if NAND_CMD_STATUS command
440-
* is executed
449+
*
441450
* @last_command: keeps track of last command on this chip. used
442451
* for reading correct status
443452
*
444453
* @cfg0, cfg1, cfg0_raw..: NANDc register configurations needed for
445454
* ecc/non-ecc mode for the current nand flash
446455
* device
456+
*
457+
* @status: value to be returned if NAND_CMD_STATUS command
458+
* is executed
459+
* @use_ecc: request the controller to use ECC for the
460+
* upcoming read/write
461+
* @bch_enabled: flag to tell whether BCH ECC mode is used
447462
*/
448463
struct qcom_nand_host {
449464
struct nand_chip chip;
@@ -452,12 +467,10 @@ struct qcom_nand_host {
452467
int cs;
453468
int cw_size;
454469
int cw_data;
455-
bool use_ecc;
456-
bool bch_enabled;
457470
int ecc_bytes_hw;
458471
int spare_bytes;
459472
int bbm_size;
460-
u8 status;
473+
461474
int last_command;
462475

463476
u32 cfg0, cfg1;
@@ -466,23 +479,27 @@ struct qcom_nand_host {
466479
u32 ecc_bch_cfg;
467480
u32 clrflashstatus;
468481
u32 clrreadstatus;
482+
483+
u8 status;
484+
bool use_ecc;
485+
bool bch_enabled;
469486
};
470487

471488
/*
472489
* This data type corresponds to the NAND controller properties which varies
473490
* among different NAND controllers.
474491
* @ecc_modes - ecc mode for NAND
492+
* @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset
475493
* @is_bam - whether NAND controller is using BAM
476494
* @is_qpic - whether NAND CTRL is part of qpic IP
477495
* @qpic_v2 - flag to indicate QPIC IP version 2
478-
* @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset
479496
*/
480497
struct qcom_nandc_props {
481498
u32 ecc_modes;
499+
u32 dev_cmd_reg_start;
482500
bool is_bam;
483501
bool is_qpic;
484502
bool qpic_v2;
485-
u32 dev_cmd_reg_start;
486503
};
487504

488505
/* Frees the BAM transaction memory */

0 commit comments

Comments
 (0)