They don't need to make money selling chips if they can license their IP to people who run the foundries. IBM's prodigious patent portfolio is a huge revenue source for the company.
IBM just spun out a $19B annual revenue managed infrastructure business, Kyndryl. [1]
Doing some back of the napkin math on the remaining business, by revenue it is roughly 45% consulting, 40% software, and 15% hardware. IP revenue represents 1% ($626M) of its revenue. [2]
What does it actually do? At a high level, help companies deal with the complexities created in a world of heterogeneous infrastructure (data and AI across environments, common management/security, automation, etc.).
I don't know the numbers, but I do know they still do significant work in mainframes. They're even still designing their own Power processors for them.