@@ -642,87 +642,18 @@ static const struct pldmfw_ops ice_fwu_ops = {
642642};
643643
644644/**
645- * ice_flash_pldm_image - Write a PLDM-formatted firmware image to the device
646- * @pf: private device driver structure
647- * @fw: firmware object pointing to the relevant firmware file
648- * @preservation: preservation level to request from firmware
649- * @extack: netlink extended ACK structure
650- *
651- * Parse the data for a given firmware file, verifying that it is a valid PLDM
652- * formatted image that matches this device.
653- *
654- * Extract the device record Package Data and Component Tables and send them
655- * to the firmware. Extract and write the flash data for each of the three
656- * main flash components, "fw.mgmt", "fw.undi", and "fw.netlist". Notify
657- * firmware once the data is written to the inactive banks.
658- *
659- * Returns: zero on success or a negative error code on failure.
660- */
661- int ice_flash_pldm_image (struct ice_pf * pf , const struct firmware * fw ,
662- u8 preservation , struct netlink_ext_ack * extack )
663- {
664- struct device * dev = ice_pf_to_dev (pf );
665- struct ice_hw * hw = & pf -> hw ;
666- struct ice_fwu_priv priv ;
667- int err ;
668-
669- switch (preservation ) {
670- case ICE_AQC_NVM_PRESERVE_ALL :
671- case ICE_AQC_NVM_PRESERVE_SELECTED :
672- case ICE_AQC_NVM_NO_PRESERVATION :
673- case ICE_AQC_NVM_FACTORY_DEFAULT :
674- break ;
675- default :
676- WARN (1 , "Unexpected preservation level request %u" , preservation );
677- return - EINVAL ;
678- }
679-
680- memset (& priv , 0 , sizeof (priv ));
681-
682- priv .context .ops = & ice_fwu_ops ;
683- priv .context .dev = dev ;
684- priv .extack = extack ;
685- priv .pf = pf ;
686- priv .activate_flags = preservation ;
687-
688- err = ice_acquire_nvm (hw , ICE_RES_WRITE );
689- if (err ) {
690- dev_err (dev , "Failed to acquire device flash lock, err %d aq_err %s\n" ,
691- err , ice_aq_str (hw -> adminq .sq_last_status ));
692- NL_SET_ERR_MSG_MOD (extack , "Failed to acquire device flash lock" );
693- return err ;
694- }
695-
696- err = pldmfw_flash_image (& priv .context , fw );
697- if (err == - ENOENT ) {
698- dev_err (dev , "Firmware image has no record matching this device\n" );
699- NL_SET_ERR_MSG_MOD (extack , "Firmware image has no record matching this device" );
700- } else if (err ) {
701- /* Do not set a generic extended ACK message here. A more
702- * specific message may already have been set by one of our
703- * ops.
704- */
705- dev_err (dev , "Failed to flash PLDM image, err %d" , err );
706- }
707-
708- ice_release_nvm (hw );
709-
710- return err ;
711- }
712-
713- /**
714- * ice_check_for_pending_update - Check for a pending flash update
645+ * ice_cancel_pending_update - Cancel any pending update for a component
715646 * @pf: the PF driver structure
716647 * @component: if not NULL, the name of the component being updated
717648 * @extack: Netlink extended ACK structure
718649 *
719- * Check whether the device already has a pending flash update . If such an
720- * update is found, cancel it so that the requested update may proceed .
650+ * Cancel any pending update for the specified component . If component is
651+ * NULL, all device updates will be canceled .
721652 *
722653 * Returns: zero on success, or a negative error code on failure.
723654 */
724- int ice_check_for_pending_update (struct ice_pf * pf , const char * component ,
725- struct netlink_ext_ack * extack )
655+ int ice_cancel_pending_update (struct ice_pf * pf , const char * component ,
656+ struct netlink_ext_ack * extack )
726657{
727658 struct devlink * devlink = priv_to_devlink (pf );
728659 struct device * dev = ice_pf_to_dev (pf );
@@ -804,3 +735,72 @@ int ice_check_for_pending_update(struct ice_pf *pf, const char *component,
804735
805736 return err ;
806737}
738+
739+ /**
740+ * ice_flash_pldm_image - Write a PLDM-formatted firmware image to the device
741+ * @pf: private device driver structure
742+ * @fw: firmware object pointing to the relevant firmware file
743+ * @preservation: preservation level to request from firmware
744+ * @extack: netlink extended ACK structure
745+ *
746+ * Parse the data for a given firmware file, verifying that it is a valid PLDM
747+ * formatted image that matches this device.
748+ *
749+ * Extract the device record Package Data and Component Tables and send them
750+ * to the firmware. Extract and write the flash data for each of the three
751+ * main flash components, "fw.mgmt", "fw.undi", and "fw.netlist". Notify
752+ * firmware once the data is written to the inactive banks.
753+ *
754+ * Returns: zero on success or a negative error code on failure.
755+ */
756+ int ice_flash_pldm_image (struct ice_pf * pf , const struct firmware * fw ,
757+ u8 preservation , struct netlink_ext_ack * extack )
758+ {
759+ struct device * dev = ice_pf_to_dev (pf );
760+ struct ice_hw * hw = & pf -> hw ;
761+ struct ice_fwu_priv priv ;
762+ int err ;
763+
764+ switch (preservation ) {
765+ case ICE_AQC_NVM_PRESERVE_ALL :
766+ case ICE_AQC_NVM_PRESERVE_SELECTED :
767+ case ICE_AQC_NVM_NO_PRESERVATION :
768+ case ICE_AQC_NVM_FACTORY_DEFAULT :
769+ break ;
770+ default :
771+ WARN (1 , "Unexpected preservation level request %u" , preservation );
772+ return - EINVAL ;
773+ }
774+
775+ memset (& priv , 0 , sizeof (priv ));
776+
777+ priv .context .ops = & ice_fwu_ops ;
778+ priv .context .dev = dev ;
779+ priv .extack = extack ;
780+ priv .pf = pf ;
781+ priv .activate_flags = preservation ;
782+
783+ err = ice_acquire_nvm (hw , ICE_RES_WRITE );
784+ if (err ) {
785+ dev_err (dev , "Failed to acquire device flash lock, err %d aq_err %s\n" ,
786+ err , ice_aq_str (hw -> adminq .sq_last_status ));
787+ NL_SET_ERR_MSG_MOD (extack , "Failed to acquire device flash lock" );
788+ return err ;
789+ }
790+
791+ err = pldmfw_flash_image (& priv .context , fw );
792+ if (err == - ENOENT ) {
793+ dev_err (dev , "Firmware image has no record matching this device\n" );
794+ NL_SET_ERR_MSG_MOD (extack , "Firmware image has no record matching this device" );
795+ } else if (err ) {
796+ /* Do not set a generic extended ACK message here. A more
797+ * specific message may already have been set by one of our
798+ * ops.
799+ */
800+ dev_err (dev , "Failed to flash PLDM image, err %d" , err );
801+ }
802+
803+ ice_release_nvm (hw );
804+
805+ return err ;
806+ }
0 commit comments