Skip to content

Commit 49da910

Browse files
sudeep-hollajoyxu
authored andcommitted
soc: hisilicon: kunpeng_hccs: Simplify PCC shared memory region handling
The PCC driver now handles mapping and unmapping of shared memory areas as part of pcc_mbox_{request,free}_channel(). Without these before, this Kunpeng HCCS driver did handling of those mappings like several other PCC mailbox client drivers. There were redundant operations, leading to unnecessary code. Maintaining the consistency across these driver was harder due to scattered handling of shmem. Just use the mapped shmem and remove all redundant operations from this driver. Cc: Huisong Li <[email protected]> Signed-off-by: Sudeep Holla <[email protected]> Reviewed-by: Huisong Li <[email protected]> Signed-off-by: Wei Xu <[email protected]>
1 parent 0af2f6b commit 49da910

File tree

2 files changed

+15
-29
lines changed

2 files changed

+15
-29
lines changed

drivers/soc/hisilicon/kunpeng_hccs.c

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ static void hccs_pcc_rx_callback(struct mbox_client *cl, void *mssg)
167167

168168
static void hccs_unregister_pcc_channel(struct hccs_dev *hdev)
169169
{
170-
struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
171-
172-
if (cl_info->pcc_comm_addr)
173-
iounmap(cl_info->pcc_comm_addr);
174170
pcc_mbox_free_channel(hdev->cl_info.pcc_chan);
175171
}
176172

@@ -179,6 +175,7 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev)
179175
struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
180176
struct mbox_client *cl = &cl_info->client;
181177
struct pcc_mbox_chan *pcc_chan;
178+
struct mbox_chan *mbox_chan;
182179
struct device *dev = hdev->dev;
183180
int rc;
184181

@@ -196,7 +193,7 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev)
196193
goto out;
197194
}
198195
cl_info->pcc_chan = pcc_chan;
199-
cl_info->mbox_chan = pcc_chan->mchan;
196+
mbox_chan = pcc_chan->mchan;
200197

201198
/*
202199
* pcc_chan->latency is just a nominal value. In reality the remote
@@ -206,34 +203,24 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev)
206203
cl_info->deadline_us =
207204
HCCS_PCC_CMD_WAIT_RETRIES_NUM * pcc_chan->latency;
208205
if (!hdev->verspec_data->has_txdone_irq &&
209-
cl_info->mbox_chan->mbox->txdone_irq) {
206+
mbox_chan->mbox->txdone_irq) {
210207
dev_err(dev, "PCC IRQ in PCCT is enabled.\n");
211208
rc = -EINVAL;
212209
goto err_mbx_channel_free;
213210
} else if (hdev->verspec_data->has_txdone_irq &&
214-
!cl_info->mbox_chan->mbox->txdone_irq) {
211+
!mbox_chan->mbox->txdone_irq) {
215212
dev_err(dev, "PCC IRQ in PCCT isn't supported.\n");
216213
rc = -EINVAL;
217214
goto err_mbx_channel_free;
218215
}
219216

220-
if (!pcc_chan->shmem_base_addr ||
221-
pcc_chan->shmem_size != HCCS_PCC_SHARE_MEM_BYTES) {
222-
dev_err(dev, "The base address or size (%llu) of PCC communication region is invalid.\n",
223-
pcc_chan->shmem_size);
217+
if (pcc_chan->shmem_size != HCCS_PCC_SHARE_MEM_BYTES) {
218+
dev_err(dev, "Base size (%llu) of PCC communication region must be %d bytes.\n",
219+
pcc_chan->shmem_size, HCCS_PCC_SHARE_MEM_BYTES);
224220
rc = -EINVAL;
225221
goto err_mbx_channel_free;
226222
}
227223

228-
cl_info->pcc_comm_addr = ioremap(pcc_chan->shmem_base_addr,
229-
pcc_chan->shmem_size);
230-
if (!cl_info->pcc_comm_addr) {
231-
dev_err(dev, "Failed to ioremap PCC communication region for channel-%u.\n",
232-
hdev->chan_id);
233-
rc = -ENOMEM;
234-
goto err_mbx_channel_free;
235-
}
236-
237224
return 0;
238225

239226
err_mbx_channel_free:
@@ -246,7 +233,7 @@ static int hccs_wait_cmd_complete_by_poll(struct hccs_dev *hdev)
246233
{
247234
struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
248235
struct acpi_pcct_shared_memory __iomem *comm_base =
249-
cl_info->pcc_comm_addr;
236+
cl_info->pcc_chan->shmem;
250237
u16 status;
251238
int ret;
252239

@@ -289,7 +276,7 @@ static inline void hccs_fill_pcc_shared_mem_region(struct hccs_dev *hdev,
289276
.status = 0,
290277
};
291278

292-
memcpy_toio(hdev->cl_info.pcc_comm_addr, (void *)&tmp,
279+
memcpy_toio(hdev->cl_info.pcc_chan->shmem, (void *)&tmp,
293280
sizeof(struct acpi_pcct_shared_memory));
294281

295282
/* Copy the message to the PCC comm space */
@@ -309,7 +296,7 @@ static inline void hccs_fill_ext_pcc_shared_mem_region(struct hccs_dev *hdev,
309296
.command = cmd,
310297
};
311298

312-
memcpy_toio(hdev->cl_info.pcc_comm_addr, (void *)&tmp,
299+
memcpy_toio(hdev->cl_info.pcc_chan->shmem, (void *)&tmp,
313300
sizeof(struct acpi_pcct_ext_pcc_shared_memory));
314301

315302
/* Copy the message to the PCC comm space */
@@ -321,20 +308,21 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
321308
{
322309
const struct hccs_verspecific_data *verspec_data = hdev->verspec_data;
323310
struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
311+
struct mbox_chan *mbox_chan = cl_info->pcc_chan->mchan;
324312
struct hccs_fw_inner_head *fw_inner_head;
325313
void __iomem *comm_space;
326314
u16 space_size;
327315
int ret;
328316

329-
comm_space = cl_info->pcc_comm_addr + verspec_data->shared_mem_size;
317+
comm_space = cl_info->pcc_chan->shmem + verspec_data->shared_mem_size;
330318
space_size = HCCS_PCC_SHARE_MEM_BYTES - verspec_data->shared_mem_size;
331319
verspec_data->fill_pcc_shared_mem(hdev, cmd, desc,
332320
comm_space, space_size);
333321
if (verspec_data->has_txdone_irq)
334322
reinit_completion(&cl_info->done);
335323

336324
/* Ring doorbell */
337-
ret = mbox_send_message(cl_info->mbox_chan, &cmd);
325+
ret = mbox_send_message(mbox_chan, &cmd);
338326
if (ret < 0) {
339327
dev_err(hdev->dev, "Send PCC mbox message failed, ret = %d.\n",
340328
ret);
@@ -356,9 +344,9 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
356344

357345
end:
358346
if (verspec_data->has_txdone_irq)
359-
mbox_chan_txdone(cl_info->mbox_chan, ret);
347+
mbox_chan_txdone(mbox_chan, ret);
360348
else
361-
mbox_client_txdone(cl_info->mbox_chan, ret);
349+
mbox_client_txdone(mbox_chan, ret);
362350
return ret;
363351
}
364352

drivers/soc/hisilicon/kunpeng_hccs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ struct hccs_chip_info {
6060

6161
struct hccs_mbox_client_info {
6262
struct mbox_client client;
63-
struct mbox_chan *mbox_chan;
6463
struct pcc_mbox_chan *pcc_chan;
6564
u64 deadline_us;
66-
void __iomem *pcc_comm_addr;
6765
struct completion done;
6866
};
6967

0 commit comments

Comments
 (0)