I set the FLASH_ACR register appropriately and the problem was solved:
rcc.cr.modify(|_, w| w.hseon().on());
while rcc.cr.read().hserdy().is_not_ready() {}
println!("Hse ready");
rcc.pllcfgr.modify(|_, w| w.pllsrc().hse());
rcc.pllcfgr.modify(unsafe {|_, w| w.pllm().bits(4)});
rcc.pllcfgr.modify(unsafe {|_, w| w.plln().bits(108)});
rcc.pllcfgr.modify(|_, w| w.pllp().div2());
rcc.cr.modify(|_, w| w.pllon().on());
while rcc.cr.read().pllrdy().is_not_ready() {}
println!("Pll ready");
dp.FLASH.acr.modify(|_, w| w.latency().ws9());
while !dp.FLASH.acr.read().latency().is_ws9() {}
rcc.cfgr.modify(|_, w| w
.ppre1().div2()
.ppre2().div2()
);
rcc.cfgr.modify(|_, w| w.sw().pll());
while !rcc.cfgr.read().sws().is_pll() {}
println!("pll selectected");