Message ID | 20220715150219.16875-2-sreekanth.reddy@broadcom.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | mpi3mr: Fix compilation errors on i386 arch | expand |
On 7/15/22 08:02, Sreekanth Reddy wrote: > Fix below compilation errors observed on i386 ARCH, > > cast from pointer to integer of different size > [-Werror=pointer-to-int-cast] > > Fixes: c196bc4dce ("scsi: mpi3mr: Reduce VD queue depth on detecting throttling") > Reported-by: Guenter Roeck <linux@roeck-us.net> > Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> > --- > drivers/scsi/mpi3mr/mpi3mr_os.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c > index 0901bc932d5c..d8013576d863 100644 > --- a/drivers/scsi/mpi3mr/mpi3mr_os.c > +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c > @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, > ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); > return; > } > - *(__le64 *)fwevt->event_data = (__le64)tg; > + memcpy(fwevt->event_data, (char *)&tg, sizeof(u64)); > fwevt->mrioc = mrioc; > fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; > fwevt->send_ack = 0; > @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, > { > struct mpi3mr_throttle_group_info *tg; > > - tg = (struct mpi3mr_throttle_group_info *) > - (*(__le64 *)fwevt->event_data); > + memcpy((char *)&tg, fwevt->event_data, sizeof(u64)); How is this expected to work on a system with 32-bit pointers ? Guenter > dprint_event_bh(mrioc, > "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", > tg->id, tg->need_qd_reduction);
Hi Guenter, Please check the changes below. I hope this change will work with 32-bit pointers as well. If it looks good then I will post this change as a patch. diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 0901bc932d5c..0bba19c0f984 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); return; } - *(__le64 *)fwevt->event_data = (__le64)tg; + memcpy(fwevt->event_data, (char *)&tg, sizeof(void *)); fwevt->mrioc = mrioc; fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; fwevt->send_ack = 0; @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, { struct mpi3mr_throttle_group_info *tg; - tg = (struct mpi3mr_throttle_group_info *) - (*(__le64 *)fwevt->event_data); + memcpy((char *)&tg, fwevt->event_data, sizeof(void *)); dprint_event_bh(mrioc, "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", tg->id, tg->need_qd_reduction); Thanks, Sreekanth On Fri, Jul 15, 2022 at 10:19 PM Guenter Roeck <linux@roeck-us.net> wrote: > > On 7/15/22 08:02, Sreekanth Reddy wrote: > > Fix below compilation errors observed on i386 ARCH, > > > > cast from pointer to integer of different size > > [-Werror=pointer-to-int-cast] > > > > Fixes: c196bc4dce ("scsi: mpi3mr: Reduce VD queue depth on detecting throttling") > > Reported-by: Guenter Roeck <linux@roeck-us.net> > > Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> > > --- > > drivers/scsi/mpi3mr/mpi3mr_os.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c > > index 0901bc932d5c..d8013576d863 100644 > > --- a/drivers/scsi/mpi3mr/mpi3mr_os.c > > +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c > > @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, > > ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); > > return; > > } > > - *(__le64 *)fwevt->event_data = (__le64)tg; > > + memcpy(fwevt->event_data, (char *)&tg, sizeof(u64)); > > fwevt->mrioc = mrioc; > > fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; > > fwevt->send_ack = 0; > > @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, > > { > > struct mpi3mr_throttle_group_info *tg; > > > > - tg = (struct mpi3mr_throttle_group_info *) > > - (*(__le64 *)fwevt->event_data); > > + memcpy((char *)&tg, fwevt->event_data, sizeof(u64)); > > How is this expected to work on a system with 32-bit pointers ? > > Guenter > > > dprint_event_bh(mrioc, > > "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", > > tg->id, tg->need_qd_reduction); >
On 7/16/22 06:35, Sreekanth Reddy wrote: > Please check the changes below. I hope this change will work with > 32-bit pointers as well. If it looks good then I will post this > change as a patch. > > diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c > index 0901bc932d5c..0bba19c0f984 100644 > --- a/drivers/scsi/mpi3mr/mpi3mr_os.c > +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c > @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct > mpi3mr_ioc *mrioc, > ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); > return; > } > - *(__le64 *)fwevt->event_data = (__le64)tg; > + memcpy(fwevt->event_data, (char *)&tg, sizeof(void *)); > fwevt->mrioc = mrioc; > fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; > fwevt->send_ack = 0; > @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, > { > struct mpi3mr_throttle_group_info *tg; > > - tg = (struct mpi3mr_throttle_group_info *) > - (*(__le64 *)fwevt->event_data); > + memcpy((char *)&tg, fwevt->event_data, sizeof(void *)); > dprint_event_bh(mrioc, > "qd reduction event processed for tg_id(%d) > reduction_needed(%d)\n", > tg->id, tg->need_qd_reduction); How about reverting c196bc4dce ("scsi: mpi3mr: Reduce VD queue depth on detecting throttling") to remove the time pressure for coming up with a fix for that commit? Thanks, Bart.
On 7/16/22 06:35, Sreekanth Reddy wrote: > Hi Guenter, > > Please check the changes below. I hope this change will work with > 32-bit pointers as well. If it looks good then I will post this > change as a patch. > > diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c > index 0901bc932d5c..0bba19c0f984 100644 > --- a/drivers/scsi/mpi3mr/mpi3mr_os.c > +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c > @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct > mpi3mr_ioc *mrioc, > ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); > return; > } > - *(__le64 *)fwevt->event_data = (__le64)tg; > + memcpy(fwevt->event_data, (char *)&tg, sizeof(void *)); > fwevt->mrioc = mrioc; > fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; > fwevt->send_ack = 0; > @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, > { > struct mpi3mr_throttle_group_info *tg; > > - tg = (struct mpi3mr_throttle_group_info *) > - (*(__le64 *)fwevt->event_data); > + memcpy((char *)&tg, fwevt->event_data, sizeof(void *)); > dprint_event_bh(mrioc, > "qd reduction event processed for tg_id(%d) > reduction_needed(%d)\n", > tg->id, tg->need_qd_reduction); > If I understand correctly, you want to pass the pointer to tg along. If so, the following seems cleaner and less confusing to me. diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 6a47f8c77256..f581c07c2665 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); return; } - *(__le64 *)fwevt->event_data = (__le64)tg; + *(struct mpi3mr_throttle_group_info **)fwevt->event_data = tg; fwevt->mrioc = mrioc; fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; fwevt->send_ack = 0; @@ -1652,8 +1652,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, { struct mpi3mr_throttle_group_info *tg; - tg = (struct mpi3mr_throttle_group_info *) - (*(__le64 *)fwevt->event_data); + tg = *(struct mpi3mr_throttle_group_info **)fwevt->event_data; dprint_event_bh(mrioc, "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", tg->id, tg->need_qd_reduction); or simply diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 6a47f8c77256..cc93b41dd428 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); return; } - *(__le64 *)fwevt->event_data = (__le64)tg; + *(void **)fwevt->event_data = tg; fwevt->mrioc = mrioc; fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; fwevt->send_ack = 0; @@ -1652,8 +1652,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, { struct mpi3mr_throttle_group_info *tg; - tg = (struct mpi3mr_throttle_group_info *) - (*(__le64 *)fwevt->event_data); + tg = *(void **)fwevt->event_data; dprint_event_bh(mrioc, "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", tg->id, tg->need_qd_reduction); Thanks, Guenter > Thanks, > Sreekanth > > On Fri, Jul 15, 2022 at 10:19 PM Guenter Roeck <linux@roeck-us.net> wrote: >> >> On 7/15/22 08:02, Sreekanth Reddy wrote: >>> Fix below compilation errors observed on i386 ARCH, >>> >>> cast from pointer to integer of different size >>> [-Werror=pointer-to-int-cast] >>> >>> Fixes: c196bc4dce ("scsi: mpi3mr: Reduce VD queue depth on detecting throttling") >>> Reported-by: Guenter Roeck <linux@roeck-us.net> >>> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> >>> --- >>> drivers/scsi/mpi3mr/mpi3mr_os.c | 5 ++--- >>> 1 file changed, 2 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c >>> index 0901bc932d5c..d8013576d863 100644 >>> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c >>> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c >>> @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, >>> ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); >>> return; >>> } >>> - *(__le64 *)fwevt->event_data = (__le64)tg; >>> + memcpy(fwevt->event_data, (char *)&tg, sizeof(u64)); >>> fwevt->mrioc = mrioc; >>> fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; >>> fwevt->send_ack = 0; >>> @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, >>> { >>> struct mpi3mr_throttle_group_info *tg; >>> >>> - tg = (struct mpi3mr_throttle_group_info *) >>> - (*(__le64 *)fwevt->event_data); >>> + memcpy((char *)&tg, fwevt->event_data, sizeof(u64)); >> >> How is this expected to work on a system with 32-bit pointers ? >> >> Guenter >> >>> dprint_event_bh(mrioc, >>> "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", >>> tg->id, tg->need_qd_reduction); >>
On 7/16/22 06:45, Bart Van Assche wrote: > On 7/16/22 06:35, Sreekanth Reddy wrote: >> Please check the changes below. I hope this change will work with >> 32-bit pointers as well. If it looks good then I will post this >> change as a patch. >> >> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c >> index 0901bc932d5c..0bba19c0f984 100644 >> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c >> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c >> @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct >> mpi3mr_ioc *mrioc, >> ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); >> return; >> } >> - *(__le64 *)fwevt->event_data = (__le64)tg; >> + memcpy(fwevt->event_data, (char *)&tg, sizeof(void *)); >> fwevt->mrioc = mrioc; >> fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; >> fwevt->send_ack = 0; >> @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, >> { >> struct mpi3mr_throttle_group_info *tg; >> >> - tg = (struct mpi3mr_throttle_group_info *) >> - (*(__le64 *)fwevt->event_data); >> + memcpy((char *)&tg, fwevt->event_data, sizeof(void *)); >> dprint_event_bh(mrioc, >> "qd reduction event processed for tg_id(%d) >> reduction_needed(%d)\n", >> tg->id, tg->need_qd_reduction); > > How about reverting c196bc4dce ("scsi: mpi3mr: Reduce VD queue depth on detecting throttling") to remove the time pressure for coming up with a fix for that commit? > Fortunately this is only seen in linux-next, so there would still be a week or two to do that. Really, I am happy that this is looked at - we still have build regressions from the last merge window in v5.19-rc6, and it sometimes takes Linus to intervene to get things fixed there. Thanks, Guenter
Hi Sreekanth, I love your patch! Perhaps something to improve: [auto build test WARNING on mkp-scsi/for-next] [also build test WARNING on next-20220714] [cannot apply to jejb-scsi/for-next linus/master v5.19-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Sreekanth-Reddy/mpi3mr-Fix-compilation-errors-on-i386-arch/20220716-211058 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next config: i386-randconfig-a013 (https://download.01.org/0day-ci/archive/20220717/202207170253.TJixMaQt-lkp@intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 07022e6cf9b5b3baa642be53d0b3c3f1c403dbfd) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/1fe83692304d301bd0737ed16c8bd1bcd8c0fa90 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Sreekanth-Reddy/mpi3mr-Fix-compilation-errors-on-i386-arch/20220716-211058 git checkout 1fe83692304d301bd0737ed16c8bd1bcd8c0fa90 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/scsi/mpi3mr/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/scsi/mpi3mr/mpi3mr_os.c:1663:3: warning: 'memcpy' will always overflow; destination buffer has size 4, but size argument is 8 [-Wfortify-source] memcpy((char *)&tg, fwevt->event_data, sizeof(u64)); ^ arch/x86/include/asm/string_32.h:150:25: note: expanded from macro 'memcpy' #define memcpy(t, f, n) __builtin_memcpy(t, f, n) ^ 1 warning generated. vim +/memcpy +1663 drivers/scsi/mpi3mr/mpi3mr_os.c 1601 1602 /** 1603 * mpi3mr_fwevt_bh - Firmware event bottomhalf handler 1604 * @mrioc: Adapter instance reference 1605 * @fwevt: Firmware event reference 1606 * 1607 * Identifies the firmware event and calls corresponding bottomg 1608 * half handler and sends event acknowledgment if required. 1609 * 1610 * Return: Nothing. 1611 */ 1612 static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, 1613 struct mpi3mr_fwevt *fwevt) 1614 { 1615 mpi3mr_fwevt_del_from_list(mrioc, fwevt); 1616 mrioc->current_event = fwevt; 1617 1618 if (mrioc->stop_drv_processing) 1619 goto out; 1620 1621 if (!fwevt->process_evt) 1622 goto evt_ack; 1623 1624 switch (fwevt->event_id) { 1625 case MPI3_EVENT_DEVICE_ADDED: 1626 { 1627 struct mpi3_device_page0 *dev_pg0 = 1628 (struct mpi3_device_page0 *)fwevt->event_data; 1629 mpi3mr_report_tgtdev_to_host(mrioc, 1630 le16_to_cpu(dev_pg0->persistent_id)); 1631 break; 1632 } 1633 case MPI3_EVENT_DEVICE_INFO_CHANGED: 1634 { 1635 mpi3mr_devinfochg_evt_bh(mrioc, 1636 (struct mpi3_device_page0 *)fwevt->event_data); 1637 break; 1638 } 1639 case MPI3_EVENT_DEVICE_STATUS_CHANGE: 1640 { 1641 mpi3mr_devstatuschg_evt_bh(mrioc, fwevt); 1642 break; 1643 } 1644 case MPI3_EVENT_SAS_TOPOLOGY_CHANGE_LIST: 1645 { 1646 mpi3mr_sastopochg_evt_bh(mrioc, fwevt); 1647 break; 1648 } 1649 case MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST: 1650 { 1651 mpi3mr_pcietopochg_evt_bh(mrioc, fwevt); 1652 break; 1653 } 1654 case MPI3_EVENT_LOG_DATA: 1655 { 1656 mpi3mr_logdata_evt_bh(mrioc, fwevt); 1657 break; 1658 } 1659 case MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION: 1660 { 1661 struct mpi3mr_throttle_group_info *tg; 1662 > 1663 memcpy((char *)&tg, fwevt->event_data, sizeof(u64)); 1664 dprint_event_bh(mrioc, 1665 "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", 1666 tg->id, tg->need_qd_reduction); 1667 if (tg->need_qd_reduction) { 1668 mpi3mr_set_qd_for_all_vd_in_tg(mrioc, tg); 1669 tg->need_qd_reduction = 0; 1670 } 1671 break; 1672 } 1673 default: 1674 break; 1675 } 1676 1677 evt_ack: 1678 if (fwevt->send_ack) 1679 mpi3mr_process_event_ack(mrioc, fwevt->event_id, 1680 fwevt->evt_ctx); 1681 out: 1682 /* Put fwevt reference count to neutralize kref_init increment */ 1683 mpi3mr_fwevt_put(fwevt); 1684 mrioc->current_event = NULL; 1685 } 1686
On Sat, Jul 16, 2022 at 7:34 PM Guenter Roeck <linux@roeck-us.net> wrote: > > On 7/16/22 06:35, Sreekanth Reddy wrote: > > Hi Guenter, > > > > Please check the changes below. I hope this change will work with > > 32-bit pointers as well. If it looks good then I will post this > > change as a patch. > > > > diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c > > index 0901bc932d5c..0bba19c0f984 100644 > > --- a/drivers/scsi/mpi3mr/mpi3mr_os.c > > +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c > > @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct > > mpi3mr_ioc *mrioc, > > ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); > > return; > > } > > - *(__le64 *)fwevt->event_data = (__le64)tg; > > + memcpy(fwevt->event_data, (char *)&tg, sizeof(void *)); > fwevt->mrioc = mrioc; > > fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; > > fwevt->send_ack = 0; > > @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, > > { > > struct mpi3mr_throttle_group_info *tg; > > > > - tg = (struct mpi3mr_throttle_group_info *) > > - (*(__le64 *)fwevt->event_data); > > + memcpy((char *)&tg, fwevt->event_data, sizeof(void *)); > > dprint_event_bh(mrioc, > > "qd reduction event processed for tg_id(%d) > > reduction_needed(%d)\n", > > tg->id, tg->need_qd_reduction); > > > > If I understand correctly, you want to pass the pointer to tg along. If so, > the following seems cleaner and less confusing to me. Yes, it is correct. I have posted a new patch with your suggested changes below. https://patchwork.kernel.org/project/linux-scsi/patch/20220718095351.15868-2-sreekanth.reddy@broadcom.com/ Thanks, Sreekanth > > diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c > index 6a47f8c77256..f581c07c2665 100644 > --- a/drivers/scsi/mpi3mr/mpi3mr_os.c > +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c > @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, > ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); > return; > } > - *(__le64 *)fwevt->event_data = (__le64)tg; > + *(struct mpi3mr_throttle_group_info **)fwevt->event_data = tg; > fwevt->mrioc = mrioc; > fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; > fwevt->send_ack = 0; > @@ -1652,8 +1652,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, > { > struct mpi3mr_throttle_group_info *tg; > > - tg = (struct mpi3mr_throttle_group_info *) > - (*(__le64 *)fwevt->event_data); > + tg = *(struct mpi3mr_throttle_group_info **)fwevt->event_data; > dprint_event_bh(mrioc, > "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", > tg->id, tg->need_qd_reduction); > > or simply > > diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c > index 6a47f8c77256..cc93b41dd428 100644 > --- a/drivers/scsi/mpi3mr/mpi3mr_os.c > +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c > @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, > ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); > return; > } > - *(__le64 *)fwevt->event_data = (__le64)tg; > + *(void **)fwevt->event_data = tg; > fwevt->mrioc = mrioc; > fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; > fwevt->send_ack = 0; > @@ -1652,8 +1652,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, > { > struct mpi3mr_throttle_group_info *tg; > > - tg = (struct mpi3mr_throttle_group_info *) > - (*(__le64 *)fwevt->event_data); > + tg = *(void **)fwevt->event_data; > dprint_event_bh(mrioc, > "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", > tg->id, tg->need_qd_reduction); > > Thanks, > Guenter > > > Thanks, > > Sreekanth > > > > On Fri, Jul 15, 2022 at 10:19 PM Guenter Roeck <linux@roeck-us.net> wrote: > >> > >> On 7/15/22 08:02, Sreekanth Reddy wrote: > >>> Fix below compilation errors observed on i386 ARCH, > >>> > >>> cast from pointer to integer of different size > >>> [-Werror=pointer-to-int-cast] > >>> > >>> Fixes: c196bc4dce ("scsi: mpi3mr: Reduce VD queue depth on detecting throttling") > >>> Reported-by: Guenter Roeck <linux@roeck-us.net> > >>> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> > >>> --- > >>> drivers/scsi/mpi3mr/mpi3mr_os.c | 5 ++--- > >>> 1 file changed, 2 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c > >>> index 0901bc932d5c..d8013576d863 100644 > >>> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c > >>> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c > >>> @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, > >>> ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); > >>> return; > >>> } > >>> - *(__le64 *)fwevt->event_data = (__le64)tg; > >>> + memcpy(fwevt->event_data, (char *)&tg, sizeof(u64)); > >>> fwevt->mrioc = mrioc; > >>> fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; > >>> fwevt->send_ack = 0; > >>> @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, > >>> { > >>> struct mpi3mr_throttle_group_info *tg; > >>> > >>> - tg = (struct mpi3mr_throttle_group_info *) > >>> - (*(__le64 *)fwevt->event_data); > >>> + memcpy((char *)&tg, fwevt->event_data, sizeof(u64)); > >> > >> How is this expected to work on a system with 32-bit pointers ? > >> > >> Guenter > >> > >>> dprint_event_bh(mrioc, > >>> "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", > >>> tg->id, tg->need_qd_reduction); > >> >
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 0901bc932d5c..d8013576d863 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -386,7 +386,7 @@ static void mpi3mr_queue_qd_reduction_event(struct mpi3mr_ioc *mrioc, ioc_warn(mrioc, "failed to queue TG QD reduction event\n"); return; } - *(__le64 *)fwevt->event_data = (__le64)tg; + memcpy(fwevt->event_data, (char *)&tg, sizeof(u64)); fwevt->mrioc = mrioc; fwevt->event_id = MPI3MR_DRIVER_EVENT_TG_QD_REDUCTION; fwevt->send_ack = 0; @@ -1660,8 +1660,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, { struct mpi3mr_throttle_group_info *tg; - tg = (struct mpi3mr_throttle_group_info *) - (*(__le64 *)fwevt->event_data); + memcpy((char *)&tg, fwevt->event_data, sizeof(u64)); dprint_event_bh(mrioc, "qd reduction event processed for tg_id(%d) reduction_needed(%d)\n", tg->id, tg->need_qd_reduction);
Fix below compilation errors observed on i386 ARCH, cast from pointer to integer of different size [-Werror=pointer-to-int-cast] Fixes: c196bc4dce ("scsi: mpi3mr: Reduce VD queue depth on detecting throttling") Reported-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> --- drivers/scsi/mpi3mr/mpi3mr_os.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)