@@ -682,6 +682,42 @@ int cudbg_collect_obq_sge_rx_q1(struct cudbg_init *pdbg_init,
682682 return cudbg_read_cim_obq (pdbg_init , dbg_buff , cudbg_err , 7 );
683683}
684684
685+ static int cudbg_meminfo_get_mem_index (struct adapter * padap ,
686+ struct cudbg_meminfo * mem_info ,
687+ u8 mem_type , u8 * idx )
688+ {
689+ u8 i , flag ;
690+
691+ switch (mem_type ) {
692+ case MEM_EDC0 :
693+ flag = EDC0_FLAG ;
694+ break ;
695+ case MEM_EDC1 :
696+ flag = EDC1_FLAG ;
697+ break ;
698+ case MEM_MC0 :
699+ /* Some T5 cards have both MC0 and MC1. */
700+ flag = is_t5 (padap -> params .chip ) ? MC0_FLAG : MC_FLAG ;
701+ break ;
702+ case MEM_MC1 :
703+ flag = MC1_FLAG ;
704+ break ;
705+ default :
706+ return CUDBG_STATUS_ENTITY_NOT_FOUND ;
707+ }
708+
709+ for (i = 0 ; i < mem_info -> avail_c ; i ++ ) {
710+ if (mem_info -> avail [i ].idx == flag ) {
711+ * idx = i ;
712+ return 0 ;
713+ }
714+ }
715+
716+ return CUDBG_STATUS_ENTITY_NOT_FOUND ;
717+ }
718+
719+ #define CUDBG_YIELD_ITERATION 256
720+
685721static int cudbg_read_fw_mem (struct cudbg_init * pdbg_init ,
686722 struct cudbg_buffer * dbg_buff , u8 mem_type ,
687723 unsigned long tot_len ,
@@ -690,10 +726,20 @@ static int cudbg_read_fw_mem(struct cudbg_init *pdbg_init,
690726 unsigned long bytes , bytes_left , bytes_read = 0 ;
691727 struct adapter * padap = pdbg_init -> adap ;
692728 struct cudbg_buffer temp_buff = { 0 };
729+ u32 yield_count = 0 ;
693730 int rc = 0 ;
694731
695732 bytes_left = tot_len ;
696733 while (bytes_left > 0 ) {
734+ /* As MC size is huge and read through PIO access, this
735+ * loop will hold cpu for a longer time. OS may think that
736+ * the process is hanged and will generate CPU stall traces.
737+ * So yield the cpu regularly.
738+ */
739+ yield_count ++ ;
740+ if (!(yield_count % CUDBG_YIELD_ITERATION ))
741+ schedule ();
742+
697743 bytes = min_t (unsigned long , bytes_left ,
698744 (unsigned long )CUDBG_CHUNK_SIZE );
699745 rc = cudbg_get_buff (dbg_buff , bytes , & temp_buff );
@@ -717,27 +763,6 @@ static int cudbg_read_fw_mem(struct cudbg_init *pdbg_init,
717763 return rc ;
718764}
719765
720- static void cudbg_collect_mem_info (struct cudbg_init * pdbg_init ,
721- struct card_mem * mem_info )
722- {
723- struct adapter * padap = pdbg_init -> adap ;
724- u32 value ;
725-
726- value = t4_read_reg (padap , MA_EDRAM0_BAR_A );
727- value = EDRAM0_SIZE_G (value );
728- mem_info -> size_edc0 = (u16 )value ;
729-
730- value = t4_read_reg (padap , MA_EDRAM1_BAR_A );
731- value = EDRAM1_SIZE_G (value );
732- mem_info -> size_edc1 = (u16 )value ;
733-
734- value = t4_read_reg (padap , MA_TARGET_MEM_ENABLE_A );
735- if (value & EDRAM0_ENABLE_F )
736- mem_info -> mem_flag |= (1 << EDC0_FLAG );
737- if (value & EDRAM1_ENABLE_F )
738- mem_info -> mem_flag |= (1 << EDC1_FLAG );
739- }
740-
741766static void cudbg_t4_fwcache (struct cudbg_init * pdbg_init ,
742767 struct cudbg_error * cudbg_err )
743768{
@@ -757,37 +782,25 @@ static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
757782 struct cudbg_error * cudbg_err ,
758783 u8 mem_type )
759784{
760- struct card_mem mem_info = {0 };
761- unsigned long flag , size ;
785+ struct adapter * padap = pdbg_init -> adap ;
786+ struct cudbg_meminfo mem_info ;
787+ unsigned long size ;
788+ u8 mc_idx ;
762789 int rc ;
763790
791+ memset (& mem_info , 0 , sizeof (struct cudbg_meminfo ));
792+ rc = cudbg_fill_meminfo (padap , & mem_info );
793+ if (rc )
794+ return rc ;
795+
764796 cudbg_t4_fwcache (pdbg_init , cudbg_err );
765- cudbg_collect_mem_info (pdbg_init , & mem_info );
766- switch (mem_type ) {
767- case MEM_EDC0 :
768- flag = (1 << EDC0_FLAG );
769- size = cudbg_mbytes_to_bytes (mem_info .size_edc0 );
770- break ;
771- case MEM_EDC1 :
772- flag = (1 << EDC1_FLAG );
773- size = cudbg_mbytes_to_bytes (mem_info .size_edc1 );
774- break ;
775- default :
776- rc = CUDBG_STATUS_ENTITY_NOT_FOUND ;
777- goto err ;
778- }
797+ rc = cudbg_meminfo_get_mem_index (padap , & mem_info , mem_type , & mc_idx );
798+ if (rc )
799+ return rc ;
779800
780- if (mem_info .mem_flag & flag ) {
781- rc = cudbg_read_fw_mem (pdbg_init , dbg_buff , mem_type ,
782- size , cudbg_err );
783- if (rc )
784- goto err ;
785- } else {
786- rc = CUDBG_STATUS_ENTITY_NOT_FOUND ;
787- goto err ;
788- }
789- err :
790- return rc ;
801+ size = mem_info .avail [mc_idx ].limit - mem_info .avail [mc_idx ].base ;
802+ return cudbg_read_fw_mem (pdbg_init , dbg_buff , mem_type , size ,
803+ cudbg_err );
791804}
792805
793806int cudbg_collect_edc0_meminfo (struct cudbg_init * pdbg_init ,
@@ -806,6 +819,22 @@ int cudbg_collect_edc1_meminfo(struct cudbg_init *pdbg_init,
806819 MEM_EDC1 );
807820}
808821
822+ int cudbg_collect_mc0_meminfo (struct cudbg_init * pdbg_init ,
823+ struct cudbg_buffer * dbg_buff ,
824+ struct cudbg_error * cudbg_err )
825+ {
826+ return cudbg_collect_mem_region (pdbg_init , dbg_buff , cudbg_err ,
827+ MEM_MC0 );
828+ }
829+
830+ int cudbg_collect_mc1_meminfo (struct cudbg_init * pdbg_init ,
831+ struct cudbg_buffer * dbg_buff ,
832+ struct cudbg_error * cudbg_err )
833+ {
834+ return cudbg_collect_mem_region (pdbg_init , dbg_buff , cudbg_err ,
835+ MEM_MC1 );
836+ }
837+
809838int cudbg_collect_rss (struct cudbg_init * pdbg_init ,
810839 struct cudbg_buffer * dbg_buff ,
811840 struct cudbg_error * cudbg_err )
0 commit comments