From 4312a1dfca26a0b5c30ac6890b0078e8d31ff6bf Mon Sep 17 00:00:00 2001 From: MD Danish Anwar Date: Tue, 30 Jan 2024 11:48:04 +0530 Subject: dma: ti: k3-udma: Use ring_idx to pair k3 nav rings Use ring_idx to pair rings. ring_idx will be same as tx flow_id for all non-negative flow_ids. For negative flow_ids, ring_idx will be tchan->id added with bchan_cnt. Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/dma/ti/k3-udma.c?h=v6.8-rc2#n1686 Signed-off-by: MD Danish Anwar Reviewed-by: Ravi Gunasekaran --- drivers/dma/ti/k3-udma.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 8a62d63dfe..eea9ec9659 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -876,13 +876,20 @@ static int udma_alloc_tx_resources(struct udma_chan *uc) { struct k3_nav_ring_cfg ring_cfg; struct udma_dev *ud = uc->ud; - int ret; + struct udma_tchan *tchan; + int ring_idx, ret; ret = udma_get_tchan(uc); if (ret) return ret; - ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, uc->tchan->id, -1, + tchan = uc->tchan; + if (tchan->tflow_id >= 0) + ring_idx = tchan->tflow_id; + else + ring_idx = ud->bchan_cnt + tchan->id; + + ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, ring_idx, -1, &uc->tchan->t_ring, &uc->tchan->tc_ring); if (ret) { -- cgit v1.2.3 From 0c4e36d65f6c25e5016235cc3f1e97c8d237f416 Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Tue, 30 Jan 2024 20:29:59 +0530 Subject: firmware: ti_sci: fix the secure_hdr in do_xfer The ti_sci driver in U-Boot has support for secure_msg as part of it's do_xfer function. This let's U-boot send secure messages during boot up. The protocol to send such secure messages is described as part of the struct ti_sci_secure_msg_hdr. As part of this, there are 2 fields for checksum and reserved that occupy the first 4 bytes of any secure message. This is called as the secure_hdr. As of now, the secure_hdr needs to be 0 init-ed before sending secure messages. However the existing code was never putting the zero-inited vars into the secure_buf, leading to possibility of the first 4 bytes of secure_buf being possibly garbage. Fix this by initialising the secure_hdr itself to the secure_buf location, thus when we make secure_hdr members 0, it automatically ensures the first 4 bytes of secure_buf are 0. Fixes: 32cd25128bd849 ("firmware: Add basic support for TI System Control Interface (TI SCI)") Reviewed-by: Nishanth Menon Signed-off-by: Dhruva Gole --- drivers/firmware/ti_sci.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 6e9f93e9a3..b77ac36af2 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -236,21 +236,21 @@ static int ti_sci_do_xfer(struct ti_sci_info *info, { struct k3_sec_proxy_msg *msg = &xfer->tx_message; u8 secure_buf[info->desc->max_msg_size]; - struct ti_sci_secure_msg_hdr secure_hdr; + struct ti_sci_secure_msg_hdr *secure_hdr = (struct ti_sci_secure_msg_hdr *)secure_buf; int ret; if (info->is_secure) { /* ToDo: get checksum of the entire message */ - secure_hdr.checksum = 0; - secure_hdr.reserved = 0; - memcpy(&secure_buf[sizeof(secure_hdr)], xfer->tx_message.buf, + secure_hdr->checksum = 0; + secure_hdr->reserved = 0; + memcpy(&secure_buf[sizeof(*secure_hdr)], xfer->tx_message.buf, xfer->tx_message.len); xfer->tx_message.buf = (u32 *)secure_buf; - xfer->tx_message.len += sizeof(secure_hdr); + xfer->tx_message.len += sizeof(*secure_hdr); if (xfer->rx_len) - xfer->rx_len += sizeof(secure_hdr); + xfer->rx_len += sizeof(*secure_hdr); } /* Send the message */ -- cgit v1.2.3 From c59720c5f4c592688d2899b352f446703c968666 Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Tue, 30 Jan 2024 20:30:00 +0530 Subject: firmware: ti_sci: Add comment explaining the is_secure code Add a comment to explain the code under is_secure condition of ti_sci_do_xfer. This will help avoid confusion amongst people who may in future touch upon this code. Reviewed-by: Nishanth Menon Signed-off-by: Dhruva Gole --- drivers/firmware/ti_sci.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index b77ac36af2..ee09218558 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -239,6 +239,12 @@ static int ti_sci_do_xfer(struct ti_sci_info *info, struct ti_sci_secure_msg_hdr *secure_hdr = (struct ti_sci_secure_msg_hdr *)secure_buf; int ret; + /* + * The reason why we need the is_secure code is because of boot R5. + * boot R5 starts off in "secure mode" when it hands off from Boot + * ROM over to the Secondary bootloader. The initial set of calls + * we have to make need to be on a secure pipe. + */ if (info->is_secure) { /* ToDo: get checksum of the entire message */ secure_hdr->checksum = 0; -- cgit v1.2.3 From e5e7d8bbcffb26f5ac9a8fab7909225f527e157d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 31 Jan 2024 10:09:52 +0300 Subject: blk: host_dev: Fix error code in host_sb_attach_file() This error path should return -EINVAL instead of success. Fixes: e261fbf34785 ("blk: host_dev: Sanity check on the size of host backing file") Signed-off-by: Dan Carpenter --- drivers/block/host_dev.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/block/host_dev.c b/drivers/block/host_dev.c index 30c7415793..52313435a0 100644 --- a/drivers/block/host_dev.c +++ b/drivers/block/host_dev.c @@ -61,6 +61,7 @@ static int host_sb_attach_file(struct udevice *dev, const char *filename) if (size % desc->blksz) { printf("The size of host backing file '%s' is not multiple of " "the device block size\n", filename); + ret = -EINVAL; goto err_fname; } desc->lba = size / desc->blksz; -- cgit v1.2.3