| ^~~~~~~~~~~~
drivers/scsi/scsi_debug.c: In function 'comp_write_worker':
drivers/scsi/scsi_debug.c:3034:9: error: implicit declaration of function 'sgl_compare_sgl_idx' [-Werror=implicit-function-declaration]
3034 | equ = sgl_compare_sgl_idx(store_sgl, sip->n_elem - sgl_i, rem,
| ^~~~~~~~~~~~~~~~~~~
drivers/scsi/scsi_debug.c: In function 'unmap_region':
drivers/scsi/scsi_debug.c:3505:5: error: implicit declaration of function 'sgl_memset'; did you mean 'memset'? [-Werror=implicit-function-declaration]
3505 | sgl_memset(store_sgl, sip->n_elem - sgl_i, rem, val,
| ^~~~~~~~~~
| memset
cc1: some warnings being treated as errors
vim +/sgl_copy_sgl +2970 drivers/scsi/scsi_debug.c
2938
2939 /* Returns number of bytes copied or -1 if error. */
2940 static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp,
2941 u32 data_inout_off, u64 lba, u32 n_blks, bool do_write)
2942 {
2943 int ret;
2944 u32 lb_size = sdebug_sector_size;
2945 u64 block, sgl_i, rem, lba_start, rest = 0;
2946 enum dma_data_direction dir;
2947 struct scsi_data_buffer *sdb = &scp->sdb;
2948 struct scatterlist *store_sgl;
2949
2950 if (do_write) {
2951 dir = DMA_TO_DEVICE;
2952 write_since_sync = true;
2953 } else {
2954 dir = DMA_FROM_DEVICE;
2955 }
2956
2957 if (!sdb->length || !sip)
2958 return 0;
2959 if (scp->sc_data_direction != dir)
2960 return -1;
2961 block = do_div(lba, sdebug_store_sectors);
2962 if (block + n_blks > sdebug_store_sectors)
2963 rest = block + n_blks - sdebug_store_sectors;
2964 lba_start = block * lb_size;
2965 sgl_i = lba_start >> sip->elem_pow2;
2966 rem = lba_start - (sgl_i ? (sgl_i << sip->elem_pow2) : 0);
2967 store_sgl = sip->sgl + sgl_i; /* O(1) to each store sg element */
2968
2969 if (do_write)
2970 ret = sgl_copy_sgl(store_sgl, sip->n_elem - sgl_i, rem,
2971 sdb->table.sgl, sdb->table.nents, data_inout_off,
2972 (n_blks - rest) * lb_size);
2973 else
2974 ret = sgl_copy_sgl(sdb->table.sgl, sdb->table.nents, data_inout_off,
2975 store_sgl, sip->n_elem - sgl_i, rem,
2976 (n_blks - rest) * lb_size);
2977
2978 if (ret != (n_blks - rest) * lb_size)
2979 return ret;
2980
2981 if (rest == 0)
2982 goto fini;
2983 if (do_write)
2984 ret += sgl_copy_sgl(sip->sgl, sip->n_elem, 0, sdb->table.sgl, sdb->table.nents,
2985 data_inout_off + ((n_blks - rest) * lb_size), rest * lb_size);
2986 else
2987 ret += sgl_copy_sgl(sdb->table.sgl, sdb->table.nents,
2988 data_inout_off + ((n_blks - rest) * lb_size),
2989 sip->sgl, sip->n_elem, 0, rest * lb_size);
2990 fini:
2991 return ret;
2992 }
2993
2994 /* Returns number of bytes copied or -1 if error. */
2995 static int do_dout_fetch(struct scsi_cmnd *scp, u32 num, u8 *doutp)
2996 {
2997 struct scsi_data_buffer *sdb = &scp->sdb;
2998
2999 if (!sdb->length)
3000 return 0;
3001 if (scp->sc_data_direction != DMA_TO_DEVICE)
3002 return -1;
3003 return sg_copy_buffer(sdb->table.sgl, sdb->table.nents, doutp,
3004 num * sdebug_sector_size, 0, true);
3005 }
3006
3007 /* If sip->storep+lba compares equal to arr(num) or scp->sdb, then if miscomp_idxp is non-NULL,
3008 * copy top half of arr into sip->storep+lba and return true. If comparison fails then return
3009 * false and write the miscompare_idx via miscomp_idxp. Thsi is the COMAPARE AND WRITE case.
3010 * For VERIFY(BytChk=1), set arr to NULL which causes a sgl (store) to sgl (data-out buffer)
3011 * compare to be done. VERIFY(BytChk=3) sets arr to a valid address and sets miscomp_idxp
3012 * to NULL.
3013 */
3014 static bool comp_write_worker(struct sdeb_store_info *sip, u64 lba, u32 num,
3015 const u8 *arr, struct scsi_cmnd *scp, size_t *miscomp_idxp)
3016 {
3017 bool equ;
3018 u64 block, lba_start, sgl_i, rem, rest = 0;
3019 u32 store_blks = sdebug_store_sectors;
3020 const u32 lb_size = sdebug_sector_size;
3021 u32 top_half = num * lb_size;
3022 struct scsi_data_buffer *sdb = &scp->sdb;
3023 struct scatterlist *store_sgl;
3024
3025 block = do_div(lba, store_blks);
3026 if (block + num > store_blks)
3027 rest = block + num - store_blks;
3028 lba_start = block * lb_size;
3029 sgl_i = lba_start >> sip->elem_pow2;
3030 rem = lba_start - (sgl_i ? (sgl_i << sip->elem_pow2) : 0);
3031 store_sgl = sip->sgl + sgl_i; /* O(1) to each store sg element */
3032
3033 if (!arr) { /* sgl to sgl compare */
3034 equ = sgl_compare_sgl_idx(store_sgl, sip->n_elem - sgl_i, rem,
3035 sdb->table.sgl, sdb->table.nents, 0,
3036 (num - rest) * lb_size, miscomp_idxp);
3037 if (!equ)
3038 return equ;
3039 if (rest > 0)
3040 equ = sgl_compare_sgl_idx(sip->sgl, sip->n_elem, 0, sdb->table.sgl,
3041 sdb->table.nents, (num - rest) * lb_size,
3042 rest * lb_size, miscomp_idxp);
3043 } else {
3044 equ = sdeb_sgl_cmp_buf(store_sgl, sip->n_elem - sgl_i, arr,
3045 (num - rest) * lb_size, 0);
3046 if (!equ)
3047 return equ;
3048 if (rest > 0)
3049 equ = sdeb_sgl_cmp_buf(sip->sgl, sip->n_elem, arr,
3050 (num - rest) * lb_size, 0);
3051 }
3052 if (!equ || !miscomp_idxp)
3053 return equ;
3054
3055 /* Copy "top half" of dout (args: 4, 5 and 6) into store sgl (args 1, 2 and 3) */
3056 sgl_copy_sgl(store_sgl, sip->n_elem - sgl_i, rem,
3057 sdb->table.sgl, sdb->table.nents, top_half,
3058 (num - rest) * lb_size);
3059 if (rest > 0) { /* for virtual_gb need to handle wrap-around of store */
3060 u32 src_off = top_half + ((num - rest) * lb_size);
3061
3062 sgl_copy_sgl(sip->sgl, sip->n_elem, 0,
3063 sdb->table.sgl, sdb->table.nents, src_off,
3064 rest * lb_size);
3065 }
3066 return true;
3067 }
3068
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx