It appears to be a BrE term:
also sterr, stur
[abbr. Rom. sturiben, a prison, staripen, to imprison; ult. štar, to imprison]
1835 [UK] Worcester Herald 26 Dec. 4/3: Sturabin a gaol.
1859 [UK] Hotten Dict. of Modern Sl. etc. 52: IN STIR, to be in prison.
1861 [UK] (con. 1840s–50s) H. Mayhew London Labour and London Poor I 219/1: Just out of ‘stir’ (jail) for ‘muzzling a peeler’.
Its origin may derive from a notorious London prison nicknamed Start according to:
the Barnhart Dictionary of Etymology, stir may have originated as a variation on Start, a nickname criminals gave to Newgate, a notorious prison throughout London’s history. Stir, if this is true, broadened out from “Newgate” specifically to “prison” in general.
The term started to be used in AmE from early 20th century:
- 1900 [US] Flynt & Walton Powers That Prey 41: If you shouldn’t happen to discover a way of helpin’ me, that telegram reads cuffs in Clinton Place, jail in Akron, Stir in Columbus.
By the early 20th century, stir had traveled to the United States, where crazy was added to describe “a prisoner who has succumbed to prison-induced insanity,” as slang lexicographer Jonathon Green defines it.
He points out many colorful permutations: Stir-bug, stir-nut,
stir-psycho, and stir-simple all referred to such prisoners who had
gone stir-crazy, while stir-batty, stir-happy, and stir-looney were
other ways to characterize the experience. US prison slang used stir
for other terms throughout the 20th century, too, such as a stir
hustler (“one who has mastered the ‘art’ of incarceration”) and stir
lawyer (“a fellow prisoner who offers advice based on his own
purported legal expertise”). Green also finds stir active more
recently, used for “time served in prison” come the 2010s.(GDoS)