1 From b360514edb4743cbf86fc377699c75e98b1264c7 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Thu, 16 Jun 2022 02:18:33 +0200
4 Subject: [PATCH 1/2] mtd: nand: raw: qcom_nandc: reorder qcom_nand_host struct
6 Reorder structs in nandc driver to save holes.
8 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
9 Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
10 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
11 Link: https://lore.kernel.org/linux-mtd/20220616001835.24393-2-ansuelsmth@gmail.com
13 drivers/mtd/nand/raw/qcom_nandc.c | 107 +++++++++++++++++-------------
14 1 file changed, 62 insertions(+), 45 deletions(-)
16 --- a/drivers/mtd/nand/raw/qcom_nandc.c
17 +++ b/drivers/mtd/nand/raw/qcom_nandc.c
18 @@ -237,6 +237,9 @@ nandc_set_reg(chip, reg, \
19 * @bam_ce - the array of BAM command elements
20 * @cmd_sgl - sgl for NAND BAM command pipe
21 * @data_sgl - sgl for NAND BAM consumer/producer pipe
22 + * @last_data_desc - last DMA desc in data channel (tx/rx).
23 + * @last_cmd_desc - last DMA desc in command channel.
24 + * @txn_done - completion for NAND transfer.
25 * @bam_ce_pos - the index in bam_ce which is available for next sgl
26 * @bam_ce_start - the index in bam_ce which marks the start position ce
27 * for current sgl. It will be used for size calculation
28 @@ -249,14 +252,14 @@ nandc_set_reg(chip, reg, \
29 * @rx_sgl_start - start index in data sgl for rx.
30 * @wait_second_completion - wait for second DMA desc completion before making
31 * the NAND transfer completion.
32 - * @txn_done - completion for NAND transfer.
33 - * @last_data_desc - last DMA desc in data channel (tx/rx).
34 - * @last_cmd_desc - last DMA desc in command channel.
36 struct bam_transaction {
37 struct bam_cmd_element *bam_ce;
38 struct scatterlist *cmd_sgl;
39 struct scatterlist *data_sgl;
40 + struct dma_async_tx_descriptor *last_data_desc;
41 + struct dma_async_tx_descriptor *last_cmd_desc;
42 + struct completion txn_done;
46 @@ -266,25 +269,23 @@ struct bam_transaction {
49 bool wait_second_completion;
50 - struct completion txn_done;
51 - struct dma_async_tx_descriptor *last_data_desc;
52 - struct dma_async_tx_descriptor *last_cmd_desc;
56 * This data type corresponds to the nand dma descriptor
57 + * @dma_desc - low level DMA engine descriptor
58 * @list - list for desc_info
59 - * @dir - DMA transfer direction
61 * @adm_sgl - sgl which will be used for single sgl dma descriptor. Only used by
63 * @bam_sgl - sgl which will be used for dma descriptor. Only used by BAM
64 * @sgl_cnt - number of SGL in bam_sgl. Only used by BAM
65 - * @dma_desc - low level DMA engine descriptor
66 + * @dir - DMA transfer direction
69 + struct dma_async_tx_descriptor *dma_desc;
70 struct list_head node;
72 - enum dma_data_direction dir;
74 struct scatterlist adm_sgl;
76 @@ -292,7 +293,7 @@ struct desc_info {
80 - struct dma_async_tx_descriptor *dma_desc;
81 + enum dma_data_direction dir;
85 @@ -336,52 +337,64 @@ struct nandc_regs {
87 * NAND controller data struct
89 - * @controller: base controller structure
90 - * @host_list: list containing all the chips attached to the
95 - * @base_phys: physical base address of controller registers
96 - * @base_dma: dma base address of controller registers
98 * @core_clk: controller clock
99 * @aon_clk: another controller clock
101 + * @regs: a contiguous chunk of memory for DMA register
102 + * writes. contains the register values to be
103 + * written to controller
105 + * @props: properties of current NAND controller,
106 + * initialized via DT match data
108 + * @controller: base controller structure
109 + * @host_list: list containing all the chips attached to the
113 * @cmd_crci: ADM DMA CRCI for command flow control
114 * @data_crci: ADM DMA CRCI for data flow control
116 * @desc_list: DMA descriptor list (list of desc_infos)
118 * @data_buffer: our local DMA buffer for page read/writes,
119 * used when we can't use the buffer provided
120 * by upper layers directly
121 - * @buf_size/count/start: markers for chip->legacy.read_buf/write_buf
123 * @reg_read_buf: local buffer for reading back registers via DMA
125 + * @base_phys: physical base address of controller registers
126 + * @base_dma: dma base address of controller registers
127 * @reg_read_dma: contains dma address for register read buffer
128 - * @reg_read_pos: marker for data read in reg_read_buf
130 - * @regs: a contiguous chunk of memory for DMA register
131 - * writes. contains the register values to be
132 - * written to controller
133 - * @cmd1/vld: some fixed controller register values
134 - * @props: properties of current NAND controller,
135 - * initialized via DT match data
136 + * @buf_size/count/start: markers for chip->legacy.read_buf/write_buf
138 * @max_cwperpage: maximum QPIC codewords required. calculated
139 * from all connected NAND devices pagesize
141 + * @reg_read_pos: marker for data read in reg_read_buf
143 + * @cmd1/vld: some fixed controller register values
145 struct qcom_nand_controller {
146 - struct nand_controller controller;
147 - struct list_head host_list;
152 - phys_addr_t base_phys;
153 - dma_addr_t base_dma;
155 struct clk *core_clk;
158 + struct nandc_regs *regs;
159 + struct bam_transaction *bam_txn;
161 + const struct qcom_nandc_props *props;
163 + struct nand_controller controller;
164 + struct list_head host_list;
167 /* will be used only by QPIC for BAM DMA */
169 @@ -399,22 +412,22 @@ struct qcom_nand_controller {
172 struct list_head desc_list;
173 - struct bam_transaction *bam_txn;
176 + __le32 *reg_read_buf;
178 + phys_addr_t base_phys;
179 + dma_addr_t base_dma;
180 + dma_addr_t reg_read_dma;
185 unsigned int max_cwperpage;
187 - __le32 *reg_read_buf;
188 - dma_addr_t reg_read_dma;
191 - struct nandc_regs *regs;
194 - const struct qcom_nandc_props *props;
198 @@ -430,19 +443,21 @@ struct qcom_nand_controller {
200 * @cw_data: the number of bytes within a codeword protected
202 - * @use_ecc: request the controller to use ECC for the
203 - * upcoming read/write
204 - * @bch_enabled: flag to tell whether BCH ECC mode is used
205 * @ecc_bytes_hw: ECC bytes used by controller hardware for this
207 - * @status: value to be returned if NAND_CMD_STATUS command
210 * @last_command: keeps track of last command on this chip. used
211 * for reading correct status
213 * @cfg0, cfg1, cfg0_raw..: NANDc register configurations needed for
214 * ecc/non-ecc mode for the current nand flash
217 + * @status: value to be returned if NAND_CMD_STATUS command
219 + * @use_ecc: request the controller to use ECC for the
220 + * upcoming read/write
221 + * @bch_enabled: flag to tell whether BCH ECC mode is used
223 struct qcom_nand_host {
224 struct nand_chip chip;
225 @@ -451,12 +466,10 @@ struct qcom_nand_host {
239 @@ -465,23 +478,27 @@ struct qcom_nand_host {
250 * This data type corresponds to the NAND controller properties which varies
251 * among different NAND controllers.
252 * @ecc_modes - ecc mode for NAND
253 + * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset
254 * @is_bam - whether NAND controller is using BAM
255 * @is_qpic - whether NAND CTRL is part of qpic IP
256 * @qpic_v2 - flag to indicate QPIC IP version 2
257 - * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset
259 struct qcom_nandc_props {
261 + u32 dev_cmd_reg_start;
265 - u32 dev_cmd_reg_start;
268 /* Frees the BAM transaction memory */