Re: [PATCH 2/6] bus: mhi: add support to allocate rddm memory during crash time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 7/18/2024 9:52 PM, Jeffrey Hugo wrote:
On 7/18/2024 12:13 AM, Gokul Sriram Palanisamy wrote:
From: Ram Kumar D <quic_ramd@xxxxxxxxxxx>

Currently, MHI bus pre-allocates the RDDM buffer for crash dump
collection during MHI power up.

To avoid carving out memory for RDDM buffers even if it is unutilized,
add support to allocate memory at runtime during the RDDM download
after target crash.

This feature can be controlled by the client driver registering the MHI
controller by setting the rddm_prealloc flag to false in mhi_cntrl.
By default rddm_prealloc is true, retaining the existing behaviour.

By default, rddm_seg_len will be same as seg_len. The client driver
can override the mhi_cntrl->rddm_seg_len.

Signed-off-by: Ram Kumar D <quic_ramd@xxxxxxxxxxx>
Co-developed-by: Vignesh Viswanathan <quic_viswanat@xxxxxxxxxxx>
Signed-off-by: Vignesh Viswanathan <quic_viswanat@xxxxxxxxxxx>
Signed-off-by: Gokul Sriram Palanisamy <quic_gokulsri@xxxxxxxxxxx>
---
  drivers/bus/mhi/host/boot.c     | 149 +++++++++++++++++++++++++++-----
  drivers/bus/mhi/host/init.c     |  19 ++--
  drivers/bus/mhi/host/internal.h |  11 ++-
  drivers/bus/mhi/host/main.c     |   4 +-
  drivers/bus/mhi/host/pm.c       |   2 +-
  include/linux/mhi.h             |   2 +

NACK.  None of this gets used, making it dead code.
I didn't get it. Do you mean to say "mhi_cntrl->rddm_prealloc = true"  by default, so its dead code?

  6 files changed, 156 insertions(+), 31 deletions(-)

diff --git a/drivers/bus/mhi/host/boot.c b/drivers/bus/mhi/host/boot.c
index ca842facf820..1a918e340424 100644
--- a/drivers/bus/mhi/host/boot.c
+++ b/drivers/bus/mhi/host/boot.c
@@ -35,6 +35,16 @@ int mhi_rddm_prepare(struct mhi_controller *mhi_cntrl,
          bhi_vec->size = mhi_buf->len;
      }
  +    if (!mhi_cntrl->rddm_prealloc) {
+        mhi_buf->dma_addr = dma_map_single(mhi_cntrl->cntrl_dev,
+                           mhi_buf->buf, mhi_buf->len,
...
@@ -312,21 +367,31 @@ void mhi_free_bhie_table(struct mhi_controller *mhi_cntrl,
    int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl,
               struct image_info **image_info,
-             size_t alloc_size)
+             size_t alloc_size, enum image_type img_type)
  {
      size_t seg_size = mhi_cntrl->seg_len;
-    int segments = DIV_ROUND_UP(alloc_size, seg_size) + 1;
+    int segments;
      int i;
      struct image_info *img_info;
      struct mhi_buf *mhi_buf;
+    /* Masked __GFP_DIRECT_RECLAIM flag for non-interrupt context
+     * to avoid rcu context sleep issue in kmalloc during kernel panic
+     */

Incorrect comment style.

Will correct this.


Also, why would RDDM be relevant to a Linux kernel panic?  This makes me suspect a lot is wrong with this patch.

When mhi device crashed, kernel also could be in panic, so during panic, its necessary to collect RDDM. This state is already supported in mhi driver.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/bus/mhi/host/boot.c?h=v6.10#n163

...

+            /* Vector table is the last entry */
+            if (i == segments - 1) {
+                mhi_buf->buf = kzalloc(PAGE_ALIGN(vec_size),
+                               gfp);
+                if (!mhi_buf->buf)
+                    goto error_alloc_segment;
+
+                /* Vector table entry will be dma_mapped during
+                 * rddm prepare with DMA_TO_DEVICE and unmapped
+                 * once the target completes the RDDM XFER.

Incorrect comment style

will correct this.

Regards,

Gokul

+                 */
+                continue;
+            }
+            mhi_buf->buf = kmalloc(vec_size, gfp);
+            if (!mhi_buf->buf)
+                goto error_alloc_segment;
+




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux