NEW YORK - Serena Williams was in pain – “acceptable” pain, her coach called it–after rolling her right ankle during the second set of a US Open victory.

That was the bad news. On a day that defending men’s champion Novak Djokovic pulled out of his match because of a problematic left shoulder, the good news for Williams as she pursues a seventh championship at Flushing Meadows and 24th Grand Slam singles title overall is that, while she reached the quarterfinals by beating No. 22 seed Petra Martic 6-3, 6-4 despite the ankle issue, No. 2 Ash Barty and No. 3 Karolina Pliskova both exited her side of the bracket Sunday.

Not that Williams seemed to care all that much about being one of only three of the top 12 seeded women who will still be around Monday. “I can’t afford to look at it that way. Every single match I have played, people come and they play their best. The women that I play are not generally playing at this level against other players in the locker room, so for me, I have to be the greatest, whether it’s against the second seed, the No. 1 seed, or the No. 80th player in the world,” said Williams, who faces No. 18 Wang Qiang next. “I have to show up or else I’m going to go home.”

Williams, who turns 38 this month, appeared to be cruising along to a straightforward victory when she took an awkward step while up at the net for a volley. She tumbled to the ground and sat there, cross-legged, right in the middle of Arthur Ashe Stadium for a few moments.

Williams has dealt with various health issues all season, including one that ended her stay at the Australian Open. Might that sort of thing be happening again? Williams immediately asked for a trainer, who added tape to her lower right leg and foot during a medical timeout at the ensuing changeover. Still, Martic thought Williams’ play might actually have improved the rest of the way.

Williams ended things by raising both arms after smacking an ace at 118 mph, her fastest of the afternoon, punctuating an overpowering performance that included 38 winners to Martic’s 11. “I didn’t know what to expect from her ball. I knew she (hits it) hard,” Martic said, “but until you feel it on your own racket, you just don’t know what to expect.”

The scene Sunday brought back memories of Williams’ Australian Open quarterfinal in January against Pliskova. Williams was way ahead - holding a match point at 5-1, 40-30 in the third set - when she turned her left ankle awkwardly. From there, Williams was no longer, well, Williams, dropping every point she served the rest of the way. She failed to convert four match points in all that day, ceded six games in a row and lost 7-5 in the third. That time, Williams didn’t call for a trainer, which surprised many. Didn’t make that mistake this time. And a couple of hours later, she was walking without any apparent hitch in her step. She figured she’d know more about the ankle based on how it responds Monday; she plays Wang on Tuesday.

Wang, who never had played in the fourth round at a major until Sunday, advanced by surprising French Open champion Barty 6-2, 6-4. Pliskova, the 2016 US Open runner-up, went home with a 6-7 (1), 6-3, 7-5 loss over nearly 2½ hours against 16th-seeded Johanna Konta of Britain. This is the only Grand Slam tournament where Konta has yet to reach the semifinals; she’ll now meet No. 5 Elina Svitolina of Ukraine, who got past 2017 runner-up Madison Keys of the US 7-5, 6-4 Sunday night.

That was followed by Djokovic’s retirement against Stan Wawrinka in Sunday’s last singles match. Djokovic had been complaining that his left shoulder was hurting during the tournament, and he finally succumbed, stopping while trailing 6-4, 7-5, 2-1. “The pain was constant for weeks now,” Djokovic said.

Wawrinka moves on to face Daniil Medvedev. Reprising his trolling role at Louis Armstrong Stadium, the No. 5-seeded Russian again begged the crowd to boo him even more after he beat qualifier Dominik Koepfer 3-6, 6-3, 6-2, 7-6 (2). “You give me so much energy to win. Thank you!” he said, similar to his interaction with jeering spectators after his third-round win. “You are the best!”

Earlier Sunday, Roger Federer kept up his recent surge, dominating No. 15 seed David Goffin 6-2, 6-2, 6-0 in just 79 minutes. That’s one fewer minute than it took him to put together a 6-2, 6-2, 6-1 win against Dan Evans in the previous round. “I mean, look, sometimes these scores just happen. You catch a good day, the opponent doesn’t, then things happen very quickly,” said Federer, who lost in the fourth round a year ago in New York but also earned five of his 20 major championships at this hard-court tournament. “Maybe he struggled a bit early on. But I found my groove after a while and was able to roll, really. Never looked back.”